本文整理匯總了Java中com.intellij.psi.search.FilenameIndex.getAllFilesByExt方法的典型用法代碼示例。如果您正苦於以下問題:Java FilenameIndex.getAllFilesByExt方法的具體用法?Java FilenameIndex.getAllFilesByExt怎麽用?Java FilenameIndex.getAllFilesByExt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.search.FilenameIndex
的用法示例。
在下文中一共展示了FilenameIndex.getAllFilesByExt方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findFileModules
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
@NotNull
public static List<PsiFile> findFileModules(@NotNull Project project, String extension, @NotNull String name, boolean exact) {
ArrayList<PsiFile> result = new ArrayList<>();
Bucklescript bucklescript = BucklescriptProjectComponent.getInstance(project);
PsiManager psiManager = PsiManager.getInstance(project);
Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, extension);
for (VirtualFile vFile : files) {
String canonicalPath = vFile.getCanonicalPath();
if (bucklescript.isDependency(canonicalPath)) {
FileBase file = (FileBase) psiManager.findFile(vFile);
if (file != null) {
String fileModuleName = file.asModuleName();
boolean found = exact ? fileModuleName.equals(name) : fileModuleName.startsWith(name);
if (found) {
result.add(file);
}
}
}
}
return result;
}
示例2: findModules
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
@NotNull
public static List<PsiModule> findModules(@NotNull Project project, @NotNull String name) {
ArrayList<PsiModule> result = new ArrayList<>();
Collection<VirtualFile> virtualFiles = FilenameIndex.getAllFilesByExt(project, RmlFileType.INSTANCE.getDefaultExtension());
for (VirtualFile virtualFile : virtualFiles) {
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
PsiModule[] modules = PsiTreeUtil.getChildrenOfType(file, PsiModule.class);
if (modules != null) {
for (PsiModule module : modules) {
if (name.equals(module.getName())) {
result.add(module);
}
}
}
}
return result;
}
示例3: getLayoutFiles
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
public static List<XmlFile> getLayoutFiles(Project project, @Nullable String fileName) {
List<XmlFile> results = new ArrayList<XmlFile>();
Collection<VirtualFile> xmlFiles = FilenameIndex.getAllFilesByExt(project, "xml");
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile xmlFile: xmlFiles) {
if (isLayoutFile(xmlFile)) {
if (fileName != null && !xmlFile.getNameWithoutExtension().equals(fileName)) {
continue;
}
PsiFile file = psiManager.findFile(xmlFile);
if (file != null) {
results.add((XmlFile)file);
}
}
}
return results;
}
示例4: getLayoutFiles
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
public static List<XmlFile> getLayoutFiles(Project project, @Nullable String fileName) {
List<XmlFile> results = new ArrayList<XmlFile>();
Collection<VirtualFile> xmlFiles = FilenameIndex.getAllFilesByExt(project, "xml");
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile xmlFile: xmlFiles) {
if (LayoutUtility.isLayoutFile(xmlFile)) {
if (fileName != null && !xmlFile.getNameWithoutExtension().equals(fileName)) {
continue;
}
PsiFile file = psiManager.findFile(xmlFile);
if (file != null) {
results.add((XmlFile)file);
}
}
}
return results;
}
示例5: getTranslationTargets
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
public static Collection<PsiElement> getTranslationTargets(@NotNull Project project, final @NotNull String translationName) {
final Collection<PsiElement> targets = new ArrayList<PsiElement>();
for (VirtualFile virtualFile : FilenameIndex.getAllFilesByExt(project, "php", GlobalSearchScope.allScope(project))) {
if (!isTranslationFile(virtualFile)) {
continue;
}
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (file != null) {
MetadataUtil.visitTranslationKey(file, new MetadataUtil.TranslationKeyVisitor() {
@Override
public void visit(@NotNull String name, @NotNull PsiElement value) {
if(name.equalsIgnoreCase(translationName)) {
targets.add(value);
}
}
});
}
}
return targets;
}
示例6: getModuleNames
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
@NotNull
public static Set<String> getModuleNames(@NotNull Project project) {
Set<String> allFilesByExt = new HashSet<>();
for (VirtualFile virtualFile : FilenameIndex.getAllFilesByExt(project, "yml")) {
if(!virtualFile.getName().endsWith(".info.yml")) {
continue;
}
allFilesByExt.add(StringUtils.stripEnd(virtualFile.getName(), ".info.yml"));
}
allFilesByExt.addAll(FilenameIndex.getAllFilesByExt(project, "module").stream()
.map(virtualFile -> StringUtils.stripEnd(virtualFile.getName(), ".module"))
.collect(Collectors.toList()));
return allFilesByExt;
}
示例7: getLayoutFiles
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
public static List<PsiFile> getLayoutFiles(Project project) {
List<PsiFile> psiFileList = new ArrayList<PsiFile>();
for (VirtualFile virtualFile : FilenameIndex.getAllFilesByExt(project, "xml")) {
VirtualFile parent = virtualFile.getParent();
if (parent != null && "layout".equals(parent.getName())) {
String relative = VfsUtil.getRelativePath(virtualFile, project.getBaseDir(), '/');
if (relative != null) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFile != null) {
psiFileList.add(psiFile);
}
}
}
}
return psiFileList;
}
示例8: getAllDojoProjectSourceFiles
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
/**
* gets a list of all files that are part of your dojo project sources.
* only retrieves javascript files
*
* @param project
* @return
*/
public Collection<VirtualFile> getAllDojoProjectSourceFiles(Project project)
{
VirtualFile[] sourceDirectories = SourcesLocator.getProjectSourceDirectories(project, true);
List<VirtualFile> files = new ArrayList<VirtualFile>();
for(VirtualFile file : sourceDirectories)
{
files.add(file);
}
Set<VirtualFile> psiFiles = new HashSet<VirtualFile>();
Collection<VirtualFile> results = FilenameIndex.getAllFilesByExt(project, "js", GlobalSearchScope.projectScope(project));
for(VirtualFile result : results)
{
for(VirtualFile directory : sourceDirectories)
{
if(VfsUtilCore.isAncestor(directory, result, false))
{
psiFiles.add(result);
continue;
}
}
}
return results;
}
示例9: getEnumeratedValues
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
@Override
public String[] getEnumeratedValues() {
CatberryProjectConfigurationManager configurationManager = CatberryProjectConfigurationManager.getInstance(project);
if(!configurationManager.isCatberryEnabled())
return ArrayUtil.EMPTY_STRING_ARRAY;
PsiDirectory storesDirectory = configurationManager.getStoresDirectory();
if(storesDirectory == null)
return ArrayUtil.EMPTY_STRING_ARRAY;
final String storesPath = storesDirectory.getVirtualFile().getPath();
GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
Collection<VirtualFile> virtualFiles = FilenameIndex.getAllFilesByExt(project, "js", scope);
List<String> keys = new LinkedList<String>();
PsiManager psiManager = PsiManager.getInstance(project);
for(VirtualFile virtualFile : virtualFiles) {
if(!virtualFile.getPath().startsWith(storesPath))
continue;
String prefix = virtualFile.getPath().substring(storesPath.length(), virtualFile.getPath().lastIndexOf("/"));
if(prefix.startsWith("/"))
prefix = prefix.substring(1);
if(prefix.length() != 0)
prefix += "/";
PsiFile psiFile = psiManager.findFile(virtualFile);
if(psiFile == null)
continue;
for(JSClass jsClass: PsiTreeUtil.findChildrenOfType(psiFile, JSClass.class)) {
keys.add(prefix+jsClass.getName());
}
}
return keys.toArray(new String[keys.size()]);
}
示例10: getTranslationLookupElements
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
public static Collection<LookupElement> getTranslationLookupElements(@NotNull Project project) {
final Set<String> keys = new HashSet<String>();
for (VirtualFile virtualFile : FilenameIndex.getAllFilesByExt(project, "php", GlobalSearchScope.allScope(project))) {
if (!isTranslationFile(virtualFile)) {
continue;
}
PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
if (file != null) {
MetadataUtil.visitTranslationKey(file, new MetadataUtil.TranslationKeyVisitor() {
@Override
public void visit(@NotNull String name, @NotNull PsiElement value) {
keys.add(name);
}
});
}
}
Collection<LookupElement> elements = new ArrayList<LookupElement>();
for (String setting : keys) {
elements.add(LookupElementBuilder.create(setting).withIcon(Symfony2Icons.TRANSLATION));
}
return elements;
}
示例11: addAllByExt
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
private void addAllByExt(Project project, String ext) {
final Set<VirtualFile> imagesFiles = getImagesFiles(project);
final VirtualFile projectDir = project.getBaseDir();
for (VirtualFile file : FilenameIndex.getAllFilesByExt(project, ext)) {
while (file != null && !file.equals(projectDir)) {
imagesFiles.add(file);
file = file.getParent();
}
}
}
示例12: findConceptFiles
import com.intellij.psi.search.FilenameIndex; //導入方法依賴的package包/類
private static VirtualFile[] findConceptFiles(Module module) {
Collection<VirtualFile> conceptFiles = FilenameIndex.getAllFilesByExt(module.getProject(), Constants.CONCEPT_EXTENSION);
return conceptFiles.toArray(new VirtualFile[conceptFiles.size()]);
}