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


Java FilenameIndex類代碼示例

本文整理匯總了Java中com.intellij.psi.search.FilenameIndex的典型用法代碼示例。如果您正苦於以下問題:Java FilenameIndex類的具體用法?Java FilenameIndex怎麽用?Java FilenameIndex使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FilenameIndex類屬於com.intellij.psi.search包,在下文中一共展示了FilenameIndex類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getRemovedConstantsFQNs

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
private Set<String> getRemovedConstantsFQNs(ConstantReference element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] constantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ConstantMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : constantMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream()
            .map(stringLiteral -> "\\" + ((StringLiteralExpression)stringLiteral).getContents())
            .collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:26,代碼來源:ConstantMatcherInspection.java

示例4: getRemovedGlobalFuntions

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
private Set<String> getRemovedGlobalFuntions(PhpPsiElement element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] constantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "FunctionCallMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : constantMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream()
            .map(stringLiteral -> "\\" + ((StringLiteralExpression) stringLiteral).getContents())
            .collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:26,代碼來源:FunctionCallMatcherInspection.java

示例5: getDeprecatedClassConstants

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
private Set<String> getDeprecatedClassConstants(PhpPsiElement element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] classConstantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ClassConstantMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : classConstantMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream().map(stringLiteral -> ((StringLiteralExpression)stringLiteral).getContents()).collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:24,代碼來源:ClassConstantMatcherInspection.java

示例6: getDeprecatedClasses

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
private Set<String> getDeprecatedClasses(PhpPsiElement element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] classNameMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ClassNameMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : classNameMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream()
            .map(stringLiteral -> "\\" + ((StringLiteralExpression)stringLiteral).getContents())
            .collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:26,代碼來源:ClassNameMatcherInspection.java

示例7: 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

示例8: applyFilter

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
@Nullable
@Override
public Result applyFilter(String textLine, int endPoint)
{
    final Matcher matcher = ELEMENT_REGEX.matcher(textLine);
    if (matcher.find())
    {
        final String element = matcher.group(1);
        final String fileName = matcher.group(4);
        final String lineNumber = matcher.group(5);
        final PsiFile[] psiFiles = FilenameIndex.getFilesByName(myProject, fileName, GlobalSearchScope.allScope(myProject));
        if (psiFiles.length == 0)
        {
            logger.debug("File: " + fileName + " not found in project: " + myProject.getName());
            return null;
        }
        else
        {
            HyperlinkInfo info = new OpenFileHyperlinkInfo(myProject, psiFiles[0].getVirtualFile(), Integer.parseInt(lineNumber) - 1);
            return new Result(endPoint - (textLine.length() - element.length()), endPoint, info);
        }
    }
    return null;
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:25,代碼來源:ConsoleFlowStackFilter.java

示例9: getSchemasFromSpringSchemas

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
private Map<String, String> getSchemasFromSpringSchemas(@NotNull Module module) throws Exception {
    Map<String, String> schemasMap = new HashMap<>();

    PsiFile[] psiFiles = FilenameIndex.getFilesByName(module.getProject(), "spring.schemas", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));

    for (PsiFile nextSpringS : psiFiles) {
        VirtualFile springSchemasFile = nextSpringS.getVirtualFile();
        if (springSchemasFile != null) {
            String springSchemasContent = new String(springSchemasFile.contentsToByteArray());
            schemasMap.putAll(parseSpringSchemas(springSchemasContent));
        }
    }

    //Fix for HTTP module schema vs old HTTP transport schema
    schemasMap.put("http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd", "META-INF/mule-httpn.xsd");

    return schemasMap;
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:19,代碼來源:MuleSchemaProvider.java

示例10: findComponents

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
@NotNull
public static Map<String, PsiFile> findComponents(@NotNull final Project project) {
  Map<String, PsiFile> result = new HashMap<String, PsiFile>();
  Collection<VirtualFile> virtualFiles =
      FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, CatberryConstants.CAT_COMPONENT_JSON,
          GlobalSearchScope.allScope(project));
  for (VirtualFile virtualFile : virtualFiles) {
    JsonFile psiFile = (JsonFile) PsiManager.getInstance(project).findFile(virtualFile);
    if (psiFile != null) {
      JsonProperty[] properties = PsiTreeUtil.getChildrenOfType(psiFile.getTopLevelValue(), JsonProperty.class);
      if (properties != null) {
        for (JsonProperty property : properties) {
          if (!property.getName().equals("name"))
            continue;
          if (property.getValue() != null && property.getValue() instanceof JsonStringLiteral)
            result.put(((JsonStringLiteral) property.getValue()).getValue(), psiFile);
          break;
        }
      }
    }
  }
  return result;
}
 
開發者ID:catberry,項目名稱:catberry-idea-plugin,代碼行數:24,代碼來源:CatberryComponentUtils.java

示例11: findTestsForClass

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
@NotNull
@Override
public Collection<PsiElement> findTestsForClass(@NotNull PsiElement psiElement) {
    Collection<PsiElement> tests = new ArrayList<>();

    PhpClass phpClass = PsiTreeUtil.getStubOrPsiParentOfType(psiElement, PhpClass.class);
    if (phpClass != null) {
        Project project = phpClass.getProject();
        Collection<PhpClass> testClasses = PhpIndex.getInstance(project).getClassesByName(phpClass.getName() + "Test");
        if (!testClasses.isEmpty()) {
            tests.addAll(testClasses);
        }

        PsiFile[] files = FilenameIndex.getFilesByName(project, phpClass.getName() + ".phpt", GlobalSearchScope.projectScope(project));
        tests.addAll(Arrays.asList(files));
    }

    return tests;
}
 
開發者ID:jiripudil,項目名稱:intellij-nette-tester,代碼行數:20,代碼來源:TesterTestFinder.java

示例12: detectBaseDirectory

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
@Override
@Nullable
public Result detectBaseDirectory(final String patchFileName) {
  String[] nameComponents = patchFileName.split("/");
  String patchName = nameComponents[nameComponents.length - 1];
  if (patchName.isEmpty()) {
    return null;
  }
  final PsiFile[] psiFiles = FilenameIndex.getFilesByName(myProject, patchName, GlobalSearchScope.projectScope(myProject));
  if (psiFiles.length == 1) {
    PsiDirectory parent = psiFiles [0].getContainingDirectory();
    for(int i=nameComponents.length-2; i >= 0; i--) {
      if (!parent.getName().equals(nameComponents[i]) || Comparing.equal(parent.getVirtualFile(), myProject.getBaseDir())) {
        return new Result(parent.getVirtualFile().getPresentableUrl(), i+1);
      }
      parent = parent.getParentDirectory();
    }
    if (parent == null) return null;
    return new Result(parent.getVirtualFile().getPresentableUrl(), 0);
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:PsiPatchBaseDirectoryDetector.java

示例13: getContainingFileForClass

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
@Nullable
private PsiFile getContainingFileForClass(String fqn) {
  String filename = fqn;
  if (fqn.contains(".")) {
    filename = fqn.substring(fqn.lastIndexOf('.') + 1);
  }
  if (filename.contains("$")) {
    filename = filename.substring(0, filename.indexOf('$'));
  }
  filename += ".java";
  final PsiFile[] files = FilenameIndex.getFilesByName(myProject, filename, GlobalSearchScope.allScope(myProject));
  if (files != null && files.length > 0) {
    return files[0];
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:PsiViewerDialog.java

示例14: getNames

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
@Override
@NotNull
public String[] getNames(Project project, boolean includeNonProjectItems) {
  if (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping) {
    final THashSet<String> names = new THashSet<String>(1000);
    IdFilter filter = IdFilter.getProjectIdFilter(project, includeNonProjectItems);
    processNames(new Processor<String>() {
      @Override
      public boolean process(String s) {
        names.add(s);
        return true;
      }
    }, FindSymbolParameters.searchScopeFor(project, includeNonProjectItems), filter);
    if (IdFilter.LOG.isDebugEnabled()) {
      IdFilter.LOG.debug("All names retrieved2:" + names.size());
    }
    return ArrayUtil.toStringArray(names);
  } else {
    return FilenameIndex.getAllFilenames(project);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:DefaultFileNavigationContributor.java

示例15: findImportableModules

import com.intellij.psi.search.FilenameIndex; //導入依賴的package包/類
private static Collection<PsiElement> findImportableModules(PsiFile targetFile, String reftext, Project project, GlobalSearchScope scope) {
  List<PsiElement> result = new ArrayList<PsiElement>();
  PsiFile[] files = FilenameIndex.getFilesByName(project, reftext + ".py", scope);
  for (PsiFile file : files) {
    if (isImportableModule(targetFile, file)) {
      result.add(file);
    }
  }
  // perhaps the module is a directory, not a file
  PsiFile[] initFiles = FilenameIndex.getFilesByName(project, PyNames.INIT_DOT_PY, scope);
  for (PsiFile initFile : initFiles) {
    PsiDirectory parent = initFile.getParent();
    if (parent != null && parent.getName().equals(reftext)) {
      result.add(parent);
    }
  }
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:PythonReferenceImporter.java


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