Search in sources :

Example 1 with JSClassStub

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

the class FlexStyleIndex method getIndexer.

@NotNull
@Override
public DataIndexer<String, Set<FlexStyleIndexInfo>, FileContent> getIndexer() {
    return new DataIndexer<String, Set<FlexStyleIndexInfo>, FileContent>() {

        @Override
        @NotNull
        public Map<String, Set<FlexStyleIndexInfo>> map(@NotNull FileContent inputData) {
            final THashMap<String, Set<FlexStyleIndexInfo>> map = new THashMap<>();
            if (JavaScriptSupportLoader.isFlexMxmFile(inputData.getFileName())) {
                PsiFile file = inputData.getPsiFile();
                VirtualFile virtualFile = inputData.getFile();
                if (file instanceof XmlFile) {
                    indexMxmlFile((XmlFile) file, virtualFile, map);
                }
            } else {
                StubTree tree = JSPackageIndex.getStubTree(inputData);
                if (tree != null) {
                    for (StubElement e : tree.getPlainList()) {
                        if (e instanceof JSClassStub) {
                            final PsiElement psiElement = e.getPsi();
                            if (psiElement instanceof JSClass) {
                                final String qName = ((JSClass) psiElement).getQualifiedName();
                                indexAttributes(psiElement, qName, true, map);
                            }
                        } else if (e instanceof PsiFileStub) {
                            PsiElement psiElement = e.getPsi();
                            if (psiElement instanceof JSFile) {
                                String name = ((JSFile) psiElement).getName();
                                indexAttributes(psiElement, name, false, map);
                            }
                        }
                    }
                }
            }
            return map;
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Set(java.util.Set) XmlFile(com.intellij.psi.xml.XmlFile) StubTree(com.intellij.psi.stubs.StubTree) StubElement(com.intellij.psi.stubs.StubElement) NotNull(org.jetbrains.annotations.NotNull) THashMap(gnu.trove.THashMap) JSClassStub(com.intellij.lang.javascript.psi.stubs.JSClassStub) PsiFileStub(com.intellij.psi.stubs.PsiFileStub) PsiFile(com.intellij.psi.PsiFile) JSFile(com.intellij.lang.javascript.psi.JSFile) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JSFile (com.intellij.lang.javascript.psi.JSFile)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSClassStub (com.intellij.lang.javascript.psi.stubs.JSClassStub)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 PsiFileStub (com.intellij.psi.stubs.PsiFileStub)1 StubElement (com.intellij.psi.stubs.StubElement)1 StubTree (com.intellij.psi.stubs.StubTree)1 XmlFile (com.intellij.psi.xml.XmlFile)1 THashMap (gnu.trove.THashMap)1 Set (java.util.Set)1 NotNull (org.jetbrains.annotations.NotNull)1