use of com.intellij.lang.javascript.psi.JSNewExpression in project intellij-plugins by JetBrains.
the class AddImportECMAScriptClassOrFunctionAction method getCandidates.
private Collection<JSQualifiedNamedElement> getCandidates(Editor editor, PsiFile file) {
final Collection<JSQualifiedNamedElement> candidates;
if (myReference instanceof JSReferenceExpression && ((JSReferenceExpression) myReference).getQualifier() == null) {
Collection<JSQualifiedNamedElement> c = getCandidates(editor, file, myReference.getCanonicalText());
filterCandidates(c);
candidates = new THashSet<>(c, JSPsiImplUtils.QUALIFIED_NAME_HASHING_STRATEGY);
} else {
JSQualifiedNamedElement invalidResult = null;
for (ResolveResult r : myReference.multiResolve(false)) {
PsiElement element = r.getElement();
if (element instanceof JSQualifiedNamedElement) {
invalidResult = (JSQualifiedNamedElement) element;
}
}
if (invalidResult != null) {
if (myReference.getElement().getParent() instanceof JSNewExpression && invalidResult instanceof JSFunction && ((JSFunction) invalidResult).isConstructor()) {
invalidResult = (JSClass) invalidResult.getParent();
}
candidates = new SmartList<>();
candidates.add(invalidResult);
} else {
candidates = Collections.emptyList();
}
}
return candidates;
}
Aggregations