Search in sources :

Example 1 with AngularJSLanguage

use of org.angularjs.lang.AngularJSLanguage in project intellij-plugins by JetBrains.

the class AngularJSIndexingHandler method addTypeFromResolveResult.

@Override
public boolean addTypeFromResolveResult(JSTypeEvaluator evaluator, PsiElement resolveResult, boolean hasSomeType) {
    if (!AngularIndexUtil.hasAngularJS(resolveResult.getProject()))
        return false;
    if (resolveResult instanceof JSDefinitionExpression && resolveResult.getLanguage() instanceof AngularJSLanguage) {
        final PsiElement resolveParent = resolveResult.getParent();
        if (resolveParent instanceof AngularJSAsExpression) {
            final String name = resolveParent.getFirstChild().getText();
            final JSTypeSource source = JSTypeSourceFactory.createTypeSource(resolveResult);
            final JSType type = JSNamedType.createType(name, source, JSContext.INSTANCE);
            evaluator.addType(type, resolveResult);
            return true;
        }
    }
    if (resolveResult instanceof JSVariable && resolveResult.getLanguage() instanceof AngularJSLanguage) {
        PsiElement resolveParent = resolveResult.getParent().getParent();
        if (resolveParent instanceof AngularJSRepeatExpression) {
            if (calculateRepeatParameterType(evaluator, (AngularJSRepeatExpression) resolveParent)) {
                return true;
            }
        }
    }
    if (resolveResult instanceof JSParameter && evaluator.isFromCurrentFile(resolveResult) && isInjectable(resolveResult)) {
        final String name = ((JSParameter) resolveResult).getName();
        final JSTypeSource source = JSTypeSourceFactory.createTypeSource(resolveResult);
        final JSType type = JSNamedType.createType(name, source, JSContext.UNKNOWN);
        evaluator.addType(type, resolveResult);
    }
    return false;
}
Also used : JSTypeSource(com.intellij.lang.javascript.psi.types.JSTypeSource) AngularJSRepeatExpression(org.angularjs.lang.psi.AngularJSRepeatExpression) AngularJSLanguage(org.angularjs.lang.AngularJSLanguage) PsiElement(com.intellij.psi.PsiElement) AngularJSAsExpression(org.angularjs.lang.psi.AngularJSAsExpression)

Aggregations

JSTypeSource (com.intellij.lang.javascript.psi.types.JSTypeSource)1 PsiElement (com.intellij.psi.PsiElement)1 AngularJSLanguage (org.angularjs.lang.AngularJSLanguage)1 AngularJSAsExpression (org.angularjs.lang.psi.AngularJSAsExpression)1 AngularJSRepeatExpression (org.angularjs.lang.psi.AngularJSRepeatExpression)1