use of com.jetbrains.python.psi.PyQualifiedExpression in project intellij-community by JetBrains.
the class AutoImportQuickFix method showHint.
public boolean showHint(Editor editor) {
if (!PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP || HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true) || myImports.isEmpty()) {
return false;
}
final PsiElement element = getStartElement();
PyPsiUtils.assertValid(element);
if (element == null || !element.isValid()) {
return false;
}
final PyElement pyElement = as(element, PyElement.class);
if (pyElement == null || !myInitialName.equals(pyElement.getName())) {
return false;
}
final PsiReference reference = findOriginalReference(element);
if (reference == null || isResolved(reference)) {
return false;
}
if (element instanceof PyQualifiedExpression && ((PyQualifiedExpression) element).isQualified()) {
// we cannot be qualified
return false;
}
final String message = ShowAutoImportPass.getMessage(myImports.size() > 1, ImportCandidateHolder.getQualifiedName(myInitialName, myImports.get(0).getPath(), myImports.get(0).getImportElement()));
final ImportFromExistingAction action = new ImportFromExistingAction(element, myImports, myInitialName, myUseQualifiedImport, false);
action.onDone(() -> myExpended = true);
HintManager.getInstance().showQuestionHint(editor, message, element.getTextOffset(), element.getTextRange().getEndOffset(), action);
return true;
}
Aggregations