Java Code Examples for com.intellij.psi.search.FilenameIndex

The following examples show how to use com.intellij.psi.search.FilenameIndex. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: markdown-image-kit   Source File: AbstractUploadCloudActionTest.java    License: MIT License 6 votes vote down vote up
/**
 * 获取 PSI 的几种方式
 *
 * @param e the e
 */
private void getPsiFile(AnActionEvent e) {
    // 从 action 中获取
    PsiFile psiFileFromAction = e.getData(LangDataKeys.PSI_FILE);
    Project project = e.getProject();
    if (project != null) {
        VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
        if (virtualFile != null) {
            // 从 VirtualFile 获取
            PsiFile psiFileFromVirtualFile = PsiManager.getInstance(project).findFile(virtualFile);

            // 从 document
            Document documentFromEditor = Objects.requireNonNull(e.getData(PlatformDataKeys.EDITOR)).getDocument();
            PsiFile psiFileFromDocument = PsiDocumentManager.getInstance(project).getPsiFile(documentFromEditor);

            // 在 project 范围内查找特定 PsiFile
            FilenameIndex.getFilesByName(project, "fileName", GlobalSearchScope.projectScope(project));
        }
    }

    // 找到特定 PSI 元素的使用位置
    // ReferencesSearch.search();
}
 
Example 2
Source Project: IntelliJDeodorant   Source File: GodClassDistanceMatrixTest.java    License: MIT License 6 votes vote down vote up
@Nullable
private ExtractClassCandidateGroup getExractClassCandidateGroup(@NotNull String classFileName) {
    myFixture.setTestDataPath(PATH_TO_TESTDATA);
    myFixture.configureByFile(PATH_TO_TESTS + classFileName);
    Project project = myFixture.getProject();
    PsiFile psiFile = FilenameIndex.getFilesByName(project, classFileName, GlobalSearchScope.allScope(project))[0];
    ProjectInfo projectInfo = new ProjectInfo(new AnalysisScope(project), false);

    Set<ExtractClassCandidateGroup> set = getExtractClassRefactoringOpportunities(projectInfo, new ProgressIndicatorBase());

    if (set.isEmpty()) {
        return null;
    }

    return set.iterator().next();
}
 
Example 3
Source Project: reasonml-idea-plugin   Source File: ORFileManager.java    License: MIT License 6 votes vote down vote up
@Nullable
public static PsiFile findCmtFileFromSource(@NotNull Project project, @NotNull String filenameWithoutExtension) {
    if (!DumbService.isDumb(project)) {
        GlobalSearchScope scope = GlobalSearchScope.allScope(project);
        String filename = filenameWithoutExtension + ".cmt";

        PsiFile[] cmtFiles = FilenameIndex.getFilesByName(project, filename, scope);
        if (cmtFiles.length == 0) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("File module for " + filename + " is NOT FOUND, files found: [" + Joiner.join(", ", cmtFiles) + "]");
            }
            return null;
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Found cmt " + filename + " (" + cmtFiles[0].getVirtualFile().getPath() + ")");
        }

        return cmtFiles[0];
    } else {
        LOG.info("Cant find cmt while reindexing");
    }

    return null;
}
 
Example 4
Source Project: reasonml-idea-plugin   Source File: ORProjectManagerTest.java    License: MIT License 6 votes vote down vote up
@Test
public void testFindBsConfigurationFiles_sortedByFileDepth() {
    String mockFileName = BsConstants.BS_CONFIG_FILENAME;
    MockVirtualFile mockBsConfigFileParent = new MockVirtualFile(mockFileName);
    MockVirtualFile mockBsConfigFile = new MockVirtualFile(mockFileName);
    MockVirtualFile mockBsConfigFileChild = new MockVirtualFile(mockFileName);
    // set up mock file hierarchy
    mockBsConfigFile.setParent(mockBsConfigFileParent);
    mockBsConfigFileChild.setParent(mockBsConfigFile);

    MockVirtualFile[] mocksUnsorted = { mockBsConfigFile, mockBsConfigFileChild, mockBsConfigFileParent };
    MockVirtualFile[] mocksSorted = { mockBsConfigFileParent, mockBsConfigFile, mockBsConfigFileChild };

    when(FilenameIndex.getVirtualFilesByName(mockProject, mockFileName, mockScope))
            .thenReturn(Arrays.asList(mocksUnsorted));

    LinkedHashSet<VirtualFile> bsConfigurationFiles = ORProjectManager.findBsConfigurationFiles(mockProject);
    assertMocksSorted(bsConfigurationFiles, mocksSorted);
}
 
Example 5
Source Project: reasonml-idea-plugin   Source File: ORProjectManagerTest.java    License: MIT License 6 votes vote down vote up
@Test
public void testFindDuneConfigurationFiles_sortedByFileDepth() {
    String mockFileName = DuneConstants.DUNE_FILENAME;
    MockVirtualFile mockDuneFileParent = new MockVirtualFile(mockFileName);
    MockVirtualFile mockDuneFile = new MockVirtualFile(mockFileName);
    MockVirtualFile mockDuneFileChild = new MockVirtualFile(mockFileName);
    // set up mock file hierarchy
    mockDuneFile.setParent(mockDuneFileParent);
    mockDuneFileChild.setParent(mockDuneFile);

    MockVirtualFile[] mocksUnsorted = { mockDuneFile, mockDuneFileChild, mockDuneFileParent };
    MockVirtualFile[] mocksSorted = { mockDuneFileParent, mockDuneFile, mockDuneFileChild };

    when(FilenameIndex.getVirtualFilesByName(mockProject, mockFileName, mockScope))
            .thenReturn(Arrays.asList(mocksUnsorted));

    LinkedHashSet<VirtualFile> duneConfigurationFiles = ORProjectManager.findDuneConfigurationFiles(mockProject);
    assertMocksSorted(duneConfigurationFiles, mocksSorted);
}
 
Example 6
Source Project: reasonml-idea-plugin   Source File: ORProjectManagerTest.java    License: MIT License 6 votes vote down vote up
@Test
public void testFindEsyConfigurationFiles_sortedByFileDepth() {
    String mockFileName = EsyConstants.ESY_CONFIG_FILENAME;
    MockVirtualFile mockEsyConfigFileParent = new MockVirtualFile(mockFileName);
    MockVirtualFile mockEsyConfigFile = new MockVirtualFile(mockFileName);
    MockVirtualFile mockEsyConfigFileChild = new MockVirtualFile(mockFileName);
    // set up mock file hierarchy
    mockEsyConfigFile.setParent(mockEsyConfigFileParent);
    mockEsyConfigFileChild.setParent(mockEsyConfigFile);

    MockVirtualFile[] mocksUnsorted = { mockEsyConfigFile, mockEsyConfigFileChild, mockEsyConfigFileParent };
    MockVirtualFile[] mocksSorted = { mockEsyConfigFileParent, mockEsyConfigFile, mockEsyConfigFileChild };

    when(FilenameIndex.getVirtualFilesByName(mockProject, mockFileName, mockScope))
            .thenReturn(Arrays.asList(mocksUnsorted));

    when(EsyPackageJson.isEsyPackageJson(any())).thenReturn(true);

    LinkedHashSet<VirtualFile> esyConfigurationFiles = ORProjectManager.findEsyConfigurationFiles(mockProject);
    assertMocksSorted(esyConfigurationFiles, mocksSorted);
}
 
Example 7
Source Project: idea-php-typo3-plugin   Source File: DeprecationUtility.java    License: MIT License 6 votes vote down vote up
public static Set<String> getDeprecatedConstantNames(@NotNull Project project) {
    Set<String> deprecatedConstants = new HashSet<>();

    PsiFile[] constantMatcherFiles = FilenameIndex.getFilesByName(project, "ConstantMatcher.php", GlobalSearchScope.allScope(project));
    for (PsiFile file : constantMatcherFiles) {

        deprecatedConstants.addAll(CachedValuesManager.getManager(project).getCachedValue(
            file,
            DEPRECATED_CONSTANTS,
            () -> CachedValueProvider.Result.create(getDeprecatedConstantNamesFromFile(file), PsiModificationTracker.MODIFICATION_COUNT),
            false
        ));

    }

    return deprecatedConstants;
}
 
Example 8
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext processingContext) {
    PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
    String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
    String key = NutzInjectConfUtil.getKey(value);
    if (NutzInjectConfUtil.isInjectConf(literalExpression) && key != null) {
        Project project = element.getProject();
        final Collection<VirtualFile> propertiesFiles = FilenameIndex.getAllFilesByExt(project, "properties", getSearchScope(project, element));
        final List<PsiElement> properties = NutzInjectConfUtil.findPropertiesPsiElement(project, propertiesFiles, key);
        List<PsiReference> psiReferences = new ArrayList<>();
        properties.forEach(psiElement -> psiReferences.add(new PsiJavaInjectReference(element, psiElement)));
        return psiReferences.toArray(new PsiReference[0]);
    } else {
        return PsiReference.EMPTY_ARRAY;
    }
}
 
Example 9
@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;
}
 
Example 10
Source Project: mule-intellij-plugins   Source File: MuleSchemaProvider.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 11
Source Project: BashSupport   Source File: SmartBashFileReference.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public PsiElement resolveInner() {
    final String referencedName = cmd.getReferencedCommandName();
    if (referencedName == null) {
        return null;
    }

    String fileName = PathUtil.getFileName(referencedName);
    GlobalSearchScope scope = BashSearchScopes.moduleScope(cmd.getContainingFile());

    PsiFileSystemItem[] files = FilenameIndex.getFilesByName(cmd.getProject(), fileName, scope, false);
    if (files.length == 0) {
        return null;
    }

    PsiFile currentFile = cmd.getContainingFile();
    return BashPsiFileUtils.findRelativeFile(currentFile, referencedName);
}
 
Example 12
Source Project: idea-php-drupal-symfony2-bridge   Source File: DrupalUtil.java    License: MIT License 6 votes vote down vote up
@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;
}
 
Example 13
@Nullable
public static PsiFile findXmlResource(@Nullable PsiReferenceExpression referenceExpression) {
    if (referenceExpression == null) return null;

    PsiElement firstChild = referenceExpression.getFirstChild();
    if (firstChild == null || !"R.layout".equals(firstChild.getText())) {
        return null;
    }

    PsiElement lastChild = referenceExpression.getLastChild();
    if(lastChild == null) {
        return null;
    }

    String name = String.format("%s.xml", lastChild.getText());
    PsiFile[] foundFiles = FilenameIndex.getFilesByName(referenceExpression.getProject(), name, GlobalSearchScope.allScope(referenceExpression.getProject()));
    if (foundFiles.length <= 0) {
        return null;
    }

    return foundFiles[0];
}
 
Example 14
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;
    }
 
Example 15
@Nullable
public static PsiFile findXmlResource(Project project, String layoutName) {

    if (!layoutName.startsWith("R.layout.")) {
        return null;
    }

    layoutName = layoutName.substring("R.layout.".length());

    String name = String.format("%s.xml", layoutName);
    PsiFile[] foundFiles = FilenameIndex.getFilesByName(project, name, GlobalSearchScope.allScope(project));
    if (foundFiles.length <= 0) {
        return null;
    }

    return foundFiles[0];
}
 
Example 16
Source Project: intellij-xquery   Source File: XQueryModuleReferenceTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testRenameOfTheFileWithReference() {
    myFixture.configureByFiles("ModuleReference.xq", "ModuleReference_ReferencedModule.xq");
    PsiFile[] files = FilenameIndex.getFilesByName(myFixture.getProject(), "ModuleReference_ReferencedModule.xq",
            GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(myFixture.getProject()),
                    XQueryFileType
                            .INSTANCE));

    myFixture.renameElement(files[0], "ModuleReference_RenamedFile.xq");
    myFixture.checkResultByFile("ModuleReference.xq", "ModuleReferenceAfterRenameOfReferencedFile.xq", false);
    PsiFile[] filesAfterRename = FilenameIndex.getFilesByName(myFixture.getProject(),
            "ModuleReference_RenamedFile.xq",
            GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(myFixture.getProject()),
                    XQueryFileType
                            .INSTANCE));
    assertEquals(1, files.length);
    assertNotNull(filesAfterRename[0]);
}
 
Example 17
Source Project: needsmoredojo   Source File: DojoModuleFileResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source Project: needsmoredojo   Source File: DojoModuleFileResolver.java    License: Apache License 2.0 6 votes vote down vote up
public Set<String> getDirectoriesForDojoModules(Project project, Set<String> modules)
{
    Set<String> possibleDirectories = new HashSet<String>();

    for(String module : modules)
    {
        String moduleParent = module;

        if(module.contains("/"))
        {
            module = module.substring(module.lastIndexOf("/") + 1);
        }

        PsiFile[] files = FilenameIndex.getFilesByName(project, module + ".js", GlobalSearchScope.projectScope(project));

        for(PsiFile file : files)
        {
            if( file.getVirtualFile().getCanonicalPath().contains(moduleParent))
            {
                possibleDirectories.add(file.getParent().getParent().getName() +  " (" + file.getParent().getParent().getVirtualFile().getCanonicalPath() + ")");
            }
        }
    }

    return possibleDirectories;
}
 
Example 19
Source Project: consulo   Source File: PsiPatchBaseDirectoryDetector.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 20
Source Project: consulo   Source File: PsiViewerDialog.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 21
Source Project: consulo   Source File: DefaultFileNavigationContributor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> _processor, @Nonnull FindSymbolParameters parameters) {
  final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries();
  final Processor<PsiFileSystemItem> processor = item -> {
    if (!globalSearch && ProjectCoreUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) {
      return true;
    }
    return _processor.process(item);
  };

  boolean directoriesOnly = isDirectoryOnlyPattern(parameters);
  if (!directoriesOnly) {
    FilenameIndex.processFilesByName(name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }

  if (directoriesOnly || Registry.is("ide.goto.file.include.directories")) {
    FilenameIndex.processFilesByName(name, true, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }
}
 
Example 22
Source Project: lsp4intellij   Source File: FileUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static PsiFile[] searchFiles(String fileName, Project p) {
    try {
        return computableReadAction(() -> FilenameIndex.getFilesByName(p, fileName, GlobalSearchScope.projectScope(p)));
    } catch (Throwable t) {
        // Todo - Find a proper way to handle when IDEA file indexing is in-progress.
        return new PsiFile[0];
    }
}
 
Example 23
Source Project: markdown-image-kit   Source File: UploadUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Search virtual file by name virtual file.
 *
 * @param project the project
 * @param name    the name
 * @return the virtual file
 */
public static VirtualFile searchVirtualFileByName(Project project, String name) {
    // Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
    AtomicReference<Collection<VirtualFile>> findedFiles = new AtomicReference<>();
    ApplicationManager.getApplication().runReadAction(() -> {
        findedFiles.set(FilenameIndex.getVirtualFilesByName(project, name, GlobalSearchScope.allScope(project)));
    });

    // 只取第一个图片
    return Iterables.getFirst(findedFiles.get(), null);
}
 
Example 24
Source Project: Thinkphp5-Plugin   Source File: ViewCollector.java    License: MIT License 5 votes vote down vote up
private static void collectIdeJsonBladePaths(@NotNull Project project, @NotNull Collection<TemplatePath> templatePaths) {
    for (PsiFile psiFile : FilenameIndex.getFilesByName(project, "ide-blade.json", GlobalSearchScope.allScope(project))) {
        Collection<TemplatePath> cachedValue = CachedValuesManager.getCachedValue(psiFile, new MyJsonCachedValueProvider(psiFile));
        if (cachedValue != null) {
            templatePaths.addAll(cachedValue);
        }
    }
}
 
Example 25
Source Project: reasonml-idea-plugin   Source File: ORFileUtilsTest.java    License: MIT License 5 votes vote down vote up
@Before
public void setUp() {
    initMocks(this);
    mockStatic(ID.class);
    mockStatic(EsyPackageJson.class);
    mockStatic(FilenameIndex.class);
    mockStatic(GlobalSearchScope.class);
    when(GlobalSearchScope.allScope(mockProject)).thenReturn(mockScope);
}
 
Example 26
Source Project: reasonml-idea-plugin   Source File: ORProjectManagerTest.java    License: MIT License 5 votes vote down vote up
@Before
public void setUp() {
    initMocks(this);
    mockStatic(ID.class);
    when(ID.create(any())).thenReturn(null);
    mockStatic(EsyPackageJson.class);
    mockStatic(FilenameIndex.class);
    mockStatic(GlobalSearchScope.class);
    when(GlobalSearchScope.allScope(mockProject)).thenReturn(mockScope);
}
 
Example 27
Source Project: reasonml-idea-plugin   Source File: ORProjectManagerTest.java    License: MIT License 5 votes vote down vote up
@Test
public void testIsModuleNoMatches() {
    when(FilenameIndex.getVirtualFilesByName(any(), any(), any())).thenReturn(Collections.emptyList());
    assertFalse(ORProjectManager.isBsProject(mockProject));
    assertFalse(ORProjectManager.isDuneProject(mockProject));
    assertFalse(ORProjectManager.isEsyProject(mockProject));
}
 
Example 28
@NotNull
@Override
public Collection<FluidNamespace> provideForElement(@NotNull PsiElement element) {
    PsiFile[] filesByName = FilenameIndex.getFilesByName(element.getProject(), "ext_localconf.php", GlobalSearchScope.allScope(element.getProject()));

    return ContainerUtil.emptyList();
}
 
Example 29
Source Project: idea-php-typo3-plugin   Source File: DeprecationUtility.java    License: MIT License 5 votes vote down vote up
public static Set<String> getDeprecatedClassConstants(@NotNull Project project) {
    Set<String> constants = new HashSet<>();
    PsiFile[] classConstantMatcherFiles = FilenameIndex.getFilesByName(project, "ClassConstantMatcher.php", GlobalSearchScope.allScope(project));
    for (PsiFile file : classConstantMatcherFiles) {
        constants.addAll(CachedValuesManager.getManager(project).getCachedValue(
            file,
            DEPRECATED_CLASS_CONSTANTS,
            () -> CachedValueProvider.Result.create(getDeprecatedClassConstantsFromFile(file), PsiModificationTracker.MODIFICATION_COUNT),
            false
        ));
    }

    return constants;
}
 
Example 30
Source Project: idea-php-typo3-plugin   Source File: DeprecationUtility.java    License: MIT License 5 votes vote down vote up
public static Set<String> getDeprecatedClassNames(@NotNull Project project) {
    Set<String> classNames = new HashSet<>();

    PsiFile[] classNameMatcherFiles = FilenameIndex.getFilesByName(project, "ClassNameMatcher.php", GlobalSearchScope.allScope(project));
    for (PsiFile file : classNameMatcherFiles) {
        classNames.addAll(CachedValuesManager.getManager(project).getCachedValue(
            file,
            DEPRECATED_CLASSES,
            () -> CachedValueProvider.Result.create(getDeprecatedClassNamesFromFile(file), PsiModificationTracker.MODIFICATION_COUNT),
            false
        ));
    }

    return classNames;
}