Skip to content

Commit

Permalink
Merge pull request #2328 from Haehnchen/feature/deprecated-file
Browse files Browse the repository at this point in the history
replace deprecated "FilenameIndex.getFilesByName"
  • Loading branch information
Haehnchen authored Apr 1, 2024
2 parents 1993016 + 26d0021 commit 712aa9d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.*;
import fr.adrienbrault.idea.symfony2plugin.util.ProjectUtil;
import fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils;
import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -133,7 +134,8 @@ private static void visitEnvironment(@NotNull Project project, @NotNull Consumer
}
}

for (PsiFile psiFile : FilenameIndex.getFilesByName(project, "docker-compose.yml", GlobalSearchScope.allScope(project))) {
Collection<VirtualFile> virtualFilesByName = FilenameIndex.getVirtualFilesByName("docker-compose.yml", GlobalSearchScope.allScope(project));
for (PsiFile psiFile : PsiElementUtils.convertVirtualFilesToPsiFiles(project, virtualFilesByName)) {
if(!(psiFile instanceof YAMLFile)) {
continue;
}
Expand All @@ -153,7 +155,8 @@ private static void visitEnvironment(@NotNull Project project, @NotNull Consumer
}

for (String file : DOCKER_FILES) {
for (PsiFile psiFile : FilenameIndex.getFilesByName(project, file, GlobalSearchScope.allScope(project))) {
Collection<VirtualFile> virtualFilesByName1 = FilenameIndex.getVirtualFilesByName(file, GlobalSearchScope.allScope(project));
for (PsiFile psiFile : PsiElementUtils.convertVirtualFilesToPsiFiles(project, virtualFilesByName1)) {
// ENV DOCKERFILE_FOO /bar
Matcher matcher = Pattern.compile("ENV\\s+([^\\s]*)\\s+").matcher(psiFile.getText());
while(matcher.find()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
Expand Down Expand Up @@ -92,8 +93,9 @@ public static void visitAttribute(@NotNull Project project, @NotNull Consumer<Pa
}
}

for (String files : new String[]{"security.yml", "security.yaml"}) {
for (PsiFile psiFile : FilenameIndex.getFilesByName(project, files, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), YAMLFileType.YML))) {
for (String fileName : new String[]{"security.yml", "security.yaml"}) {
Collection<VirtualFile> virtualFilesByName = FilenameIndex.getVirtualFilesByName(fileName, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), YAMLFileType.YML));
for (PsiFile psiFile : PsiElementUtils.convertVirtualFilesToPsiFiles(project, virtualFilesByName)) {
if(!(psiFile instanceof YAMLFile)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import fr.adrienbrault.idea.symfony2plugin.templating.dict.TwigConfigJson;
import fr.adrienbrault.idea.symfony2plugin.templating.path.dict.TwigPathJson;
import fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil;
import fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils;
import fr.adrienbrault.idea.symfony2plugin.util.VfsExUtil;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -50,7 +51,8 @@ public Collection<TwigPath> getNamespaces(final @NotNull TwigNamespaceExtensionP
private static Collection<TwigPath> getNamespacesInner(@NotNull Project project) {
Collection<TwigPath> twigPaths = new ArrayList<>();

for (final PsiFile psiFile : FilenameIndex.getFilesByName(project, "ide-twig.json", GlobalSearchScope.allScope(project))) {
@NotNull Collection<VirtualFile> filesByName = FilenameIndex.getVirtualFilesByName("ide-twig.json", GlobalSearchScope.allScope(project));
for (final PsiFile psiFile : PsiElementUtils.convertVirtualFilesToPsiFiles(project, filesByName)) {
Collection<TwigPath> cachedValue = CachedValuesManager.getCachedValue(psiFile, new MyJsonCachedValueProvider(psiFile));
if(cachedValue != null) {
twigPaths.addAll(cachedValue);
Expand Down

0 comments on commit 712aa9d

Please sign in to comment.