use of com.intellij.psi.PsiNameIdentifierOwner in project intellij-community by JetBrains.
the class PyRenameElementQuickFix method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement element = descriptor.getPsiElement();
if (element instanceof PyReferenceExpression) {
final PsiReference reference = element.getReference();
if (reference == null)
return;
element = reference.resolve();
}
final PsiNameIdentifierOwner nameOwner = element instanceof PsiNameIdentifierOwner ? (PsiNameIdentifierOwner) element : PsiTreeUtil.getParentOfType(element, PsiNameIdentifierOwner.class, true);
if (nameOwner != null) {
final VirtualFile virtualFile = nameOwner.getContainingFile().getVirtualFile();
if (virtualFile != null) {
final Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile), true);
if (ApplicationManager.getApplication().isUnitTestMode()) {
renameInUnitTestMode(project, nameOwner, editor);
} else {
if (checkLocalScope(element) != null && (nameOwner instanceof PyNamedParameter || nameOwner instanceof PyTargetExpression)) {
new VariableInplaceRenamer(nameOwner, editor).performInplaceRename();
} else {
PsiElementRenameHandler.invoke(nameOwner, project, ScopeUtil.getScopeOwner(nameOwner), editor);
}
}
}
}
}
Aggregations