Skip to content

Commit 149255e

Browse files
authored
Merge pull request #2377 from Haehnchen/feature/project-dir
ignore "Accessing invalid virtual file" errors for project root dir changes
2 parents f1894f9 + 181470d commit 149255e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.intellij.openapi.util.Key;
88
import com.intellij.openapi.util.SimpleModificationTracker;
99
import com.intellij.openapi.util.io.FileUtil;
10+
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
1011
import com.intellij.openapi.vfs.VfsUtil;
1112
import com.intellij.openapi.vfs.VirtualFile;
1213
import com.intellij.psi.PsiElement;
@@ -482,8 +483,15 @@ private static Set<String> getDefaultRoutes(@NotNull Project project) {
482483
Set<String> files = new HashSet<>();
483484

484485
// old "app/cache" is ignored for now
485-
VirtualFile cache = VfsUtil.findRelativeFile(projectDir, "var", "cache");
486-
for (VirtualFile child : cache != null ? cache.getChildren() : new VirtualFile[] {}) {
486+
VirtualFile cache = null;
487+
488+
try {
489+
cache = VfsUtil.findRelativeFile(projectDir, "var", "cache");
490+
} catch (InvalidVirtualFileAccessException ignored) {
491+
// "Accessing invalid virtual file"
492+
}
493+
494+
for (VirtualFile child : (cache != null) ? cache.getChildren() : new VirtualFile[]{}) {
487495
String filename = child.getName();
488496
// support "dev" and "dev_*"
489497
if ("dev".equals(filename) || filename.startsWith("dev_")) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.intellij.openapi.util.Key;
55
import com.intellij.openapi.util.SimpleModificationTracker;
66
import com.intellij.openapi.util.io.FileUtil;
7+
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
78
import com.intellij.openapi.vfs.VfsUtil;
89
import com.intellij.openapi.vfs.VfsUtilCore;
910
import com.intellij.openapi.vfs.VirtualFile;
@@ -124,7 +125,13 @@ private static Collection<File> getTranslationRootInner(@NotNull Project project
124125
Set<String> caches = new HashSet<>();
125126

126127
for (String root : new String[] {"var/cache", "app/cache"}) {
127-
VirtualFile cache = VfsUtil.findRelativeFile(projectDir, root.split("/"));
128+
VirtualFile cache = null;
129+
try {
130+
cache = VfsUtil.findRelativeFile(projectDir, root.split("/"));
131+
} catch (InvalidVirtualFileAccessException ignored) {
132+
// "Accessing invalid virtual file"
133+
}
134+
128135
if (cache == null) {
129136
continue;
130137
}

0 commit comments

Comments
 (0)