mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
TargetElementUtil: only retrieve lookup when asked to (EA-35476,EA-38080)
This commit is contained in:
@@ -156,12 +156,10 @@ public class TargetElementUtilBase {
|
||||
Project project = editor.getProject();
|
||||
if (project == null) return null;
|
||||
|
||||
Lookup activeLookup = LookupManager.getInstance(project).getActiveLookup();
|
||||
if (activeLookup != null && (flags & LOOKUP_ITEM_ACCEPTED) != 0) {
|
||||
LookupElement item = activeLookup.getCurrentItem();
|
||||
final PsiElement psi = item == null ? null : CompletionUtil.getTargetElement(item);
|
||||
if (psi != null && psi.isValid()) {
|
||||
return psi;
|
||||
if ((flags & LOOKUP_ITEM_ACCEPTED) != 0) {
|
||||
PsiElement element = getTargetElementFromLookup(project);
|
||||
if (element != null) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +195,19 @@ public class TargetElementUtilBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement getTargetElementFromLookup(Project project) {
|
||||
Lookup activeLookup = LookupManager.getInstance(project).getActiveLookup();
|
||||
if (activeLookup != null) {
|
||||
LookupElement item = activeLookup.getCurrentItem();
|
||||
final PsiElement psi = item == null ? null : CompletionUtil.getTargetElement(item);
|
||||
if (psi != null && psi.isValid()) {
|
||||
return psi;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean isAcceptableReferencedElement(final PsiElement element, final PsiElement referenceOrReferencedElement) {
|
||||
return referenceOrReferencedElement != null &&
|
||||
referenceOrReferencedElement.isValid();
|
||||
|
||||
Reference in New Issue
Block a user