當前位置: 首頁>>代碼示例>>Java>>正文


Java FilenameIndex.getAllFilesByExt方法代碼示例

本文整理匯總了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;
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:25,代碼來源:RmlPsiUtil.java

示例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;
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:20,代碼來源:RmlPsiUtil.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:21,代碼來源:LayoutIndex.java

示例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;
}
 
開發者ID:dkvashninbay,項目名稱:magento2plugin,代碼行數:21,代碼來源:LayoutUtility.java

示例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;
    }
 
開發者ID:Haehnchen,項目名稱:idea-php-oxid-plugin,代碼行數:27,代碼來源:TranslationUtil.java

示例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;
}
 
開發者ID:Haehnchen,項目名稱:idea-php-drupal-symfony2-bridge,代碼行數:19,代碼來源:DrupalUtil.java

示例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;
    }
 
開發者ID:Haehnchen,項目名稱:idea-android-studio-plugin,代碼行數:20,代碼來源:AndroidUtils.java

示例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;
}
 
開發者ID:cefolger,項目名稱:needsmoredojo,代碼行數:33,代碼來源:DojoModuleFileResolver.java

示例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()]);
}
 
開發者ID:catberry,項目名稱:catberry-idea-plugin,代碼行數:34,代碼來源:CatberryAttributeDescriptor.java

示例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;
    }
 
開發者ID:Haehnchen,項目名稱:idea-php-oxid-plugin,代碼行數:30,代碼來源:TranslationUtil.java

示例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();
    }
  }
}
 
開發者ID:JetBrains,項目名稱:intellij-sdk-docs,代碼行數:11,代碼來源:ImagesProjectNode.java

示例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()]);
}
 
開發者ID:getgauge,項目名稱:Intellij-Plugin,代碼行數:5,代碼來源:StepUtil.java


注:本文中的com.intellij.psi.search.FilenameIndex.getAllFilesByExt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。