Search in sources :

Example 1 with JSQualifiedNameImpl

use of com.intellij.lang.javascript.psi.JSQualifiedNameImpl in project intellij-plugins by JetBrains.

the class AngularIndexUtil method multiResolveAngularNamedDefinitionIndex.

public static ResolveResult[] multiResolveAngularNamedDefinitionIndex(@NotNull final Project project, @NotNull final ID<String, AngularNamedItemDefinition> INDEX, @NotNull final String id, @NotNull final Condition<VirtualFile> filter, boolean dirtyResolve) {
    final FileBasedIndex instance = FileBasedIndex.getInstance();
    Collection<VirtualFile> files = instance.getContainingFiles(INDEX, id, GlobalSearchScope.allScope(project));
    if (files.isEmpty())
        return ResolveResult.EMPTY_ARRAY;
    final List<VirtualFile> filtered = ContainerUtil.filter(files, filter);
    if (filtered.isEmpty()) {
        if (!dirtyResolve)
            return ResolveResult.EMPTY_ARRAY;
    } else {
        files = filtered;
    }
    final List<JSImplicitElement> elements = new ArrayList<>();
    for (VirtualFile file : files) {
        final List<AngularNamedItemDefinition> values = instance.getValues(INDEX, id, GlobalSearchScope.fileScope(project, file));
        for (AngularNamedItemDefinition value : values) {
            JSQualifiedNameImpl qName = JSQualifiedNameImpl.fromQualifiedName(id);
            JSImplicitElementImpl.Builder elementBuilder = new JSImplicitElementImpl.Builder(qName, null);
            final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
            if (psiFile != null) {
                elements.add(new JSOffsetBasedImplicitElement(elementBuilder, (int) value.getStartOffset(), psiFile));
            }
        }
    }
    final List<ResolveResult> list = ContainerUtil.map(elements, JS_IMPLICIT_TO_RESOLVE_RESULT);
    return list.toArray(new ResolveResult[list.size()]);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JSQualifiedNameImpl(com.intellij.lang.javascript.psi.JSQualifiedNameImpl) JSImplicitElementImpl(com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl) ArrayList(java.util.ArrayList) PsiFile(com.intellij.psi.PsiFile) JSOffsetBasedImplicitElement(com.intellij.lang.javascript.psi.impl.JSOffsetBasedImplicitElement) JSImplicitElement(com.intellij.lang.javascript.psi.stubs.JSImplicitElement) JSResolveResult(com.intellij.lang.javascript.psi.resolve.JSResolveResult) ResolveResult(com.intellij.psi.ResolveResult) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Aggregations

JSQualifiedNameImpl (com.intellij.lang.javascript.psi.JSQualifiedNameImpl)1 JSOffsetBasedImplicitElement (com.intellij.lang.javascript.psi.impl.JSOffsetBasedImplicitElement)1 JSResolveResult (com.intellij.lang.javascript.psi.resolve.JSResolveResult)1 JSImplicitElement (com.intellij.lang.javascript.psi.stubs.JSImplicitElement)1 JSImplicitElementImpl (com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 ResolveResult (com.intellij.psi.ResolveResult)1 FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)1 ArrayList (java.util.ArrayList)1