Java Code Examples for com.intellij.psi.search.GlobalSearchScope#projectScope()
The following examples show how to use
com.intellij.psi.search.GlobalSearchScope#projectScope() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaskellReference.java From intellij-haskforce with Apache License 2.0 | 6 votes |
private @NotNull List<PsiElementResolveResult> handleImportReferences(@NotNull HaskellImpdecl haskellImpdecl, @NotNull PsiNamedElement myElement, int i) { /** * Don't use the named element yet to determine which element we're * talking about, not necessary yet */ List<PsiElementResolveResult> modulesFound = new ArrayList<PsiElementResolveResult>(); List<HaskellQconid> qconidList = haskellImpdecl.getQconidList(); if (qconidList.size() > 0){ String moduleName = qconidList.get(0).getText(); GlobalSearchScope globalSearchScope = GlobalSearchScope.projectScope(myElement.getProject()); List<HaskellFile> filesByModuleName = HaskellModuleIndex.getFilesByModuleName(myElement.getProject(), moduleName, globalSearchScope); for (HaskellFile haskellFile : filesByModuleName) { HaskellModuledecl[] moduleDecls = PsiTreeUtil.getChildrenOfType(haskellFile, HaskellModuledecl.class); if (moduleDecls != null && moduleDecls.length > 0){ HaskellQconid qconid = moduleDecls[0].getQconid(); if (qconid != null) { List<HaskellConid> conidList = moduleDecls[0].getQconid().getConidList(); modulesFound.add(new PsiElementResolveResult(conidList.get(i))); } } } } return modulesFound; }
Example 2
Source File: SqlsXmlUtil.java From NutzCodeInsight with Apache License 2.0 | 5 votes |
public static GlobalSearchScope getSearchScope(Project project, @NotNull PsiElement element) { GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project); Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(element.getContainingFile().getVirtualFile()); if (module != null) { searchScope = GlobalSearchScope.moduleScope(module); } return searchScope; }
Example 3
Source File: FilesIndexCacheProjectComponent.java From idea-gitignore with MIT License | 5 votes |
/** * Finds {@link VirtualFile} instances for the specific {@link Pattern} and caches them. * * @param project current project * @param pattern to handle * @return matched files list */ @NotNull public Collection<VirtualFile> getFilesForPattern(@NotNull final Project project, @NotNull Pattern pattern) { final GlobalSearchScope scope = GlobalSearchScope.projectScope(project); final String[] parts = MatcherUtil.getParts(pattern); if (parts.length > 0) { final String key = StringUtil.join(parts, Constants.DOLLAR); if (cacheMap.get(key) == null) { final THashSet<VirtualFile> files = new THashSet<>(1000); projectFileIndex.iterateContent(fileOrDir -> { final String name = fileOrDir.getName(); if (MatcherUtil.matchAnyPart(parts, name)) { for (VirtualFile file : FilenameIndex.getVirtualFilesByName(project, name, scope)) { if (file.isValid() && MatcherUtil.matchAllParts(parts, file.getPath())) { files.add(file); } } } return true; }); cacheMap.put(key, files); } return cacheMap.get(key); } return new ArrayList<>(); }
Example 4
Source File: IdFilter.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static IdFilter buildProjectIdFilter(Project project, boolean includeNonProjectItems) { long started = System.currentTimeMillis(); final BitSet idSet = new BitSet(); ContentIterator iterator = fileOrDir -> { idSet.set(((VirtualFileWithId)fileOrDir).getId()); ProgressManager.checkCanceled(); return true; }; if (!includeNonProjectItems) { ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator); } else { FileBasedIndex.getInstance().iterateIndexableFiles(iterator, project, ProgressIndicatorProvider.getGlobalProgressIndicator()); } if (LOG.isDebugEnabled()) { long elapsed = System.currentTimeMillis() - started; LOG.debug("Done filter (includeNonProjectItems=" + includeNonProjectItems + ") " + "in " + elapsed + "ms. Total files in set: " + idSet.cardinality()); } return new IdFilter() { @Override public boolean containsFileId(int id) { return id >= 0 && idSet.get(id); } @Nonnull @Override public GlobalSearchScope getEffectiveFilteringScope() { return includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); } }; }
Example 5
Source File: BashFileRenameProcessor.java From BashSupport with Apache License 2.0 | 5 votes |
/** * Returns references to the given element. If it is a BashPsiElement a special search scope is used to locate the elements referencing the file. * * @param element References to the given element * @return */ @NotNull @Override public Collection<PsiReference> findReferences(PsiElement element) { //fixme fix the custom scope SearchScope scope = (element instanceof BashPsiElement) ? BashElementSharedImpl.getElementUseScope((BashPsiElement) element, element.getProject()) : GlobalSearchScope.projectScope(element.getProject()); Query<PsiReference> search = ReferencesSearch.search(element, scope); return search.findAll(); }
Example 6
Source File: XQueryRunConfigurationModule.java From intellij-xquery with Apache License 2.0 | 5 votes |
public GlobalSearchScope getSearchScope() { final Module module = getModule(); if (module != null) { return GlobalSearchScope.moduleWithDependenciesScope(module); } return GlobalSearchScope.projectScope(getProject()); }
Example 7
Source File: HaxeClassContributor.java From intellij-haxe with Apache License 2.0 | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); final Collection<HaxeComponent> result = HaxeComponentIndex.getItemsByName(name, project, scope); return result.toArray(new NavigationItem[result.size()]); }
Example 8
Source File: CoverageSuitesBundle.java From consulo with Apache License 2.0 | 5 votes |
private GlobalSearchScope getSearchScopeInner(Project project) { final RunConfigurationBase configuration = getRunConfiguration(); if (configuration instanceof ModuleBasedConfiguration) { final Module module = ((ModuleBasedConfiguration)configuration).getConfigurationModule().getModule(); if (module != null) { return GlobalSearchScope.moduleRuntimeScope(module, isTrackTestFolders()); } } return isTrackTestFolders() ? GlobalSearchScope.projectScope(project) : GlobalSearchScopesCore.projectProductionScope(project); }
Example 9
Source File: BlazePyUseScopeEnlarger.java From intellij with Apache License 2.0 | 5 votes |
@Nullable @Override public SearchScope getAdditionalUseScope(PsiElement element) { if (!Blaze.isBlazeProject(element.getProject())) { return null; } if (isPyPackageOutsideProject(element) || isPyFileOutsideProject(element)) { return GlobalSearchScope.projectScope(element.getProject()); } return null; }
Example 10
Source File: GoToClassContributor.java From protobuf-jetbrains-plugin with Apache License 2.0 | 5 votes |
@NotNull private GlobalSearchScope getSearchScope(Project project, boolean includeNonProjectItems) { if (includeNonProjectItems) { return GlobalSearchScope.allScope(project); } else { return GlobalSearchScope.projectScope(project); } }
Example 11
Source File: TodoTreeHelper.java From consulo with Apache License 2.0 | 5 votes |
private static void traverseSubPackages(PsiPackage psiPackage, Module module, TodoTreeBuilder builder, Project project, Set<PsiPackage> packages) { if (!isPackageEmpty(new PackageElement(module, psiPackage, false), builder, project)) { packages.add(psiPackage); } GlobalSearchScope scope = module != null ? GlobalSearchScope.moduleScope(module) : GlobalSearchScope.projectScope(project); final PsiPackage[] subPackages = psiPackage.getSubPackages(scope); for (PsiPackage subPackage : subPackages) { traverseSubPackages(subPackage, module, builder, project, packages); } }
Example 12
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Nullable public static XmlTag findGlobalElement(PsiElement element, String elementName) { final Project project = element.getProject(); final PsiFile psiFile = PsiTreeUtil.getParentOfType(element, PsiFile.class); //Search first in the local file else we search globally if (psiFile != null) { final XmlTag xmlTag = findGlobalElementInFile(project, elementName, psiFile.getVirtualFile()); if (xmlTag != null) { return xmlTag; } } final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project); return findGlobalElementInScope(project, elementName, searchScope); }
Example 13
Source File: TodoPackageNode.java From consulo with Apache License 2.0 | 5 votes |
/** * @return read-only iterator of all valid PSI files that can have T.O.D.O items * and which are located under specified <code>psiDirctory</code>. */ public Iterator<PsiFile> getFiles(PackageElement packageElement) { ArrayList<PsiFile> psiFileList = new ArrayList<PsiFile>(); GlobalSearchScope scope = packageElement.getModule() != null ? GlobalSearchScope.moduleScope(packageElement.getModule()) : GlobalSearchScope.projectScope(myProject); final PsiDirectory[] directories = packageElement.getPackage().getDirectories(scope); for (PsiDirectory directory : directories) { Iterator<PsiFile> files = myBuilder.getFiles(directory, false); for (;files.hasNext();) { psiFileList.add(files.next()); } } return psiFileList.iterator(); }
Example 14
Source File: HaxeSymbolContributor.java From intellij-haxe with Apache License 2.0 | 5 votes |
@NotNull @Override public NavigationItem[] getItemsByName(@NotNull final String name, @NotNull final String pattern, @NotNull final Project project, final boolean includeNonProjectItems) { final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); final Collection<HaxeComponentName> result = HaxeSymbolIndex.getItemsByName(name, project, scope); return result.toArray(new NavigationItem[result.size()]); }
Example 15
Source File: ThriftClassContributor.java From intellij-thrift with Apache License 2.0 | 4 votes |
private GlobalSearchScope getScope(Project project, boolean includeNonProjectItems) { return includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); }
Example 16
Source File: GraphQLConfigManager.java From js-graphql-intellij-plugin with MIT License | 4 votes |
public GraphQLConfigManager(Project myProject) { this.myProject = myProject; this.projectScope = GlobalSearchScope.projectScope(myProject); this.graphQLConfigGlobMatcher = ServiceManager.getService(myProject, GraphQLConfigGlobMatcher.class); this.pluginDescriptor = PluginManager.getPlugin(PluginId.getId("com.intellij.lang.jsgraphql")); }
Example 17
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
public static List<DomElement> getFlows(Project project) { final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project); return getFlowsInScope(project, searchScope); }
Example 18
Source File: BaseRefactoringProcessor.java From consulo with Apache License 2.0 | 4 votes |
protected BaseRefactoringProcessor(@Nonnull Project project, @Nullable Runnable prepareSuccessfulCallback) { this(project, GlobalSearchScope.projectScope(project), prepareSuccessfulCallback); }
Example 19
Source File: AbstractTreeClassChooserDialog.java From consulo with Apache License 2.0 | 4 votes |
public AbstractTreeClassChooserDialog(String title, Project project, final Class<T> elementClass, @Nullable T initialClass) { this(title, project, GlobalSearchScope.projectScope(project), elementClass, null, initialClass); }
Example 20
Source File: AnalysisScope.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public SearchScope toSearchScope() { switch (myType) { case CUSTOM: return myScope; case DIRECTORY: return GlobalSearchScopesCore.directoryScope((PsiDirectory)myElement, true); case FILE: return new LocalSearchScope(myElement); case INVALID: return LocalSearchScope.EMPTY; case MODULE: GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(myModule); return myIncludeTestSource ? moduleScope : GlobalSearchScope.notScope(GlobalSearchScopesCore.projectTestScope(myModule.getProject())).intersectWith(moduleScope); case MODULES: SearchScope scope = GlobalSearchScope.EMPTY_SCOPE; for (Module module : myModules) { scope = scope.union(GlobalSearchScope.moduleScope(module)); } return scope; case PROJECT: return myIncludeTestSource ? GlobalSearchScope.projectScope(myProject) : GlobalSearchScopesCore.projectProductionScope(myProject); case VIRTUAL_FILES: return new GlobalSearchScope() { @Override public boolean contains(@Nonnull VirtualFile file) { return myFilesSet.contains(file); } @Override public int compare(@Nonnull VirtualFile file1, @Nonnull VirtualFile file2) { return 0; } @Override public boolean isSearchInModuleContent(@Nonnull Module aModule) { return false; } @Override public boolean isSearchInLibraries() { return false; } }; default: LOG.error("invalid type " + myType); return GlobalSearchScope.EMPTY_SCOPE; } }