@Override @NotNull public String[] getNames(Project project, boolean includeNonProjectItems) { if (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping) { final THashSet<String> names = new THashSet<String>(1000); IdFilter filter = IdFilter.getProjectIdFilter(project, includeNonProjectItems); processNames(new Processor<String>() { @Override public boolean process(String s) { names.add(s); return true; } }, FindSymbolParameters.searchScopeFor(project, includeNonProjectItems), filter); if (IdFilter.LOG.isDebugEnabled()) { IdFilter.LOG.debug("All names retrieved2:" + names.size()); } return ArrayUtil.toStringArray(names); } else { return FilenameIndex.getAllFilenames(project); } }
public boolean hasStubElementsOfType(final DomFileElement domFileElement, final Class<? extends DomElement> clazz) { final VirtualFile file = domFileElement.getFile().getVirtualFile(); if (!(file instanceof VirtualFileWithId)) return false; final String clazzName = clazz.getName(); final int virtualFileId = ((VirtualFileWithId)file).getId(); CommonProcessors.FindFirstProcessor<? super PsiFile> processor = new CommonProcessors.FindFirstProcessor<PsiFile>(); StubIndex.getInstance().processElements(KEY, clazzName, domFileElement.getFile().getProject(), GlobalSearchScope.fileScope(domFileElement.getFile()), new IdFilter() { @Override public boolean containsFileId(int id) { return id == virtualFileId; } }, PsiFile.class, processor ); return processor.isFound(); }
public boolean hasStubElementsWithNamespaceKey(final DomFileElement domFileElement, final String namespaceKey) { final VirtualFile file = domFileElement.getFile().getVirtualFile(); if (!(file instanceof VirtualFileWithId)) return false; final int virtualFileId = ((VirtualFileWithId)file).getId(); CommonProcessors.FindFirstProcessor<PsiFile> processor = new CommonProcessors.FindFirstProcessor<PsiFile>(); StubIndex.getInstance().processElements( KEY, namespaceKey, domFileElement.getFile().getProject(), GlobalSearchScope.fileScope(domFileElement.getFile()), new IdFilter() { @Override public boolean containsFileId(int id) { return id == virtualFileId; } }, PsiFile.class, processor ); return processor.isFound(); }
ByItem(final Converter converter, final Map<String,Set<String>> globalFields, final Map<String,Set<String>> globalMethods, final List<TypeNameItemNamePair> pairFields, final List<TypeNameItemNamePair> pairMethods, final List<Item> locals, final GlobalSearchScope scope, final IdFilter filter) { this.converter = converter; final ByItemMaps maps = JavaItems.valuesByItem(locals, true); // locals byItem map contains an entry for ObjectItem this.localValues = maps.values; this.localMethods = maps.methods; this.globalFields = globalFields; this.globalMethods = globalMethods; this.pairFields = pairFields; this.pairMethods = pairMethods; this.psiCache = PsiShortNamesCache.getInstance(converter.project); this.scope = scope; this.filter = filter; }
@NotNull @Override @RequiredReadAction public PsiClass[] getClassesByName(@NotNull @NonNls String s, @NotNull GlobalSearchScope globalSearchScope) { CommonProcessors.CollectProcessor<DotNetTypeDeclaration> collectProcessor = new CommonProcessors.CollectProcessor<DotNetTypeDeclaration>(); DotNetShortNameSearcher.getInstance(myProject).collectTypes(s, globalSearchScope, IdFilter.getProjectIdFilter(myProject, false), collectProcessor); Collection<DotNetTypeDeclaration> results = collectProcessor.getResults(); List<PsiClass> classes = new ArrayList<PsiClass>(results.size()); for(DotNetTypeDeclaration dotNetTypeDeclaration : results) { JavaClassStubBuilder javaClassStubBuilder = StubBuilder.build(dotNetTypeDeclaration); if(javaClassStubBuilder == null) { continue; } classes.add(javaClassStubBuilder.buildToPsi(null)); } return ContainerUtil.toArray(classes, PsiClass.ARRAY_FACTORY); }
@Override public void processElementsWithName( @NotNull String name, @NotNull Processor<NavigationItem> navigationItemProcessor, @NotNull FindSymbolParameters findSymbolParameters) { Project project = findSymbolParameters.getProject(); IdFilter idFilter = findSymbolParameters.getIdFilter(); GlobalSearchScope searchScope = findSymbolParameters.getSearchScope(); StubIndex.getInstance().processElements(CSharpIndexKeys.METHOD_INDEX, name, project, searchScope, idFilter, DotNetLikeMethodDeclaration.class, (Processor) navigationItemProcessor); StubIndex.getInstance().processElements(CSharpIndexKeys.EVENT_INDEX, name, project, searchScope, idFilter, DotNetEventDeclaration.class, (Processor) navigationItemProcessor); StubIndex.getInstance().processElements(CSharpIndexKeys.PROPERTY_INDEX, name, project, searchScope, idFilter, DotNetPropertyDeclaration.class, (Processor) navigationItemProcessor); StubIndex.getInstance().processElements(CSharpIndexKeys.FIELD_INDEX, name, project, searchScope, idFilter, DotNetFieldDeclaration.class, (Processor) navigationItemProcessor); }
@Override @Nonnull public String[] getNames(Project project, boolean includeNonProjectItems) { if (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping) { final THashSet<String> names = new THashSet<String>(1000); IdFilter filter = IdFilter.getProjectIdFilter(project, includeNonProjectItems); processNames(new Processor<String>() { @Override public boolean process(String s) { names.add(s); return true; } }, FindSymbolParameters.searchScopeFor(project, includeNonProjectItems), filter); if (LOGGER.isDebugEnabled()) { LOGGER.debug("All names retrieved2:" + names.size()); } return ArrayUtil.toStringArray(names); } else { return FilenameIndex.getAllFilenames(project); } }
public boolean hasStubElementsOfType(final DomFileElement domFileElement, final Class<? extends DomElement> clazz) { final VirtualFile file = domFileElement.getFile().getVirtualFile(); if(!(file instanceof VirtualFileWithId)) { return false; } final String clazzName = clazz.getName(); final int virtualFileId = ((VirtualFileWithId) file).getId(); CommonProcessors.FindFirstProcessor<? super PsiFile> processor = new CommonProcessors.FindFirstProcessor<PsiFile>(); StubIndex.getInstance().process(KEY, clazzName, domFileElement.getFile().getProject(), GlobalSearchScope.fileScope(domFileElement.getFile()) , new IdFilter() { @Override public boolean containsFileId(int id) { return id == virtualFileId; } }, processor); return processor.isFound(); }
public boolean hasStubElementsWithNamespaceKey(final DomFileElement domFileElement, final String namespaceKey) { final VirtualFile file = domFileElement.getFile().getVirtualFile(); if(!(file instanceof VirtualFileWithId)) { return false; } final int virtualFileId = ((VirtualFileWithId) file).getId(); CommonProcessors.FindFirstProcessor<PsiFile> processor = new CommonProcessors.FindFirstProcessor<PsiFile>(); StubIndex.getInstance().process(KEY, namespaceKey, domFileElement.getFile().getProject(), GlobalSearchScope.fileScope(domFileElement.getFile ()), new IdFilter() { @Override public boolean containsFileId(int id) { return id == virtualFileId; } }, processor); return processor.isFound(); }
@Override public boolean processFieldsWithName(@NotNull String name, @NotNull Processor<? super PsiField> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return StubIndex.getInstance().processElements(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), new JavaSourceFilterScope(scope), filter, PsiField.class, processor); }
@Override public boolean processMethodsWithName(@NonNls @NotNull String name, @NotNull Processor<? super PsiMethod> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS, name, myManager.getProject(), new JavaSourceFilterScope(scope), filter, PsiMethod.class, processor); }
@Override public boolean processClassesWithName(@NotNull String name, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return StubIndex.getInstance().processElements(JavaStubIndexKeys.CLASS_SHORT_NAMES, name, myManager.getProject(), new JavaSourceFilterScope(scope), filter, PsiClass.class, processor); }
public static Project processClassNames(final Project project, final GlobalSearchScope scope, final Consumer<String> consumer) { final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator(); MethodUsagesSearcher.resolveInReadAction(project, new Computable<Void>() { @Override public Void compute() { PsiShortNamesCache.getInstance(project).processAllClassNames(new Processor<String>() { int i = 0; @Override public boolean process(String s) { if (indicator != null && i++ % 512 == 0) { indicator.checkCanceled(); } consumer.consume(s); return true; } }, scope, IdFilter.getProjectIdFilter(project, true)); return null; } }); if (indicator != null) { indicator.checkCanceled(); } return project; }
@Override public boolean processAllClassNames(Processor<String> processor, GlobalSearchScope scope, IdFilter filter) { for (PsiShortNamesCache cache : myCaches) { if (!cache.processAllClassNames(processor, scope, filter)) { return false; } } return true; }
@Override public boolean processAllMethodNames(Processor<String> processor, GlobalSearchScope scope, IdFilter filter) { for (PsiShortNamesCache cache : myCaches) { if (!cache.processAllMethodNames(processor, scope, filter)) { return false; } } return true; }
@Override public boolean processAllFieldNames(Processor<String> processor, GlobalSearchScope scope, IdFilter filter) { for (PsiShortNamesCache cache : myCaches) { if (!cache.processAllFieldNames(processor, scope, filter)) { return false; } } return true; }
@Override public boolean processMethodsWithName(@NonNls @NotNull String name, @NotNull Processor<? super PsiMethod> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter idFilter) { for (PsiShortNamesCache cache : myCaches) { if (!cache.processMethodsWithName(name, processor, scope, idFilter)) return false; } return true; }
@Override public boolean processFieldsWithName(@NotNull String key, @NotNull Processor<? super PsiField> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { for (PsiShortNamesCache cache : myCaches) { if (!cache.processFieldsWithName(key, processor, scope, filter)) return false; } return true; }
@Override public boolean processClassesWithName(@NotNull String key, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { for (PsiShortNamesCache cache : myCaches) { if (!cache.processClassesWithName(key, processor, scope, filter)) return false; } return true; }
public boolean processMethodsWithName(@NonNls @NotNull String name, @NotNull final Processor<? super PsiMethod> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return processMethodsWithName(name, scope, new Processor<PsiMethod>() { @Override public boolean process(PsiMethod method) { return processor.process(method); } }); }
@Override @NotNull public String[] getNames(Project project, boolean includeNonProjectItems) { if (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping) { GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>(); processNames(processor, scope, IdFilter.getProjectIdFilter(project, includeNonProjectItems)); return ArrayUtil.toStringArray(processor.getResults()); } return PsiShortNamesCache.getInstance(project).getAllClassNames(); }
/** * @deprecated use {@link #getElements(StubIndexKey, Object, com.intellij.openapi.project.Project, com.intellij.psi.search.GlobalSearchScope, Class)} */ public <Key, Psi extends PsiElement> Collection<Psi> get(@NotNull StubIndexKey<Key, Psi> indexKey, @NotNull Key key, @NotNull Project project, @Nullable final GlobalSearchScope scope, IdFilter filter) { return get(indexKey, key, project, scope); }
/** * @deprecated use processElements */ public <Key, Psi extends PsiElement> boolean process(@NotNull StubIndexKey<Key, Psi> indexKey, @NotNull Key key, @NotNull Project project, @Nullable GlobalSearchScope scope, @SuppressWarnings("UnusedParameters") IdFilter idFilter, @NotNull Processor<? super Psi> processor) { return process(indexKey, key, project, scope, processor); }
public <Key, Psi extends PsiElement> boolean processElements(@NotNull StubIndexKey<Key, Psi> indexKey, @NotNull Key key, @NotNull Project project, @Nullable GlobalSearchScope scope, IdFilter idFilter, @NotNull Class<Psi> requiredClass, @NotNull Processor<? super Psi> processor) { return process(indexKey, key, project, scope, processor); }
public static <Key, Psi extends PsiElement> Collection<Psi> getElements(@NotNull StubIndexKey<Key, Psi> indexKey, @NotNull Key key, @NotNull final Project project, @Nullable final GlobalSearchScope scope, @Nullable IdFilter idFilter, @NotNull Class<Psi> requiredClass) { final List<Psi> result = new SmartList<Psi>(); getInstance().processElements(indexKey, key, project, scope, idFilter, requiredClass, new CommonProcessors.CollectProcessor<Psi>(result)); return result; }
IdFilter getIdFilter(boolean withLibraries) { IdFilter idFilter = myIdFilter; if (idFilter == null || myIdFilterForLibraries != withLibraries) { idFilter = IdFilter.getProjectIdFilter(myProject, withLibraries); myIdFilter = idFilter; myIdFilterForLibraries = withLibraries; } return idFilter; }
@Override public void processNames(@NotNull final Processor<String> processor, @NotNull GlobalSearchScope scope, IdFilter filter) { long started = System.currentTimeMillis(); FileBasedIndex.getInstance().processAllKeys(FilenameIndex.NAME, new Processor<String>() { @Override public boolean process(String s) { return processor.process(s); } }, scope, filter); if (IdFilter.LOG.isDebugEnabled()) { IdFilter.LOG.debug("All names retrieved:" + (System.currentTimeMillis() - started)); } }
@Override public boolean processMethodsWithName(@NonNls @NotNull String name, @NotNull Processor<? super PsiMethod> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { GrSourceFilterScope filterScope = new GrSourceFilterScope(scope); return StubIndex.getInstance().processElements(GrMethodNameIndex.KEY, name, myProject, filterScope, filter, GrMethod.class, processor) && StubIndex.getInstance().processElements(GrAnnotationMethodNameIndex.KEY, name, myProject, filterScope, filter, GrAnnotationMethod.class, processor); }
@Override public boolean processFieldsWithName(@NotNull String name, @NotNull Processor<? super PsiField> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { return StubIndex.getInstance().processElements(GrFieldNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter, GrField.class, processor); }
@Override public boolean processClassesWithName(@NotNull String name, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { for (GroovyFile file : StubIndex.getElements(GrScriptClassNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter, GroovyFile.class)) { PsiClass aClass = file.getScriptClass(); if (aClass != null && !processor.process(aClass)) return true; } return true; }
ItemGenerator(Project project, GlobalSearchScope scope, Converter conv, PackageIndex packageIndex) { this.project = project; this.scope = scope; filter = IdFilter.getProjectIdFilter(project, true); this.psiCache = PsiShortNamesCache.getInstance(project); psiManager = PsiManager.getInstance(project); converter = conv; this.packageIndex = packageIndex; }
public JavaEnvironment(@NotNull Project project, @NotNull ChangeTracker<String> nameTracker, @NotNull ChangeTracker<TypeNameItemNamePair> fieldTracker, @NotNull ChangeTracker<TypeNameItemNamePair> methodTracker) { this.project = project; this.nameTracker = nameTracker; this.fieldTracker = fieldTracker; this.methodTracker = methodTracker; final boolean extremelySlow = false; // TODO: Would be really nice if searching everything wasn't extremely slow byItemScope = extremelySlow ? ProjectScope.getAllScope(project) : ProjectScope.getProjectScope(project); byItemFilter = IdFilter.getProjectIdFilter(project, true); }
@NotNull @Override public String[] getNames(Project project, boolean includeNonProjectItems) { CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>(ContainerUtil.<String>newTroveSet()); processNames(processor, GlobalSearchScope.allScope(project), IdFilter.getProjectIdFilter(project, includeNonProjectItems)); return processor.toArray(ArrayUtil.STRING_ARRAY_FACTORY); }
@NotNull @Override public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { CommonProcessors.CollectProcessor<NavigationItem> processor = new CommonProcessors.CollectProcessor<NavigationItem>(ContainerUtil.<NavigationItem>newTroveSet()); processElementsWithName(name, processor, new FindSymbolParameters(pattern, name, GlobalSearchScope.allScope(project), IdFilter.getProjectIdFilter(project, includeNonProjectItems))); return processor.toArray(NavigationItem.ARRAY_FACTORY); }
@Override public void processNames(@NotNull final Processor<String> processor, @NotNull GlobalSearchScope scope, IdFilter filter) { projectsManager = MavenProjectsManager.getInstance(project); List<MavenProject> mavenProjects = projectsManager.getRootProjects(); if (mavenProjects.size() > 0) { addProjectNames(processor, mavenProjects.get(0)); if (scope.isSearchInLibraries()) { for (MavenId mavenId : getNotImportPoms(mavenProjects.get(0)).keySet()) { processor.process(mavenId.getKey()); } } } }
@NotNull @Override public String[] getNames(Project project, boolean includeNonProjectItems) { CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>(); GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); processNames(processor, scope, IdFilter.getProjectIdFilter(project, includeNonProjectItems)); return ArrayUtil.toStringArray(processor.getResults()); }
@Override public boolean processMethodsWithName(@NonNls @NotNull String s, @NotNull Processor<? super PsiMethod> processor, @NotNull GlobalSearchScope globalSearchScope, @Nullable IdFilter idFilter) { return false; }
@Override public boolean processFieldsWithName(@NotNull String s, @NotNull Processor<? super PsiField> processor, @NotNull GlobalSearchScope globalSearchScope, @Nullable IdFilter idFilter) { return false; }
@Override public boolean processClassesWithName(@NotNull String s, @NotNull Processor<? super PsiClass> processor, @NotNull GlobalSearchScope globalSearchScope, @Nullable IdFilter idFilter) { return false; }
@Override public void collectTypes(@NotNull String s, @NotNull GlobalSearchScope searchScope, @Nullable IdFilter filter, @NotNull final Processor<DotNetTypeDeclaration> processor) { StubIndex.getInstance().processElements(CSharpIndexKeys.TYPE_INDEX, s, myProject, searchScope, filter, CSharpTypeDeclaration.class, processor); StubIndex.getInstance().processElements(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, s, myProject, searchScope, filter, CSharpMethodDeclaration.class, methodDeclaration -> { ProgressManager.checkCanceled(); CSharpTypeDeclaration typeFromDelegate = CSharpLambdaResolveResultUtil.createTypeFromDelegate(methodDeclaration, DotNetGenericExtractor.EMPTY); return processor.process(typeFromDelegate); }); }