Java Code Examples for com.intellij.psi.search.GlobalSearchScope#allScope()
The following examples show how to use
com.intellij.psi.search.GlobalSearchScope#allScope() .
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: PhpInjectFileReferenceIndex.java From idea-php-advanced-autocomplete with MIT License | 6 votes |
public static PhpInjectFileReference getInjectFileReference(@NotNull Project project, @NotNull Function function, int argumentIndex) { FileBasedIndex index = FileBasedIndex.getInstance(); GlobalSearchScope scope = GlobalSearchScope.allScope(project); Ref<List<PhpInjectFileReference>> result = new Ref<>(ContainerUtil.emptyList()); result.set(index.getValues(KEY, function.getFQN() + ":" + argumentIndex, scope)); if (result.get().isEmpty() && function instanceof PhpClassMember) { PhpClassHierarchyUtils.processSuperMembers((PhpClassMember)function, (classMember, subClass, baseClass) -> { List<PhpInjectFileReference> values = index.getValues(KEY, classMember.getFQN() + ":" + argumentIndex, scope); if (values.isEmpty()) { return true; } else { result.set(values); return false; } }); } if (result.get().isEmpty()) { return null; } return result.get().get(0); }
Example 2
Source File: XDebugSessionTab.java From consulo with Apache License 2.0 | 6 votes |
private XDebugSessionTab(@Nonnull XDebugSessionImpl session, @Nullable Image icon, @Nullable ExecutionEnvironment environment) { super(session.getProject(), "Debug", session.getSessionName(), GlobalSearchScope.allScope(session.getProject())); setSession(session, environment, icon); myUi.addContent(createFramesContent(), 0, PlaceInGrid.left, false); addVariablesAndWatches(session); attachToSession(session); DefaultActionGroup focus = new DefaultActionGroup(); focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT)); myUi.getOptions().setAdditionalFocusActions(focus); myUi.addListener(new ContentManagerAdapter() { @Override public void selectionChanged(ContentManagerEvent event) { Content content = event.getContent(); if (mySession != null && content.isSelected() && getWatchesContentId().equals(ViewImpl.ID.get(content))) { myRebuildWatchesRunnable.run(); } } }, myRunContentDescriptor); rebuildViews(); }
Example 3
Source File: ClassHelper.java From MVPManager with MIT License | 6 votes |
/** * search class by class name. * * @param name * @param project * @return */ private static PsiClass searchClassByName(String name, Project project) { GlobalSearchScope searchScope = GlobalSearchScope.allScope(project); PsiClass[] psiClasses = PsiShortNamesCache.getInstance(project).getClassesByName(name, searchScope); if (psiClasses.length == 1) { return psiClasses[0]; } if (psiClasses.length > 1) { for (PsiClass pc : psiClasses) { PsiJavaFile psiJavaFile = (PsiJavaFile) pc.getContainingFile(); String packageName = psiJavaFile.getPackageName(); if (List.class.getPackage().getName().equals(packageName) || packageName.contains("io.xujiaji.xmvp")) { return pc; } } } return null; }
Example 4
Source File: ORFileManager.java From reasonml-idea-plugin with MIT License | 6 votes |
@Nullable public static PsiFile findCmtFileFromSource(@NotNull Project project, @NotNull String filenameWithoutExtension) { if (!DumbService.isDumb(project)) { GlobalSearchScope scope = GlobalSearchScope.allScope(project); String filename = filenameWithoutExtension + ".cmt"; PsiFile[] cmtFiles = FilenameIndex.getFilesByName(project, filename, scope); if (cmtFiles.length == 0) { if (LOG.isDebugEnabled()) { LOG.debug("File module for " + filename + " is NOTĀ FOUND, files found: [" + Joiner.join(", ", cmtFiles) + "]"); } return null; } if (LOG.isDebugEnabled()) { LOG.debug("Found cmt " + filename + " (" + cmtFiles[0].getVirtualFile().getPath() + ")"); } return cmtFiles[0]; } else { LOG.info("Cant find cmt while reindexing"); } return null; }
Example 5
Source File: SubscriberMetadata.java From otto-intellij-plugin with Apache License 2.0 | 5 votes |
@Nullable public PsiMethod getBusPostMethod(Project project) { JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project); GlobalSearchScope globalSearchScope = GlobalSearchScope.allScope(project); PsiClass busClass = javaPsiFacade.findClass(getBusClassName(), globalSearchScope); if (busClass != null) { for (PsiMethod psiMethod : busClass.getMethods()) { if (psiMethod.getName().equals("post")) { return psiMethod; } } } return null; }
Example 6
Source File: TemplateNameUtils.java From bamboo-soy with Apache License 2.0 | 5 votes |
/** * Finds all fully qualified template names starting with a given prefix with respect to aliases * and template visibility. */ public static Collection<Fragment> getPossibleNextIdentifierFragments( Project project, PsiElement identifierElement, String identifier, boolean isDelegate) { AliasMapper mapper = new AliasMapper(identifierElement.getContainingFile()); GlobalSearchScope scope = isDelegate ? GlobalSearchScope.allScope(project) : GlobalSearchScope.allScope(project) .intersectWith( GlobalSearchScope.notScope( GlobalSearchScope.fileScope( identifierElement.getContainingFile().getOriginalFile()))); return TemplateBlockIndex.INSTANCE .getAllKeys(project) .stream() // Filter out private templates, assuming those end with "_". .filter((key) -> !key.endsWith("_")) // Filter out deltemplates or normal templates based on `isDelegate`. // Also checks template's lang. .filter( (key) -> TemplateBlockIndex.INSTANCE .get(key, project, scope) .stream() .anyMatch((block) -> block.isDelegate() == isDelegate)) // Project matches into denormalized key space. .flatMap(mapper::denormalizeIdentifier) // Find the denormalized keys that match the identifier. .filter((key) -> key.startsWith(identifier)) // Collect next fragments. .map((key) -> getNextFragment(key, identifier)) .collect(Collectors.toList()); }
Example 7
Source File: TreeFileChooserDialog.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public Object[] getElementsByName(final String name, final boolean checkBoxState, final String pattern) { GlobalSearchScope scope = myShowLibraryContents ? GlobalSearchScope.allScope(myProject) : GlobalSearchScope.projectScope(myProject); final PsiFile[] psiFiles = FilenameIndex.getFilesByName(myProject, name, scope); return filterFiles(psiFiles); }
Example 8
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 9
Source File: ReferenceSearchTest.java From Intellij-Plugin with Apache License 2.0 | 5 votes |
@Test public void testShouldNotFindReferencesOfNonGaugeElement() throws Exception { when(element.getProject()).thenReturn(project); ReferencesSearch.SearchParameters searchParameters = new ReferencesSearch.SearchParameters(element, GlobalSearchScope.allScope(project), true); when(helper.shouldFindReferences(searchParameters, searchParameters.getElementToSearch())).thenReturn(false); new ReferenceSearch(helper).processQuery(searchParameters, psiReference -> false); verify(helper, never()).getPsiElements(any(StepCollector.class), any(PsiElement.class)); }
Example 10
Source File: TreeFileChooserDialog.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public String[] getNames(final boolean checkBoxState) { final String[] fileNames; if (myFileType != null && myProject != null) { GlobalSearchScope scope = myShowLibraryContents ? GlobalSearchScope.allScope(myProject) : GlobalSearchScope.projectScope(myProject); Collection<VirtualFile> virtualFiles = FileTypeIndex.getFiles(myFileType, scope); fileNames = ContainerUtil.map2Array(virtualFiles, String.class, new Function<VirtualFile, String>() { @Override public String fun(VirtualFile file) { return file.getName(); } }); } else { fileNames = FilenameIndex.getAllFilenames(myProject); } final Set<String> array = new THashSet<String>(); for (String fileName : fileNames) { if (!array.contains(fileName)) { array.add(fileName); } } final String[] result = ArrayUtil.toStringArray(array); Arrays.sort(result); return result; }
Example 11
Source File: BlazeConsoleView.java From intellij with Apache License 2.0 | 5 votes |
/** Add the global filters, wrapped to separate them from blaze problems. */ private void addWrappedPredefinedFilters() { GlobalSearchScope scope = GlobalSearchScope.allScope(project); for (ConsoleFilterProvider provider : ConsoleFilterProvider.FILTER_PROVIDERS.getExtensions()) { Arrays.stream(getFilters(scope, provider)) .forEach(f -> consoleView.addMessageFilter(NonProblemFilterWrapper.wrap(f))); } }
Example 12
Source File: HaxeInheritanceDefinitionsSearcher.java From intellij-haxe with Apache License 2.0 | 5 votes |
static private boolean processInheritors(final String qName, final PsiElement context, final Processor<? super PsiElement> consumer) { final Set<String> namesSet = new THashSet<String>(); final LinkedList<String> namesQueue = new LinkedList<String>(); namesQueue.add(qName); final Project project = context.getProject(); final GlobalSearchScope scope = GlobalSearchScope.allScope(project); while (!namesQueue.isEmpty()) { final String name = namesQueue.pollFirst(); if (!namesSet.add(name)) { continue; } List<List<HaxeClassInfo>> files = FileBasedIndex.getInstance().getValues(HaxeInheritanceIndex.HAXE_INHERITANCE_INDEX, name, scope); files.addAll(FileBasedIndex.getInstance().getValues(HaxeTypeDefInheritanceIndex.HAXE_TYPEDEF_INHERITANCE_INDEX, name, scope)); for (List<HaxeClassInfo> subClassInfoList : files) { for (HaxeClassInfo subClassInfo : subClassInfoList) { final HaxeClass subClass = HaxeResolveUtil.findClassByQName(subClassInfo.getValue(), context.getManager(), scope); if (subClass != null) { if (!consumer.process(subClass)) { return true; } namesQueue.add(subClass.getQualifiedName()); } } } } return true; }
Example 13
Source File: LogConsoleImpl.java From consulo with Apache License 2.0 | 5 votes |
/** * @deprecated use {@link #LogConsoleImpl(com.intellij.openapi.project.Project, java.io.File, java.nio.charset.Charset, long, String, boolean, com.intellij.psi.search.GlobalSearchScope)} */ public LogConsoleImpl(Project project, @Nonnull File file, @Nonnull Charset charset, long skippedContents, String title, final boolean buildInActions) { this(project, file, charset, skippedContents, title, buildInActions, GlobalSearchScope.allScope(project)); }
Example 14
Source File: PsiConsultantImpl.java From dagger-intellij-plugin with Apache License 2.0 | 5 votes |
private static boolean isLazyOrProvider(PsiClass psiClass) { if (psiClass == null) { return false; } Project project = psiClass.getProject(); JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project); GlobalSearchScope globalSearchScope = GlobalSearchScope.allScope(project); PsiClass lazyClass = javaPsiFacade.findClass(CLASS_LAZY, globalSearchScope); PsiClass providerClass = javaPsiFacade.findClass(CLASS_PROVIDER, globalSearchScope); return psiClass.equals(lazyClass) || psiClass.equals(providerClass); }
Example 15
Source File: ORProjectManager.java From reasonml-idea-plugin with MIT License | 4 votes |
public static Set<VirtualFile> findFilesInProject(@NotNull String filename, @NotNull Project project) { GlobalSearchScope scope = GlobalSearchScope.allScope(project); Collection<VirtualFile> virtualFilesByName = FilenameIndex.getVirtualFilesByName(project, filename, scope); return new HashSet<>(virtualFilesByName); }
Example 16
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 17
Source File: MockResolveScopeManager.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public GlobalSearchScope getDefaultResolveScope(VirtualFile vFile) { return GlobalSearchScope.allScope(myProject); }
Example 18
Source File: LogConsoleBase.java From consulo with Apache License 2.0 | 4 votes |
public LogConsoleBase(@Nonnull Project project, @Nullable Reader reader, String title, final boolean buildInActions, LogFilterModel model) { this(project, reader, title, buildInActions, model, GlobalSearchScope.allScope(project)); }
Example 19
Source File: LibraryScopeCache.java From consulo with Apache License 2.0 | 4 votes |
@Inject public LibraryScopeCache(Project project) { myProject = project; myLibrariesOnlyScope = new LibrariesOnlyScope(GlobalSearchScope.allScope(myProject), myProject); }
Example 20
Source File: MockResolveScopeManager.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public GlobalSearchScope getUseScope(@Nonnull PsiElement element) { return GlobalSearchScope.allScope(element.getProject()); }