Search in sources :

Example 1 with MacroCollector

use of ool.intellij.plugin.file.index.collector.MacroCollector in project oxy-template-support-plugin by mutant-industries.

the class OxyTemplateIndexUtil method getJsSymbols.

@NotNull
public static HashMultimap<String, JSElement> getJsSymbols(@NotNull Project project, boolean macros, boolean namespaces, @Nullable Collection<VirtualFile> restrictFiles) {
    final GlobalSearchScope allScope = ProjectScope.getProjectScope(project);
    FileBasedIndex index = FileBasedIndex.getInstance();
    HashMultimap<String, JSElement> result = HashMultimap.create();
    for (String key : index.getAllKeys(JsMacroNameIndex.INDEX_ID, project)) {
        MacroCollector<JSElement, JsMacroNameIndexedElement> collector = new JsMacroCollector(project);
        Collection<VirtualFile> virtualFiles = restrictFiles != null ? restrictFiles : index.getContainingFiles(JsMacroNameIndex.INDEX_ID, key, allScope);
        index.getValues(JsMacroNameIndex.INDEX_ID, key, allScope).stream().filter(macroName -> macroName.isMacro() && macros || !macroName.isMacro() && namespaces).forEach(macroName -> virtualFiles.forEach(file -> index.processValues(JsMacroNameIndex.INDEX_ID, key, file, collector, allScope)));
        collector.getResult().stream().forEach(element -> result.put(key, element));
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JsMacroNameIndex(ool.intellij.plugin.file.index.nacro.js.JsMacroNameIndex) StringUtils(org.apache.commons.lang.StringUtils) VirtualFile(com.intellij.openapi.vfs.VirtualFile) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PsiModifier(com.intellij.psi.PsiModifier) CachedValueProvider(com.intellij.psi.util.CachedValueProvider) PsiClass(com.intellij.psi.PsiClass) HashMultimap(com.google.common.collect.HashMultimap) JsMacroCollector(ool.intellij.plugin.file.index.collector.JsMacroCollector) Map(java.util.Map) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) JsMacroNameIndexedElement(ool.intellij.plugin.file.index.nacro.js.JsMacroNameIndexedElement) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) MacroIndex(ool.intellij.plugin.file.index.nacro.MacroIndex) JSElement(com.intellij.lang.javascript.psi.JSElement) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) Key(com.intellij.openapi.util.Key) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) CachedValuesManager(com.intellij.psi.util.CachedValuesManager) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) JSProperty(com.intellij.lang.javascript.psi.JSProperty) CachedValue(com.intellij.psi.util.CachedValue) MacroCollector(ool.intellij.plugin.file.index.collector.MacroCollector) ClassInheritorsSearch(com.intellij.psi.search.searches.ClassInheritorsSearch) ProjectScope(com.intellij.psi.search.ProjectScope) NotNull(org.jetbrains.annotations.NotNull) JsMacroNameIndexedElement(ool.intellij.plugin.file.index.nacro.js.JsMacroNameIndexedElement) JsMacroCollector(ool.intellij.plugin.file.index.collector.JsMacroCollector) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JSElement(com.intellij.lang.javascript.psi.JSElement) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HashMultimap (com.google.common.collect.HashMultimap)1 JSElement (com.intellij.lang.javascript.psi.JSElement)1 JSProperty (com.intellij.lang.javascript.psi.JSProperty)1 Project (com.intellij.openapi.project.Project)1 Key (com.intellij.openapi.util.Key)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 PsiModifier (com.intellij.psi.PsiModifier)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 ProjectScope (com.intellij.psi.search.ProjectScope)1 ClassInheritorsSearch (com.intellij.psi.search.searches.ClassInheritorsSearch)1 CachedValue (com.intellij.psi.util.CachedValue)1 CachedValueProvider (com.intellij.psi.util.CachedValueProvider)1 CachedValuesManager (com.intellij.psi.util.CachedValuesManager)1 FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1