use of com.goide.psi.GoCompositeElement in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoReferenceImporter method autoImportReferenceAtCursor.
@Override
public boolean autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile file) {
if (!file.getViewProvider().getLanguages().contains(GoLanguage.INSTANCE) || !DaemonListeners.canChangeFileSilently(file)) {
return false;
}
int caretOffset = editor.getCaretModel().getOffset();
Document document = editor.getDocument();
int lineNumber = document.getLineNumber(caretOffset);
int startOffset = document.getLineStartOffset(lineNumber);
int endOffset = document.getLineEndOffset(lineNumber);
List<PsiElement> elements = CollectHighlightsUtil.getElementsInRange(file, startOffset, endOffset);
for (PsiElement element : elements) {
if (element instanceof GoCompositeElement) {
for (PsiReference reference : element.getReferences()) {
GoImportPackageQuickFix fix = new GoImportPackageQuickFix(reference);
if (fix.doAutoImportOrShowHint(editor, false)) {
return true;
}
}
}
}
return false;
}
Aggregations