Java Code Examples for com.intellij.psi.search.GlobalSearchScope#getScopeRestrictedByFileTypes()

The following examples show how to use com.intellij.psi.search.GlobalSearchScope#getScopeRestrictedByFileTypes() . 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: IdeaUtils.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
public void iterateXmlDocumentRoots(Module module, Consumer<XmlTag> rootTag) {
    final GlobalSearchScope moduleScope = module.getModuleContentScope();
    final GlobalSearchScope xmlFiles = GlobalSearchScope.getScopeRestrictedByFileTypes(moduleScope, XmlFileType.INSTANCE);

    ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex();
    fileIndex.iterateContent(f -> {
        if (xmlFiles.contains(f)) {
            PsiFile file = PsiManager.getInstance(module.getProject()).findFile(f);
            if (file instanceof XmlFile) {
                XmlFile xmlFile = (XmlFile) file;
                XmlTag root = xmlFile.getRootTag();
                if (root != null) {
                    rootTag.accept(xmlFile.getRootTag());
                }
            }
        }
        return true;
    });
}
 
Example 2
Source File: SchemaIDLTypeDefinitionRegistry.java    From js-graphql-intellij-plugin with MIT License 6 votes vote down vote up
public SchemaIDLTypeDefinitionRegistry(Project project) {
    this.project = project;
    scope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), GraphQLFileType.INSTANCE);
    introspectionScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), JsonFileType.INSTANCE);
    psiManager = PsiManager.getInstance(project);
    graphQLEndpointNamedTypeRegistry = JSGraphQLEndpointNamedTypeRegistry.getService(project);
    graphQLPsiSearchHelper = GraphQLPsiSearchHelper.getService(project);
    graphQLConfigManager = GraphQLConfigManager.getService(project);
    graphQLInjectionSearchHelper = ServiceManager.getService(GraphQLInjectionSearchHelper.class);
    project.getMessageBus().connect().subscribe(GraphQLSchemaChangeListener.TOPIC, new GraphQLSchemaEventListener() {
        @Override
        public void onGraphQLSchemaChanged(Integer schemaVersion) {
            scopeToRegistry.clear();
        }
    });
}
 
Example 3
Source File: ExcludeBuildFilesScope.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public GlobalSearchScope getScopeToExclude(PsiElement element) {
  if (!enabled.getValue()) {
    return null;
  }
  if (element instanceof PsiFileSystemItem) {
    return GlobalSearchScope.getScopeRestrictedByFileTypes(
        new EverythingGlobalScope(), BuildFileType.INSTANCE);
  }
  return null;
}
 
Example 4
Source File: BuildReferenceSearcher.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void searchForString(
    SearchParameters params, SearchScope scope, PsiElement element, String string) {
  if (scope instanceof GlobalSearchScope) {
    scope =
        GlobalSearchScope.getScopeRestrictedByFileTypes(
            (GlobalSearchScope) scope, BuildFileType.INSTANCE);
  }
  params.getOptimizer().searchWord(string, scope, UsageSearchContext.IN_STRINGS, true, element);
}
 
Example 5
Source File: BashSearchScopes.java    From BashSupport with Apache License 2.0 4 votes vote down vote up
public static GlobalSearchScope bashOnly(GlobalSearchScope scope) {
    return GlobalSearchScope.getScopeRestrictedByFileTypes(scope, BashFileType.BASH_FILE_TYPE);
}
 
Example 6
Source File: ServiceIndexUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
/**
 * So support only some file types, so we can filter them and xml and yaml for now
 */
public static GlobalSearchScope getRestrictedFileTypesScope(@NotNull Project project) {
    return GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), XmlFileType.INSTANCE, YAMLFileType.YML, PhpFileType.INSTANCE);
}