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;
}
Aggregations