use of com.intellij.lang.javascript.ecmascript6.TypeScriptResolveProcessor in project intellij-plugins by JetBrains.
the class AngularJSReferenceExpressionResolver method resolve.
@NotNull
@Override
public ResolveResult[] resolve(@NotNull JSReferenceExpressionImpl expression, boolean incompleteCode) {
if (myReferencedName == null)
return ResolveResult.EMPTY_ARRAY;
if (myRef.getParent() instanceof JSDefinitionExpression) {
final PsiElement sibling = PsiTreeUtil.prevVisibleLeaf(myRef);
if (sibling != null && sibling.getNode().getElementType() == JSTokenTypes.LET_KEYWORD) {
return new JSResolveResult[] { new JSResolveResult(myRef) };
}
final AngularJSRepeatExpression repeat = PsiTreeUtil.getParentOfType(myRef, AngularJSRepeatExpression.class);
if (repeat != null) {
for (JSDefinitionExpression def : repeat.getDefinitions()) {
if (PsiTreeUtil.isAncestor(def, myRef, true))
return new JSResolveResult[] { new JSResolveResult(myRef) };
}
}
final AngularJSAsExpression as = PsiTreeUtil.getParentOfType(myRef, AngularJSAsExpression.class);
if (as != null) {
if (PsiTreeUtil.isAncestor(as.getDefinition(), myRef, true))
return new JSResolveResult[] { new JSResolveResult(myRef) };
}
JSClass clazz = myRef.getQualifier() == null ? AngularJS2IndexingHandler.findDirectiveClass(myRef) : null;
if (clazz != null && DialectDetector.isTypeScript(clazz)) {
final TypeScriptResolveProcessor localProcessor = new TypeScriptResolveProcessor(myReferencedName, myContainingFile, myRef, incompleteCode);
localProcessor.setToProcessHierarchy(true);
JSReferenceExpressionImpl.doProcessLocalDeclarations(clazz, myQualifier, localProcessor, false, false, null);
return localProcessor.getResultsAsResolveResults();
}
}
if (AngularJSAsExpression.isAsControllerRef(myRef, myRef.getParent())) {
final PsiElement resolve = AngularIndexUtil.resolve(myParent.getProject(), AngularControllerIndex.KEY, myReferencedName);
if (resolve != null) {
return new JSResolveResult[] { new JSResolveResult(resolve) };
}
} else if (AngularJSFilterExpression.isFilterNameRef(myRef, myParent)) {
final PsiElement resolve = AngularIndexUtil.resolve(myParent.getProject(), AngularFilterIndex.KEY, myReferencedName);
if (resolve != null) {
return new JSResolveResult[] { new JSResolveResult(resolve) };
}
} else if (myQualifier == null) {
final Collection<JSPsiElementBase> localVariables = getItemsByName(myReferencedName, myRef);
if (!localVariables.isEmpty()) {
return ContainerUtil.map2Array(localVariables, JSResolveResult.class, item -> new JSResolveResult(item));
}
}
return super.resolve(expression, incompleteCode);
}
Aggregations