From 181470d153451c990059509138d20395b406a960 Mon Sep 17 00:00:00 2001 From: Daniel Espendiller Date: Mon, 20 May 2024 15:54:04 +0200 Subject: [PATCH] ignore "Accessing invalid virtual file" errors for project root dir changes --- .../idea/symfony2plugin/routing/RouteHelper.java | 12 ++++++++++-- .../symfony2plugin/translation/TranslationIndex.java | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java index 9a33ce9a7..96f735a04 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java @@ -7,6 +7,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.InvalidVirtualFileAccessException; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; @@ -482,8 +483,15 @@ private static Set getDefaultRoutes(@NotNull Project project) { Set files = new HashSet<>(); // old "app/cache" is ignored for now - VirtualFile cache = VfsUtil.findRelativeFile(projectDir, "var", "cache"); - for (VirtualFile child : cache != null ? cache.getChildren() : new VirtualFile[] {}) { + VirtualFile cache = null; + + try { + cache = VfsUtil.findRelativeFile(projectDir, "var", "cache"); + } catch (InvalidVirtualFileAccessException ignored) { + // "Accessing invalid virtual file" + } + + for (VirtualFile child : (cache != null) ? cache.getChildren() : new VirtualFile[]{}) { String filename = child.getName(); // support "dev" and "dev_*" if ("dev".equals(filename) || filename.startsWith("dev_")) { diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java index 12a9b8b6b..ef27fa461 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java @@ -4,6 +4,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.InvalidVirtualFileAccessException; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; @@ -124,7 +125,13 @@ private static Collection getTranslationRootInner(@NotNull Project project Set caches = new HashSet<>(); for (String root : new String[] {"var/cache", "app/cache"}) { - VirtualFile cache = VfsUtil.findRelativeFile(projectDir, root.split("/")); + VirtualFile cache = null; + try { + cache = VfsUtil.findRelativeFile(projectDir, root.split("/")); + } catch (InvalidVirtualFileAccessException ignored) { + // "Accessing invalid virtual file" + } + if (cache == null) { continue; }