Search in sources :

Example 1 with JSImplicitElementImpl

use of com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl in project intellij-plugins by JetBrains.

the class AngularJSIndexingHandler method addImplicitElements.

private static void addImplicitElements(@NotNull final JSImplicitElementProvider elementProvider, @Nullable final String command, @NotNull final StubIndexKey<String, JSImplicitElementProvider> index, @Nullable String defaultName, @Nullable final String value, @NotNull final JSElementIndexingData outData) {
    if (defaultName == null)
        return;
    final List<String> keys = INDEXES.getKeysByValue(index);
    assert keys != null && keys.size() == 1;
    final Consumer<JSImplicitElementImpl.Builder> adder = builder -> {
        builder.setType(elementProvider instanceof JSDocComment ? JSImplicitElement.Type.Tag : JSImplicitElement.Type.Class).setTypeString(value);
        builder.setUserString(keys.get(0));
        final JSImplicitElementImpl implicitElement = builder.toImplicitElement();
        outData.addImplicitElement(implicitElement);
    };
    final Function<String, List<String>> variants = POLY_NAME_CONVERTERS.get(command);
    final Function<String, String> converter = command != null ? NAME_CONVERTERS.get(command) : null;
    final String name = converter != null ? converter.fun(defaultName) : defaultName;
    if (variants != null) {
        final List<String> strings = variants.fun(name);
        for (String string : strings) {
            adder.consume(new JSImplicitElementImpl.Builder(string, elementProvider));
        }
    } else {
        adder.consume(new JSImplicitElementImpl.Builder(JSQualifiedNameImpl.fromQualifiedName(name), elementProvider));
    }
    if (!StringUtil.equals(defaultName, name)) {
        JSImplicitElementImpl.Builder symbolElementBuilder = new JSImplicitElementImpl.Builder(defaultName, elementProvider).setType(elementProvider instanceof JSDocComment ? JSImplicitElement.Type.Tag : JSImplicitElement.Type.Class).setTypeString(value);
        final List<String> symbolKeys = INDEXES.getKeysByValue(AngularSymbolIndex.KEY);
        assert symbolKeys != null && symbolKeys.size() == 1;
        symbolElementBuilder.setUserString(symbolKeys.get(0));
        final JSImplicitElementImpl implicitElement2 = symbolElementBuilder.toImplicitElement();
        outData.addImplicitElement(implicitElement2);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FrameworkIndexingHandler(com.intellij.lang.javascript.index.FrameworkIndexingHandler) THashSet(gnu.trove.THashSet) CompositeElement(com.intellij.psi.impl.source.tree.CompositeElement) JSCallExpressionImpl(com.intellij.lang.javascript.psi.impl.JSCallExpressionImpl) PsiTreeUtil(com.intellij.psi.util.PsiTreeUtil) JSImplicitElementImpl(com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl) AngularJSFilterExpression(org.angularjs.lang.psi.AngularJSFilterExpression) JSElementIndexingData(com.intellij.lang.javascript.psi.stubs.JSElementIndexingData) PsiNamedElement(com.intellij.psi.PsiNamedElement) BidirectionalMap(com.intellij.util.containers.BidirectionalMap) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) JSDocumentationUtils(com.intellij.lang.javascript.documentation.JSDocumentationUtils) JSDocTag(com.intellij.lang.javascript.psi.jsdoc.JSDocTag) JSSymbolUtil(com.intellij.lang.javascript.index.JSSymbolUtil) JSNamedType(com.intellij.lang.javascript.psi.types.JSNamedType) JSImplicitElement(com.intellij.lang.javascript.psi.stubs.JSImplicitElement) JSTreeUtil(com.intellij.lang.javascript.psi.util.JSTreeUtil) JSLibraryUtil(com.intellij.lang.javascript.library.JSLibraryUtil) JSDocComment(com.intellij.lang.javascript.psi.jsdoc.JSDocComment) Nullable(org.jetbrains.annotations.Nullable) JSDocTagValue(com.intellij.lang.javascript.psi.jsdoc.JSDocTagValue) StubIndexKey(com.intellij.psi.stubs.StubIndexKey) com.intellij.util(com.intellij.util) AngularJSAsExpression(org.angularjs.lang.psi.AngularJSAsExpression) NotNull(org.jetbrains.annotations.NotNull) JSLiteralImplicitElementProvider(com.intellij.lang.javascript.psi.literal.JSLiteralImplicitElementProvider) Ref(com.intellij.openapi.util.Ref) java.util(java.util) JSTypeEvaluator(com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator) JSDocTokenTypes(com.intellij.lang.javascript.JSDocTokenTypes) AngularJSLanguage(org.angularjs.lang.AngularJSLanguage) JSImplicitElementStructure(com.intellij.lang.javascript.psi.stubs.JSImplicitElementStructure) JSReferenceExpressionImpl(com.intellij.lang.javascript.psi.impl.JSReferenceExpressionImpl) DirectiveUtil(org.angularjs.codeInsight.DirectiveUtil) JSContext(com.intellij.lang.javascript.psi.types.JSContext) JSTypeSourceFactory(com.intellij.lang.javascript.psi.types.JSTypeSourceFactory) PsiElement(com.intellij.psi.PsiElement) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace) JSTypeSource(com.intellij.lang.javascript.psi.types.JSTypeSource) StringUtil(com.intellij.openapi.util.text.StringUtil) FileViewProvider(com.intellij.psi.FileViewProvider) com.intellij.lang.javascript.psi(com.intellij.lang.javascript.psi) JSPsiImplUtils(com.intellij.lang.javascript.psi.impl.JSPsiImplUtils) AngularJSRepeatExpression(org.angularjs.lang.psi.AngularJSRepeatExpression) ASTNode(com.intellij.lang.ASTNode) AngularJSUiRouterConstants(org.angularjs.codeInsight.router.AngularJSUiRouterConstants) Pair(com.intellij.openapi.util.Pair) JSElementIndexingDataImpl(com.intellij.lang.javascript.psi.stubs.impl.JSElementIndexingDataImpl) IndexSink(com.intellij.psi.stubs.IndexSink) JSDocComment(com.intellij.lang.javascript.psi.jsdoc.JSDocComment) JSImplicitElementImpl(com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl)

Example 2 with JSImplicitElementImpl

use of com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl in project intellij-plugins by JetBrains.

the class AngularJSIndexingHandler method generateNamespace.

private static void generateNamespace(@NotNull JSLiteralExpression argument, @NotNull JSElementIndexingData outData) {
    final String namespace = unquote(argument);
    if (namespace == null)
        return;
    JSQualifiedNameImpl qName = JSQualifiedNameImpl.fromQualifiedName(namespace);
    JSImplicitElementImpl.Builder elementBuilder = new JSImplicitElementImpl.Builder(qName, argument).setType(JSImplicitElement.Type.Class).setUserString(ANGULAR_SYMBOL_INDEX_USER_STRING);
    final JSImplicitElementImpl implicitElement = elementBuilder.toImplicitElement();
    outData.addImplicitElement(implicitElement);
// TODO fix
//final JSFunction function = findFunction(argument);
//final JSNamespace ns = visitor.findNsForExpr((JSExpression)argument);
//if (function != null && ns != null) {
//  visitor.visitWithNamespace(ns, function, false);
//}
}
Also used : JSImplicitElementImpl(com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl)

Aggregations

JSImplicitElementImpl (com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl)2 ASTNode (com.intellij.lang.ASTNode)1 JSDocTokenTypes (com.intellij.lang.javascript.JSDocTokenTypes)1 JSDocumentationUtils (com.intellij.lang.javascript.documentation.JSDocumentationUtils)1 FrameworkIndexingHandler (com.intellij.lang.javascript.index.FrameworkIndexingHandler)1 JSSymbolUtil (com.intellij.lang.javascript.index.JSSymbolUtil)1 JSLibraryUtil (com.intellij.lang.javascript.library.JSLibraryUtil)1 com.intellij.lang.javascript.psi (com.intellij.lang.javascript.psi)1 JSCallExpressionImpl (com.intellij.lang.javascript.psi.impl.JSCallExpressionImpl)1 JSPsiImplUtils (com.intellij.lang.javascript.psi.impl.JSPsiImplUtils)1 JSReferenceExpressionImpl (com.intellij.lang.javascript.psi.impl.JSReferenceExpressionImpl)1 JSDocComment (com.intellij.lang.javascript.psi.jsdoc.JSDocComment)1 JSDocTag (com.intellij.lang.javascript.psi.jsdoc.JSDocTag)1 JSDocTagValue (com.intellij.lang.javascript.psi.jsdoc.JSDocTagValue)1 JSLiteralImplicitElementProvider (com.intellij.lang.javascript.psi.literal.JSLiteralImplicitElementProvider)1 JSTypeEvaluator (com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator)1 JSElementIndexingData (com.intellij.lang.javascript.psi.stubs.JSElementIndexingData)1 JSImplicitElement (com.intellij.lang.javascript.psi.stubs.JSImplicitElement)1 JSImplicitElementStructure (com.intellij.lang.javascript.psi.stubs.JSImplicitElementStructure)1 JSElementIndexingDataImpl (com.intellij.lang.javascript.psi.stubs.impl.JSElementIndexingDataImpl)1