本文整理汇总了Java中com.intellij.psi.search.FileTypeIndex.getFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileTypeIndex.getFiles方法的具体用法?Java FileTypeIndex.getFiles怎么用?Java FileTypeIndex.getFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.search.FileTypeIndex
的用法示例。
在下文中一共展示了FileTypeIndex.getFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: getConfigVirtualFiles
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
/**
* 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;
}
示例5: completeImportFile
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
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;
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:27,代码来源:JSGraphQLEndpointCompletionContributor.java
示例6: getVariants
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
@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);
}
示例7: findGlobalElementInScope
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
@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;
}
示例8: findFlowInScope
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
@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;
}
示例9: buildChildren
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
@Override
protected SimpleNode[] buildChildren() {
List<SimpleNode> myConfigNodes = new ArrayList<>();
final DomManager manager = DomManager.getDomManager(myProject);
final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, GlobalSearchScope.projectScope(myProject));
for (VirtualFile file : files) {
final PsiFile xmlFile = PsiManager.getInstance(myProject).findFile(file);
if (xmlFile != null) {
// PsiDirectory directory = xmlFile.getParent();
// Module module = ModuleUtilCore.findModuleForPsiElement((PsiElement) (directory == null ? xmlFile : directory));
if (MuleConfigUtils.isMuleFile(xmlFile)) {
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
XmlTag[] subTags = rootElement.getXmlTag().getSubTags();
for (XmlTag nextTag : subTags) {
MuleElementType muleElementType = MuleConfigUtils.getMuleElementTypeFromXmlElement(nextTag);
if (muleElementType != null && //This is a global config file and it has at least one connector
(MuleElementType.CONFIG.equals(muleElementType) || (MuleElementType.TRANSPORT_CONNECTOR.equals(muleElementType)))) {
MuleConfigNode nextConfigNode = new MuleConfigNode(this, xmlFile);
myConfigNodes.add(nextConfigNode);
break;
}
}
}
}
}
}
return myConfigNodes.toArray(new SimpleNode[]{});
}
示例10: getStringTableXmlFile
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
/**
* @param module {@link Module} instance to get a stringtable.xml file for
* @return a {@link VirtualFile} that maps to a Stringtable.xml file (name case sensitivity doesn't matter),
* or null if couldn't be found
*/
@Nullable
public static VirtualFile getStringTableXmlFile(@NotNull Module module) {
Collection<VirtualFile> files = FileTypeIndex.getFiles(XmlFileType.INSTANCE, module.getModuleContentScope());
for (VirtualFile virtFile : files) {
if (virtFile.getName().equalsIgnoreCase("stringtable.xml")) {
return virtFile;
}
}
return null;
}
示例11: findAllCommandInstances
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
/**
* Adds all {@link SQFCommand} instances in the current module that is equal to findCommand into a list and returns it
*
* @param project project
* @param findCommand the command
* @return list
*/
@NotNull
public static List<SQFCommand> findAllCommandInstances(@NotNull Project project, @NotNull SQFCommand findCommand) {
List<SQFCommand> result = new ArrayList<>();
Module m = ModuleUtil.findModuleForPsiElement(findCommand);
if (m == null) {
return result;
}
GlobalSearchScope searchScope = m.getModuleContentScope();
Collection<VirtualFile> files = FileTypeIndex.getFiles(SQFFileType.INSTANCE, searchScope);
for (VirtualFile virtualFile : files) {
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (!(file instanceof SQFFile)) {
continue;
}
SQFFile sqfFile = (SQFFile) file;
PsiUtil.traverseBreadthFirstSearch(sqfFile.getNode(), astNode -> {
PsiElement nodeAsElement = astNode.getPsi();
if (nodeAsElement instanceof SQFCommand) {
SQFCommand command = (SQFCommand) nodeAsElement;
if (command.commandNameEquals(findCommand.getCommandName())) {
result.add(command);
}
}
return false;
});
}
return result;
}
示例12: findGlobalVariables
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
/**
* Adds all {@link SQFVariable}s in the current module that is equal to findVar into a list and returns it
* <p>
* If findVar is a local variable, the list returned will be empty.
*
* @param project project
* @param findVar variable
* @return list
*/
@NotNull
public static List<SQFVariable> findGlobalVariables(@NotNull Project project, @NotNull SQFVariable findVar) {
List<SQFVariable> result = new ArrayList<>();
if (findVar.isLocal()) {
return result;
}
Module m = ModuleUtil.findModuleForPsiElement(findVar);
if (m == null) {
return result;
}
GlobalSearchScope searchScope = m.getModuleContentScope();
Collection<VirtualFile> files = FileTypeIndex.getFiles(SQFFileType.INSTANCE, searchScope);
for (VirtualFile virtualFile : files) {
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (!(file instanceof SQFFile)) {
continue;
}
SQFFile sqfFile = (SQFFile) file;
PsiUtil.traverseBreadthFirstSearch(sqfFile.getNode(), astNode -> {
PsiElement nodeAsElement = astNode.getPsi();
if (nodeAsElement instanceof SQFVariable) {
SQFVariable var = (SQFVariable) nodeAsElement;
if (var.isLocal()) {
return false;
}
if (SQFVariableName.nameEquals(var.getVarName(), findVar.getVarName())) {
result.add(var);
}
}
return false;
});
}
return result;
}
示例13: getNames
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
@Override
@NotNull
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;
}
示例14: addVariantsFromModules
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
private static void addVariantsFromModules(CompletionResultSet result, PsiFile targetFile, boolean inStringLiteral) {
Collection<VirtualFile> files = FileTypeIndex.getFiles(PythonFileType.INSTANCE, PyProjectScopeBuilder.excludeSdkTestsScope(targetFile));
for (VirtualFile file : files) {
PsiFile pyFile = targetFile.getManager().findFile(file);
PsiFileSystemItem importable = (PsiFileSystemItem) PyUtil.turnInitIntoDir(pyFile);
if (importable == null) continue;
if (PythonReferenceImporter.isImportableModule(targetFile, importable)) {
LookupElementBuilder element = PyModuleType.buildFileLookupElement(importable, null);
if (element != null) {
result.addElement(element.withInsertHandler(inStringLiteral ? STRING_LITERAL_INSERT_HANDLER : IMPORTING_INSERT_HANDLER));
}
}
}
}
示例15: findProjectIdentifiers
import com.intellij.psi.search.FileTypeIndex; //导入方法依赖的package包/类
public static Collection<KUserId> findProjectIdentifiers(Project project) {
final Collection<VirtualFile> virtualFiles = FileTypeIndex.getFiles(KFileType.INSTANCE,
GlobalSearchScope.allScope(project));
final Stream<KUserId> stream = virtualFiles.stream()
.flatMap(file -> findIdentifiers(project, file, AnyMatcher, false).stream());
List<KUserId> fnNames = stream.collect(Collectors.toList());
return fnNames;
}