本文整理匯總了Java中com.intellij.psi.PsiNameIdentifierOwner.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiNameIdentifierOwner.getName方法的具體用法?Java PsiNameIdentifierOwner.getName怎麽用?Java PsiNameIdentifierOwner.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiNameIdentifierOwner
的用法示例。
在下文中一共展示了PsiNameIdentifierOwner.getName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processElement
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
private void processElement(@NotNull PsiNameIdentifierOwner element) {
final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
if (owner instanceof PyClass) {
return;
}
final String name = element.getName();
if (name != null && !myIgnoredNames.contains(name)) {
final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(element);
final PsiElement builtin = builtinCache.getByName(name);
if (builtin != null && !PyUtil.inSameFile(builtin, element)) {
final PsiElement identifier = element.getNameIdentifier();
final PsiElement problemElement = identifier != null ? identifier : element;
registerProblem(problemElement, String.format("Shadows built-in name '%s'", name),
ProblemHighlightType.WEAK_WARNING, null, new PyRenameElementQuickFix(), new PyIgnoreBuiltinQuickFix(name));
}
}
}
示例2: initOccurrencesNumber
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
protected static int initOccurrencesNumber(PsiNameIdentifierOwner nameIdentifierOwner) {
final ProgressManager progressManager = ProgressManager.getInstance();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(nameIdentifierOwner.getProject());
final GlobalSearchScope scope = GlobalSearchScope.projectScope(nameIdentifierOwner.getProject());
final String name = nameIdentifierOwner.getName();
final boolean isCheapToSearch =
name != null && searchHelper.isCheapEnoughToSearch(name, scope, null, progressManager.getProgressIndicator()) != PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
return isCheapToSearch ? ReferencesSearch.search(nameIdentifierOwner).findAll().size() : - 1;
}
示例3: processElement
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
private void processElement(@NotNull PsiNameIdentifierOwner element) {
final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
if (owner instanceof PyClass) {
return;
}
final String name = element.getName();
if (name != null) {
final PsiElement identifier = element.getNameIdentifier();
final PsiElement problemElement = identifier != null ? identifier : element;
if ("_".equals(name)) {
return;
}
if (owner != null) {
final ScopeOwner nextOwner = ScopeUtil.getScopeOwner(owner);
if (nextOwner != null) {
final ResolveProcessor processor = new ResolveProcessor(name);
PyResolveUtil.scopeCrawlUp(processor, nextOwner, null, name, null, null);
final PsiElement resolved = processor.getResult();
if (resolved != null) {
final PyComprehensionElement comprehension = PsiTreeUtil.getParentOfType(resolved, PyComprehensionElement.class);
if (comprehension != null && PyUtil.isOwnScopeComprehension(comprehension)) {
return;
}
final Scope scope = ControlFlowCache.getScope(owner);
if (scope.isGlobal(name) || scope.isNonlocal(name)) {
return;
}
registerProblem(problemElement, String.format("Shadows name '%s' from outer scope", name),
ProblemHighlightType.WEAK_WARNING, null, new PyRenameElementQuickFix());
}
}
}
}
}
示例4: perform
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
public void perform() {
final PsiNameIdentifierOwner element = getNamedElement();
if (element != null) {
final String name = element.getName();
ApplicationManager.getApplication().runWriteAction(() -> {
element.setName(myOldName);
});
new RenameProcessor(element.getProject(), element, name, false, false).run();
}
}
示例5: processElement
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
private void processElement(@NotNull final PsiNameIdentifierOwner element) {
if (isConditional(element)) {
return;
}
final String name = element.getName();
final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
if (owner != null && name != null) {
final Instruction[] instructions = ControlFlowCache.getControlFlow(owner).getInstructions();
PsiElement elementInControlFlow = element;
if (element instanceof PyTargetExpression) {
final PyImportStatement importStatement = PsiTreeUtil.getParentOfType(element, PyImportStatement.class);
if (importStatement != null) {
elementInControlFlow = importStatement;
}
}
final int startInstruction = ControlFlowUtil.findInstructionNumberByElement(instructions, elementInControlFlow);
if (startInstruction < 0) {
return;
}
final Ref<PsiElement> readElementRef = Ref.create(null);
final Ref<PsiElement> writeElementRef = Ref.create(null);
ControlFlowUtil.iteratePrev(startInstruction, instructions, new Function<Instruction, ControlFlowUtil.Operation>() {
@Override
public ControlFlowUtil.Operation fun(Instruction instruction) {
if (instruction instanceof ReadWriteInstruction && instruction.num() != startInstruction) {
final ReadWriteInstruction rwInstruction = (ReadWriteInstruction)instruction;
if (name.equals(rwInstruction.getName())) {
final PsiElement originalElement = rwInstruction.getElement();
if (originalElement != null) {
if (rwInstruction.getAccess().isReadAccess()) {
readElementRef.set(originalElement);
}
if (rwInstruction.getAccess().isWriteAccess()) {
if (originalElement != element) {
writeElementRef.set(originalElement);
}
}
}
return ControlFlowUtil.Operation.CONTINUE;
}
}
return ControlFlowUtil.Operation.NEXT;
}
});
final PsiElement writeElement = writeElementRef.get();
if (writeElement != null && readElementRef.get() == null) {
final List<LocalQuickFix> quickFixes = new ArrayList<LocalQuickFix>();
if (suggestRename(element, writeElement)) {
quickFixes.add(new PyRenameElementQuickFix());
}
final PsiElement identifier = element.getNameIdentifier();
registerProblem(identifier != null ? identifier : element,
PyBundle.message("INSP.redeclared.name", name),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
null,
quickFixes.toArray(new LocalQuickFix[quickFixes.size()]));
}
}
}
示例6: processElement
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
private void processElement(@NotNull final PsiNameIdentifierOwner element, @NotNull final String elementType) {
if (isConditional(element)) {
return;
}
final String name = element.getName();
final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
if (owner != null && name != null) {
final Instruction[] instructions = ControlFlowCache.getControlFlow(owner).getInstructions();
PsiElement elementInControlFlow = element;
if (element instanceof PyTargetExpression) {
final PyImportStatement importStatement = PsiTreeUtil.getParentOfType(element, PyImportStatement.class);
if (importStatement != null) {
elementInControlFlow = importStatement;
}
}
final int startInstruction = ControlFlowUtil.findInstructionNumberByElement(instructions, elementInControlFlow);
if (startInstruction < 0) {
return;
}
final Ref<PsiElement> readElementRef = Ref.create(null);
final Ref<PsiElement> writeElementRef = Ref.create(null);
ControlFlowUtil.iteratePrev(startInstruction, instructions, instruction -> {
if (instruction instanceof ReadWriteInstruction && instruction.num() != startInstruction) {
final ReadWriteInstruction rwInstruction = (ReadWriteInstruction) instruction;
if (name.equals(rwInstruction.getName())) {
final PsiElement originalElement = rwInstruction.getElement();
if (originalElement != null) {
if (rwInstruction.getAccess().isReadAccess()) {
readElementRef.set(originalElement);
}
if (rwInstruction.getAccess().isWriteAccess()) {
if (originalElement != element) {
writeElementRef.set(originalElement);
}
}
}
return ControlFlowUtil.Operation.CONTINUE;
}
}
return ControlFlowUtil.Operation.NEXT;
});
final PsiElement writeElement = writeElementRef.get();
if (writeElement != null && readElementRef.get() == null) {
final List<LocalQuickFix> quickFixes = new ArrayList<LocalQuickFix>();
if (suggestRename(element, writeElement)) {
quickFixes.add(new PyRenameElementQuickFix());
}
final PsiElement identifier = element.getNameIdentifier();
registerProblem(identifier != null ? identifier : element,
String.format("Redeclared decorated %s ''%s'' defined above", elementType, name),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
null,
quickFixes.toArray(new LocalQuickFix[quickFixes.size()]));
}
}
}
示例7: RenameChangeInfo
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
public RenameChangeInfo(final PsiNameIdentifierOwner namedElement, final ChangeInfo oldInfo) {
myOldName = oldInfo instanceof RenameChangeInfo ? ((RenameChangeInfo)oldInfo).getOldName() : namedElement.getName();
myFile = namedElement.getContainingFile();
myOffset = namedElement.getTextOffset();
}
示例8: getNewName
import com.intellij.psi.PsiNameIdentifierOwner; //導入方法依賴的package包/類
@Override
public String getNewName() {
final PsiNameIdentifierOwner nameOwner = getNamedElement();
return nameOwner != null ? nameOwner.getName() : null;
}