本文整理汇总了Java中com.intellij.psi.search.FileTypeIndex类的典型用法代码示例。如果您正苦于以下问题:Java FileTypeIndex类的具体用法?Java FileTypeIndex怎么用?Java FileTypeIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileTypeIndex类属于com.intellij.psi.search包,在下文中一共展示了FileTypeIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
@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;
}
示例2: collectServices
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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));
}
}
}
示例3: findProperties
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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;
}
示例4: findMappings
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例5: getFlowsInScope
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
@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;
}
示例6: getGlobalElementsInScope
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
@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;
}
示例7: findFlowRefsForFlow
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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;
}
示例8: findTransitions
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例9: findMapGlobally
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例10: findSmcFile
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例11: findMethodLikeForMethod
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例12: findTransitionByMethod
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例13: findMethodLikeCalls
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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;
}
示例14: findJavaMethod
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}
示例15: findRythms
import com.intellij.psi.search.FileTypeIndex; //导入依赖的package包/类
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();
}