Java 类com.intellij.psi.search.FileTypeIndex 实例源码

项目:TS-IJ    文件:TSGlobalCachedListGenerator.java   
@Override
public Set<TSVarExpr> generate(Project project) {
    Set<TSVarExpr> items = new HashSet<>();
    //Search every file in the project
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, TSFileType.INSTANCE, GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        TSFile tsFile = (TSFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (tsFile != null) {
            Collection<TSAssignExpr> assignments = PsiTreeUtil.findChildrenOfType(tsFile, TSAssignExpr.class);
            for (TSAssignExpr assignment : assignments) {
                PsiElement first = assignment.getFirstChild();
                if (!(first instanceof TSVarExpr))
                    continue;

                if (((TSVarExpr)first).isLocal())
                    continue;

                items.add((TSVarExpr) first);

            }
        }
        ProgressManager.progress("Loading Symbols");
    }
    return items;
}
项目:idea-php-typo3-plugin    文件:CoreServiceParser.java   
private void collectServices(Project project) {
    FileBasedIndex index = FileBasedIndex.getInstance();
    Collection<VirtualFile> containingFiles = index.getContainingFiles(
            FileTypeIndex.NAME,
            PhpFileType.INSTANCE,
            GlobalSearchScope.allScope(project)
    );
    containingFiles.removeIf(virtualFile -> !(virtualFile.getName().contains("ext_localconf.php")));

    for (VirtualFile projectFile : containingFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(projectFile);
        if (psiFile != null) {
            psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
        }
    }
}
项目:greycat-idea-plugin    文件:GCMUtil.java   
public static List<GCMTypeDeclaration> findProperties(Project project) {
    final List<GCMTypeDeclaration> result = new ArrayList<GCMTypeDeclaration>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, GCMLanguageType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        GCMFile simpleFile = (GCMFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            simpleFile.acceptChildren(new PsiElementVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    if (element instanceof GCMDeclaration) {
                        GCMDeclaration declaration = (GCMDeclaration) element;
                        if (declaration.getClassDeclaration() != null) {
                            result.add(declaration.getClassDeclaration().getTypeDeclaration());
                        }
                        if (declaration.getCustomTypeDeclaration() != null) {
                            //result.add(declaration.getCustomTypeDeclaration().getTypeDeclaration());
                        }
                    }
                    super.visitElement(element);
                }
            });
        }
    }
    return result;
}
项目:intellij-postfix-templates    文件:CptUtil.java   
public static List<CptMapping> findMappings(Project project, String key) {
    List<CptMapping> result = null;

    Collection<VirtualFile> virtualFiles =
        FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, CptFileType.INSTANCE,
            GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        CptFile cptFile = (CptFile) PsiManager.getInstance(project).findFile(virtualFile);

        if (cptFile != null) {
            CptMapping[] mappings = PsiTreeUtil.getChildrenOfType(cptFile, CptMapping.class);
            if (mappings != null) {
                for (CptMapping mapping : mappings) {
                    if (key.equals(mapping.getMatchingClass())) {
                        if (result == null) {
                            result = new ArrayList<>();
                        }
                        result.add(mapping);
                    }
                }
            }
        }
    }
    return result != null ? result : Collections.emptyList();
}
项目:intellij-postfix-templates    文件:CptUtil.java   
public static List<CptMapping> findMappings(Project project) {
    List<CptMapping> result = new ArrayList<>();

    Collection<VirtualFile> virtualFiles =
        FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, CptFileType.INSTANCE,
            GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        CptFile cptFile = (CptFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (cptFile != null) {
            CptMapping[] mappings = PsiTreeUtil.getChildrenOfType(cptFile, CptMapping.class);
            if (mappings != null) {
                Collections.addAll(result, mappings);
            }
        }
    }
    return result;
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
@NotNull
private static List<DomElement> getFlowsInScope(Project project, GlobalSearchScope searchScope) {
    final List<DomElement> result = new ArrayList<>();
    final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
    final DomManager manager = DomManager.getDomManager(project);
    for (VirtualFile file : files) {
        final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
        if (isMuleFile(xmlFile)) {
            final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
            if (fileElement != null) {
                final Mule rootElement = fileElement.getRootElement();
                result.addAll(rootElement.getFlows());
                result.addAll(rootElement.getSubFlows());
            }
        }
    }
    return result;
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
@NotNull
private static List<XmlTag> getGlobalElementsInScope(Project project, GlobalSearchScope searchScope) {
    final List<XmlTag> result = new ArrayList<>();
    final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
    final DomManager manager = DomManager.getDomManager(project);
    for (VirtualFile file : files) {
        final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
        if (isMuleFile(xmlFile)) {
            final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
            if (fileElement != null) {
                final Mule rootElement = fileElement.getRootElement();
                final XmlTag[] subTags = rootElement.getXmlTag().getSubTags();
                for (XmlTag subTag : subTags) {
                    if (isGlobalElement(subTag)) {
                        result.add(subTag);
                    }
                }
            }
        }
    }
    return result;
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
public static List<XmlTag> findFlowRefsForFlow(@NotNull XmlTag flow) {
    List<XmlTag> flowRefs = new ArrayList<>();

    final Project project = flow.getProject();
    final String flowName = flow.getAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE);

    Collection<VirtualFile> vFiles = FileTypeIndex.getFiles(StdFileTypes.XML, ProjectScope.getContentScope(project));
    for (VirtualFile virtualFile : vFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        if (psiFile != null) {
            XmlFile xmlFile = (XmlFile) psiFile;
            XmlTag mule = xmlFile.getRootTag();

            FlowRefsFinder finder = new FlowRefsFinder(flowName);
            mule.accept(finder);
            flowRefs.addAll(finder.getFlowRefs());
        }
    }
    return flowRefs;
}
项目:smcplugin    文件:SmcUtil.java   
public static List<SmcTransition> findTransitions(Project project, String name) {
    List<SmcTransition> result = null;
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SmcFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        SmcFile smcFile = (SmcFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (smcFile != null) {
            SmcTransition[] properties = PsiTreeUtil.getChildrenOfType(smcFile, SmcTransition.class);
            if (properties != null) {
                for (SmcTransition property : properties) {
                    if (name.equals(property.getName())) {
                        if (result == null) {
                            result = new ArrayList<SmcTransition>();
                        }
                        result.add(property);
                    }
                }
            }
        }
    }
    return result != null ? result : Collections.<SmcTransition>emptyList();
}
项目:smcplugin    文件:SmcPsiUtil.java   
public static List<SmcMap> findMapGlobally(Project project, String name) {
    List<SmcMap> result = null;
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SmcFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        SmcFile simpleFile = (SmcFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            Collection<SmcMap> properties = PsiTreeUtil.findChildrenOfType(simpleFile, SmcMap.class);
            for (SmcMap property : properties) {
                if (name.equals(property.getName())) {
                    if (result == null) {
                        result = new ArrayList<SmcMap>();
                    }
                    result.add(property);
                }
            }
        }
    }
    return result != null ? result : Collections.<SmcMap>emptyList();
}
项目:smcplugin    文件:SmcPsiUtil.java   
public static List<SmcFile> findSmcFile(Project project, Predicate<SmcFile> predicate) {
    List<SmcFile> result = null;
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SmcFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        SmcFile smcFile = (SmcFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (smcFile != null &&
                (predicate == null || predicate.apply(smcFile))) {
            if (result == null) {
                result = new ArrayList<>();
            }
            result.add(smcFile);
        }
    }
    return result != null ? result : Collections.<SmcFile>emptyList();
}
项目:smcplugin    文件:SmcPsiUtil.java   
public static List<? extends SmcMethodLikeElement> findMethodLikeForMethod(PsiMethod psiMethod, Class<? extends SmcMethodLikeElement> aClass, Predicate<SmcMethodLikeElement> predicate) {
    List<SmcMethodLikeElement> result = null;
    Project project = psiMethod.getProject();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SmcFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        SmcFile simpleFile = (SmcFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            Collection<? extends SmcMethodLikeElement> methodLikeElements = PsiTreeUtil.findChildrenOfType(simpleFile, aClass);
            for (SmcMethodLikeElement methodLike : methodLikeElements) {
                if (psiMethod.getName().equals(methodLike.getName()) &&
                        psiMethod.getParameterList().getParametersCount() == methodLike.getArgumentCount() &&
                        (predicate == null || predicate.apply(methodLike))) {
                    if (result == null) {
                        result = new ArrayList<>();
                    }
                    result.add(methodLike);
                }
            }
        }
    }
    return result != null ? result : Collections.<SmcMethodLikeElement>emptyList();
}
项目:smcplugin    文件:SmcPsiUtil.java   
public static List<SmcTransition> findTransitionByMethod(PsiMethod psiMethod, Predicate<SmcTransition> predicate) {
    List<SmcTransition> result = null;
    Project project = psiMethod.getProject();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SmcFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        SmcFile simpleFile = (SmcFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            Collection<SmcTransition> smcTransitions = PsiTreeUtil.findChildrenOfType(simpleFile, SmcTransition.class);
            for (SmcTransition transition : smcTransitions) {
                if (psiMethod.getName().equals(transition.getName()) &&
                        (psiMethod.getParameterList().getParametersCount() == transition.getArgumentCount() + 1) &&
                        (predicate == null || predicate.apply(transition))) {
                    if (result == null) {
                        result = new ArrayList<>();
                    }
                    result.add(transition);
                }
            }
        }
    }
    return result != null ? result : Collections.<SmcTransition>emptyList();
}
项目:smcplugin    文件:SmcPsiUtil.java   
public static List<PsiMethodCallExpression> findMethodLikeCalls(SmcMethodLikeElement psiMethodLike) {
    SmcFile containingFile = (SmcFile) psiMethodLike.getContainingFile().getContainingFile();
    PsiClass fsmClass = containingFile.getFsmClass();
    Project project = psiMethodLike.getProject();
    if (fsmClass == null) return Collections.emptyList();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, JavaFileType.INSTANCE,
            GlobalSearchScope.projectScope(project));
    List<PsiMethodCallExpression> result = new ArrayList<>();
    for (VirtualFile virtualFile : virtualFiles) {
        PsiJavaFile psiJavaFile = (PsiJavaFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (psiJavaFile != null) {
            Collection<PsiMethodCallExpression> methodCallExpressions = PsiTreeUtil.findChildrenOfType(psiJavaFile, PsiMethodCallExpression.class);
            for (PsiMethodCallExpression methodCall : methodCallExpressions) {
                PsiMethod psiMethod = methodCall.resolveMethod();
                if (psiMethod != null && psiMethodLike.matches(psiMethod)) {
                    result.add(methodCall);
                }
            }
        }
    }
    return result;
}
项目:smcplugin    文件:SmcPsiUtil.java   
public static List<PsiMethod> findJavaMethod(Project project, String name) {
    List<PsiMethod> result = null;
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, JavaFileType.INSTANCE,
            GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        PsiJavaFile javaFile = (PsiJavaFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (javaFile != null) {
            Collection<PsiMethod> properties = PsiTreeUtil.findChildrenOfType(javaFile, PsiMethod.class);
            for (PsiMethod javaMethod : properties) {
                if (name.equals(javaMethod.getName())) {
                    if (result == null) {
                        result = new ArrayList<PsiMethod>();
                    }
                    result.add(javaMethod);
                }
            }
        }
    }
    return result != null ? result : Collections.<PsiMethod>emptyList();
}
项目:rythm_plugin    文件:RythmUtil.java   
public static List<RythmRythm> findRythms(Project project, String key) {
    List<RythmRythm> result = null;
    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, RythmFileType.INSTANCE,
                    GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        RythmFile rythmFile = (RythmFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (rythmFile != null) {
            RythmRythm[] rythms = PsiTreeUtil.getChildrenOfType(rythmFile, RythmRythm.class);
            if (rythms != null) {
                for (RythmRythm rythm : rythms) {
                   // if (key.equals(rythm.getKey())) {
                        if (result == null) {
                            result = new ArrayList<RythmRythm>();
                        }
                        result.add(rythm);
                    }
                }
            }
        }
   // }
    return result != null ? result : Collections.<RythmRythm>emptyList();
}
项目:rythm_plugin    文件:RythmUtil.java   
public static List<RythmRythm> findRythms(Project project) {
    List<RythmRythm> result = new ArrayList<RythmRythm>();
    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, RythmFileType.INSTANCE,
                    GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        RythmFile rythmFile = (RythmFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (rythmFile != null) {
            RythmRythm[] rythms = PsiTreeUtil.getChildrenOfType(rythmFile, RythmRythm.class);
            if (rythms != null) {
                Collections.addAll(result, rythms);
            }
        }
    }
    return result;
}
项目:arma-intellij-plugin    文件:ArmaPluginUtil.java   
/**
 * Gets the config files (either a description.ext or multiple, at least 1, config.cpp (case sensitivity doesn't matter)).
 * If no description.ext file or config.cpp files could be found, this will return an empty list. This will also
 * return and empty list if a module for the given PsiElement couldn't be found.
 * <p>
 * If a description.ext file is found, this method will return a singleton list of the description.ext file,regardless
 * if there are config.cpp files. If there is no description.ext files, this will return all config.cpp files found
 *
 * @param module a PsiElement used to determine what module the root config file is located in
 * @return a list of VirtualFile instances, or an empty list
 */
@NotNull
public static List<VirtualFile> getConfigVirtualFiles(@NotNull Module module) {
    Collection<VirtualFile> files = FileTypeIndex.getFiles(HeaderFileType.INSTANCE, module.getModuleContentScope());
    List<VirtualFile> configs = new ArrayList<>();
    for (VirtualFile virtFile : files) {
        if (virtFile.getName().equalsIgnoreCase("description.ext")) {
            return Collections.singletonList(virtFile);
        }
        if (virtFile.getName().equalsIgnoreCase("config.cpp")) {
            configs.add(virtFile);
        }

    }
    return configs;
}
项目:jetbrains-hacklang    文件:HackUtil.java   
public static List<HackVarname> findVarnames(Project project)
{
    List<HackVarname> result = new ArrayList<HackVarname>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance()
            .getContainingFiles(FileTypeIndex.NAME, HackFileType.INSTANCE, GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        HackFile hackFile = (HackFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (hackFile != null) {
            HackVarname[] varnames = PsiTreeUtil.getChildrenOfType(hackFile, HackVarname.class);
            if (varnames != null) {
                Collections.addAll(result, varnames);
            }
        }
    }

    return result;
}
项目:dotplugin    文件:DotPSITreeUtil.java   
/**
 * Utility method returning all DotIDs with corresponding id the project.
 *
 * @param project - project for searching
 * @param id_     - DotId id for searching
 * @return iterable set of DotIds naming as id
 */
public static Iterable<DotId> findDotIds(Project project, String id_) {
    Set<DotId> ids = new HashSet<>();
    PsiRecursiveElementVisitor psiRecursiveElementVisitor = new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (element instanceof DotId && element.getText().equals(id_)) {
                ids.add(((DotId) element));
            }
            super.visitElement(element);
        }
    };
    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, DotFileType.INSTANCE,
                    GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        DotFile dotFile = (DotFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (dotFile != null) {
            for (PsiElement e : dotFile.getChildren()) {
                psiRecursiveElementVisitor.visitElement(e);
            }
        }
    }
    return ids;
}
项目:dotplugin    文件:DotPSITreeUtil.java   
/**
 * Utility method returning all DotIDs in the project
 *
 * @param project project for searching
 * @return iterable set of all DotIds in project
 */
public static Iterable<DotId> findDotIds(Project project) {
    Set<DotId> ids = new HashSet<>();
    PsiRecursiveElementVisitor psiRecursiveElementVisitor = new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (element instanceof DotId) {
                ids.add(((DotId) element));
            }
            super.visitElement(element);
        }
    };
    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, DotFileType.INSTANCE,
                    GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        DotFile dotFile = (DotFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (dotFile != null) {
            for (PsiElement e : dotFile.getChildren()) {
                psiRecursiveElementVisitor.visitElement(e);
            }
        }
    }
    return ids;
}
项目:intellij-ce-playground    文件:GroovyHotSwapper.java   
private static boolean containsGroovyClasses(final Project project) {
  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Boolean>() {
    @Nullable
    @Override
    public Result<Boolean> compute() {
      AccessToken accessToken = ReadAction.start();
      try {
        return Result.create(FileTypeIndex.containsFileOfType(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScope.projectScope(project)),
                             PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
      }
      finally {
        accessToken.finish();
      }
    }
  });
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLEndpointCompletionContributor.java   
private boolean completeImportFile(@NotNull CompletionResultSet result, PsiFile file, PsiElement parent) {
    if ((parent instanceof JSGraphQLEndpointQuotedString || parent instanceof JSGraphQLEndpointString) && PsiTreeUtil.getParentOfType(parent, JSGraphQLEndpointImportFileReference.class) != null) {

        final Project project = file.getProject();
        final VirtualFile entryFile = JSGraphQLConfigurationProvider.getService(project).getEndpointEntryFile();
        final GlobalSearchScope scope = JSGraphQLEndpointPsiUtil.getImportScopeFromEntryFile(project, entryFile);
        final Collection<VirtualFile> files = FileTypeIndex.getFiles(JSGraphQLEndpointFileType.INSTANCE, scope);
        for (VirtualFile virtualFile : files) {
            if(virtualFile.equals(entryFile)) {
                // entry file should never be imported
                continue;
            }
            final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
            if (psiFile != null) {
                if(psiFile.equals(file)) {
                    // don't suggest the current file
                    continue;
                }
                String name = JSGraphQLEndpointImportUtil.getImportName(project, psiFile);
                result.addElement(LookupElementBuilder.create(name).withIcon(psiFile.getIcon(0)));
            }
        }
        return true;
    }
    return false;
}
项目:arma-intellij-plugin    文件:ArmaPluginUtil.java   
/**
 * Gets the config files (either a description.ext or multiple, at least 1, config.cpp (case sensitivity doesn't matter)).
 * If no description.ext file or config.cpp files could be found, this will return an empty list. This will also
 * return and empty list if a module for the given PsiElement couldn't be found.
 * <p>
 * If a description.ext file is found, this method will return a singleton list of the description.ext file,regardless
 * if there are config.cpp files. If there is no description.ext files, this will return all config.cpp files found
 *
 * @param module a PsiElement used to determine what module the root config file is located in
 * @return a list of VirtualFile instances, or an empty list
 */
@NotNull
public static List<VirtualFile> getConfigVirtualFiles(@NotNull Module module) {
    Collection<VirtualFile> files = FileTypeIndex.getFiles(HeaderFileType.INSTANCE, module.getModuleContentScope());
    List<VirtualFile> configs = new ArrayList<>();
    for (VirtualFile virtFile : files) {
        if (virtFile.getName().equalsIgnoreCase("description.ext")) {
            return Collections.singletonList(virtFile);
        }
        if (virtFile.getName().equalsIgnoreCase("config.cpp")) {
            configs.add(virtFile);
        }

    }
    return configs;
}
项目:CMaker    文件:CMakeParserUtilImpl.java   
public static List<PsiElement> getDefinedSymbols(Project project) {
    final List<PsiElement> result = new ArrayList<PsiElement>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, 
            CMakeFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    // Scan each file for named entities
    for (VirtualFile virtualFile : virtualFiles) {
        CMakeFile cmakeFile = (CMakeFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (cmakeFile != null) {
            cmakeFile.accept(new PsiRecursiveElementWalkingVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    super.visitElement(element);
                    if(element instanceof CMakeCommandExpr
                            && (element.getFirstChild().getNode().getElementType() == CMakeTypes.FUNCTION
                            || element.getFirstChild().getNode().getElementType() == CMakeTypes.MACRO
                            || element.getFirstChild().toString().equalsIgnoreCase("set")))
                    {
                        result.add(element);
                    }
                }
            });
        }
    }
    return result;
}
项目:CMaker    文件:CMakeParserUtilImpl.java   
public static List<PsiElement> getDefinedSymbols(Project project, final String name) {
    final List<PsiElement> result = new ArrayList<PsiElement>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME,
            CMakeFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    // Scan each file for named entities
    for (VirtualFile virtualFile : virtualFiles) {
        CMakeFile cmakeFile = (CMakeFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (cmakeFile != null) {
            cmakeFile.accept(new PsiRecursiveElementWalkingVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    super.visitElement(element);
                    if(element instanceof CMakeCommandExpr
                            && (element.getFirstChild().getNode().getElementType() == CMakeTypes.FUNCTION
                                || element.getFirstChild().getNode().getElementType() == CMakeTypes.MACRO))
                    {
                        result.add(element);
                    }
                }
            });   
        }
    }
    return result;
}
项目:CMaker    文件:CMakeParserUtilImpl.java   
public static List<PsiElement> getDefinedVars(Project project, String name) {
    final List<PsiElement> result = new ArrayList<PsiElement>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME,
            CMakeFileType.INSTANCE,
            GlobalSearchScope.allScope(project));
    // Scan each file for named entities
    for (VirtualFile virtualFile : virtualFiles) {
        CMakeFile cmakeFile = (CMakeFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (cmakeFile != null) {
            cmakeFile.accept(new PsiRecursiveElementWalkingVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    super.visitElement(element);
                    if(element instanceof CMakeCommandExpr
                            && (element.getFirstChild().getText().contains("set")
                            || element.getFirstChild().getText().contains("list")
                            || element.getFirstChild().getText().contains("option")))
                    {
                        result.add(element);
                    }
                }
            });
        }
    }
    return result;
}
项目:robot-intellij-plugin    文件:RobotResourceFileUtil.java   
/**
 * Find all the ResourceFile imports that refer to this RobotPsiFile.
 * However, don't take into account variable substitution, because we don't want to change
 * the value of variables when we rename refactor a Robot File.
 *
 * @param file
 * @return
 */
public static List<RobotResourceFile> findAllReferencesToFileBeforeVariableSubstitution(RobotPsiFile file) {
    final Project project = file.getProject();
    final List<RobotResourceFile> results = Lists.newArrayList();
    if (file.getVirtualFile() == null) {
        return results;
    }
    Collection<VirtualFile> robotFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, RobotFileType.INSTANCE,
            GlobalSearchScope.projectScope(project));
    for (VirtualFile vf: robotFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(vf);
        if (!(psiFile instanceof RobotPsiFile)) {
            continue;
        }
        getReferencesToRobotFileInResourceSettings(file, (RobotPsiFile)psiFile, results);
    }
    return results;
}
项目:salesforce-plugin    文件:ApexPsiUtilities.java   
@NotNull
public static List<ApexClassDeclaration> getApexClassDeclarations(@NotNull Project project, @NotNull String name) {
    List<ApexClassDeclaration> result = new ArrayList<ApexClassDeclaration>();

    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, ApexClassFileType.INSTANCE,
            GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        ApexClassFile apexClassFile = (ApexClassFile)PsiManager.getInstance(project).findFile(virtualFile);
        ApexClassDeclaration apexClassDeclaration = PsiTreeUtil.getChildOfType(apexClassFile, ApexClassDeclaration.class);
        if (apexClassDeclaration != null) {
            String className = apexClassDeclaration.getName();
            if (name.equals(className)) {
                result.add(apexClassDeclaration);
            }
        }
    }
    return result;
}
项目:salesforce-plugin    文件:ApexPsiUtilities.java   
@NotNull
public static List<ApexClassDeclaration> getApexClassDeclarations(@NotNull Project project) {
    List<ApexClassDeclaration> result = new ArrayList<ApexClassDeclaration>();

    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, ApexClassFileType.INSTANCE,
            GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        ApexClassFile apexClassFile = (ApexClassFile)PsiManager.getInstance(project).findFile(virtualFile);
        ApexClassDeclaration apexClassDeclaration = PsiTreeUtil.getChildOfType(apexClassFile, ApexClassDeclaration.class);
        if (apexClassDeclaration != null) {
            result.add(apexClassDeclaration);
        }
    }
    return result;
}
项目:salesforce-plugin    文件:ApexPsiUtilities.java   
@NotNull
public static List<ApexInterfaceDeclaration> getApexInterfaceDeclarations(@NotNull Project project, @NotNull String name) {
    List<ApexInterfaceDeclaration> result = new ArrayList<ApexInterfaceDeclaration>();

    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, ApexClassFileType.INSTANCE,
            GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        ApexClassFile apexClassFile = (ApexClassFile)PsiManager.getInstance(project).findFile(virtualFile);
        ApexInterfaceDeclaration apexInterfaceDeclaration = PsiTreeUtil.getChildOfType(apexClassFile, ApexInterfaceDeclaration.class);
        if (apexInterfaceDeclaration != null) {
            String interfaceName = apexInterfaceDeclaration.getName();
            if (name.equals(interfaceName)) {
                result.add(apexInterfaceDeclaration);
            }
        }
    }
    return result;
}
项目:salesforce-plugin    文件:ApexPsiUtilities.java   
@NotNull
public static List<ApexInterfaceDeclaration> getApexInterfaceDeclarations(@NotNull Project project) {
    List<ApexInterfaceDeclaration> result = new ArrayList<ApexInterfaceDeclaration>();

    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, ApexClassFileType.INSTANCE,
            GlobalSearchScope.allScope(project));

    for (VirtualFile virtualFile : virtualFiles) {
        ApexClassFile apexClassFile = (ApexClassFile)PsiManager.getInstance(project).findFile(virtualFile);
        ApexInterfaceDeclaration apexInterfaceDeclaration = PsiTreeUtil.getChildOfType(apexClassFile, ApexInterfaceDeclaration.class);
        if (apexInterfaceDeclaration != null) {
            result.add(apexInterfaceDeclaration);
        }
    }
    return result;
}
项目:asciidoctor-intellij-plugin    文件:AsciiDocFileUtil.java   
public static List<AsciiDocSection> findProperties(Project project, String key) {
  List<AsciiDocSection> result = null;
  Collection<VirtualFile> virtualFiles =
    FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, AsciiDocFileType.INSTANCE,
      GlobalSearchScope.allScope(project));
  for (VirtualFile virtualFile : virtualFiles) {
    AsciiDocFile asciiDocFile = (AsciiDocFile)PsiManager.getInstance(project).findFile(virtualFile);
    if (asciiDocFile != null) {
      ArrayList<AsciiDocSection> properties = new ArrayList<>();
      new PsiFilter(AsciiDocSection.class).createVisitor(properties).visitFile(asciiDocFile);
      for (AsciiDocSection property : properties) {
        if (key.equals(property.getTitle())) {
          if (result == null) {
            result = new ArrayList<>();
          }
          result.add(property);
        }
      }
    }
  }
  return result != null ? result : Collections.emptyList();
}
项目:IntelliFrog    文件:FrogIncludedFileReferenceImpl.java   
@NotNull
@Override
public Object[] getVariants() {
    final List<LookupElement> results = ContainerUtil.newArrayList();

    Project project = myElement.getProject();
    GlobalSearchScope searchScope = GlobalSearchScope.allScope(project);
    for (final VirtualFile file : FileTypeIndex.getFiles(FrogFileType.INSTANCE, searchScope)) {
        AllSourceRoots.process(project, new SourceRootProcessor() {
            @Override
            public boolean process(VirtualFile sourceRoot, boolean isLibrary) {
                String path = VfsUtil.getPath(sourceRoot, file, VfsUtil.VFS_PATH_SEPARATOR);
                if (path != null && !path.startsWith("..")) {
                    results.add(LookupElementBuilder.create("/" + path).withIcon(FrogIcons.FILE));
                    return false;
                }
                return true;
            }
        });
    }

    return ArrayUtil.toObjectArray(results);
}
项目:TS-IJ    文件:TSFunctionCachedListGenerator.java   
@Override
public Set<TSFnDeclStmt> generate(Project project) {
    Set<TSFnDeclStmt> items = new HashSet<>();
    //Search every file in the project
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, TSFileType.INSTANCE, GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        TSFile tsFile = (TSFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (tsFile != null) {
            TSFnDeclStmt[] functions = PsiTreeUtil.getChildrenOfType(tsFile, TSFnDeclStmt.class);
            if (functions != null) {
                Collections.addAll(items, functions);
            }

            TSPackageDecl[] packages = PsiTreeUtil.getChildrenOfType(tsFile, TSPackageDecl.class);
            if (packages != null) {
                for (TSPackageDecl pack : packages) {
                    functions = PsiTreeUtil.getChildrenOfType(pack, TSFnDeclStmt.class);
                    if (functions != null) {
                        Collections.addAll(items, functions);
                    }
                }
            }
            ProgressManager.progress("Loading Symbols");
        }
    }
    return items;
}
项目:TS-IJ    文件:TSObjectCachedListGenerator.java   
@Override
public Set<TSObjectExpr> generate(Project project) {
    Set<TSObjectExpr> items = new HashSet<>();
    //Search every file in the project
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, TSFileType.INSTANCE, GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        TSFile tsFile = (TSFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (tsFile != null) {
            items.addAll(PsiTreeUtil.findChildrenOfType(tsFile, TSObjectExpr.class));
            items.addAll(PsiTreeUtil.findChildrenOfType(tsFile, TSDatablockDecl.class));
        }
        ProgressManager.progress("Loading Symbols");
    }
    return items;
}
项目:greycat-idea-plugin    文件:GCMUtil.java   
public static List<GCMTypeDeclaration> findProperties(Project project, final String key) {
    final List<GCMTypeDeclaration> result = new ArrayList<GCMTypeDeclaration>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, GCMLanguageType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        GCMFile simpleFile = (GCMFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            simpleFile.acceptChildren(new PsiElementVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    if (element instanceof GCMDeclaration) {
                        GCMDeclaration declaration = (GCMDeclaration) element;
                        if (declaration.getClassDeclaration() != null && declaration.getClassDeclaration().getTypeDeclaration() != null) {
                            if (key.equals(declaration.getClassDeclaration().getTypeDeclaration().getName())) {
                                result.add(declaration.getClassDeclaration().getTypeDeclaration());
                            }
                        }
                        if (declaration.getCustomTypeDeclaration() != null && declaration.getCustomTypeDeclaration().getIdent() != null) {
                            if (key.equals(declaration.getCustomTypeDeclaration().getIdent())) {
                                //result.add(declaration.getCustomTypeDeclaration().getIdent().getText());
                            }
                        }
                    }
                    super.visitElement(element);
                }
            });
        }
    }
    return result;
}
项目:GravSupport    文件:FileCreateUtil.java   
public static List<VirtualFile> findFileByRelativePath(@NotNull Project project, @NotNull String fileRelativePath) {
    String relativePath = fileRelativePath.startsWith("/") ? fileRelativePath : "/" + fileRelativePath;
    Set<FileType> fileTypes = Collections.singleton(FileTypeManager.getInstance().getFileTypeByFileName(relativePath));
    final List<VirtualFile> fileList = new ArrayList<>();
    FileBasedIndex.getInstance().processFilesContainingAllKeys(FileTypeIndex.NAME, fileTypes, GlobalSearchScope.projectScope(project), null, virtualFile -> {
        if (virtualFile.getPath().endsWith(relativePath)) {
            fileList.add(virtualFile);
        }
        return true;
    });
    return fileList;
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
@Nullable
private static XmlTag findGlobalElementInScope(Project project, String elementName, GlobalSearchScope searchScope) {
    final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
    for (VirtualFile file : files) {
        XmlTag flow = findGlobalElementInFile(project, elementName, file);
        if (flow != null) {
            return flow;
        }
    }
    return null;
}
项目:mule-intellij-plugins    文件:MuleConfigUtils.java   
@Nullable
private static XmlTag findFlowInScope(Project project, String flowName, GlobalSearchScope searchScope) {
    final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
    for (VirtualFile file : files) {
        XmlTag flow = findFlowInFile(project, flowName, file);
        if (flow != null) {
            return flow;
        }
    }
    return null;
}