类com.intellij.psi.search.GlobalSearchScopesCore源码实例Demo

下面列出了怎么用com.intellij.psi.search.GlobalSearchScopesCore的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Uses custom editable scopes to limit the schema and reference resolution of a GraphQL psi element
 */
public GlobalSearchScope getSchemaScope(PsiElement element) {

    return fileNameToSchemaScope.computeIfAbsent(getFileName(element.getContainingFile()), fileName -> {

        final VirtualFile virtualFile = getVirtualFile(element.getContainingFile());
        final NamedScope schemaScope = graphQLConfigManager.getSchemaScope(virtualFile);
        if (schemaScope != null) {
            final GlobalSearchScope filterSearchScope = GlobalSearchScopesCore.filterScope(myProject, schemaScope);
            return searchScope.intersectWith(filterSearchScope.union(allBuiltInSchemaScopes));
        }

        // default is entire project limited by relevant file types
        return searchScope;

    });

}
 
源代码2 项目: IntelliJDeodorant   文件: ScopeChooserCombo.java
private void browseCustomScope(Project project) {
    EditScopesDialog dialog = EditScopesDialog.showDialog(project, null);
    if (dialog.isOK()) {
        if (dialog.getSelectedScope() != null) {
            customScope = new AnalysisScope(GlobalSearchScopesCore.filterScope(project, dialog.getSelectedScope()), project);
            configureComboBox(customScope.getDisplayName());
        }
    }
}
 
/**
 * Creates a search scope for finding import files based on the endpoint entry file, falling back to
 * project scope in case no entry file has been configured.
 * @param project      project to search
 * @param entryFile    the entry file, or null to look it up
    */
@NotNull
public static GlobalSearchScope getImportScopeFromEntryFile(Project project, @Nullable VirtualFile entryFile, PsiElement scopedElement) {
	if(entryFile == null) {
		entryFile = JSGraphQLConfigurationProvider.getService(project).getEndpointEntryFile(scopedElement.getContainingFile());
	}
	final GlobalSearchScope scope;
	if(entryFile != null) {
		scope = GlobalSearchScopesCore.directoriesScope(project, true, entryFile.getParent());
	} else {
		scope = GlobalSearchScope.projectScope(project);
	}
	return scope;
}
 
源代码4 项目: consulo   文件: CoverageSuitesBundle.java
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);
}
 
源代码5 项目: consulo   文件: DirectoryPathMatcher.java
@Nonnull
GlobalSearchScope narrowDown(@Nonnull GlobalSearchScope fileSearchScope) {
  if (myFiles == null) return fileSearchScope;

  VirtualFile[] array = ContainerUtil.map2Array(myFiles, VirtualFile.class, p -> p.first);
  return GlobalSearchScopesCore.directoriesScope(myModel.getProject(), true, array).intersectWith(fileSearchScope);

}
 
源代码6 项目: consulo   文件: AnalysisScope.java
@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;
  }
}
 
 类所在包
 类方法
 同包方法