Skip to content

Commit 03517fd

Browse files
#30: Do not log error if WebCore resource roots cannot be loaded
Logging error created a dialog for user to send report to plugin author.
1 parent a72282a commit 03517fd

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/main/java/io/protostuff/jetbrains/plugin/reference/file/WebCoreResourcePathRootsProvider.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,26 @@ class WebCoreResourcePathRootsProvider implements FilePathReferenceProvider.Sour
5050
public VirtualFile[] getSourceRoots(Module module) {
5151
try {
5252
if (GET_INSTANCE != null && GET_RESOURCE_ROOTS != null) {
53-
List<VirtualFile> result = new ArrayList<>();
5453
Object configurationInstance = GET_INSTANCE.invoke(null, module.getProject());
55-
MultiMap<String, String> resourceRoots = (MultiMap<String, String>) GET_RESOURCE_ROOTS.invoke(configurationInstance);
56-
for (Map.Entry<String, Collection<String>> entry : resourceRoots.entrySet()) {
57-
for (String uri : entry.getValue()) {
58-
if (!Strings.isNullOrEmpty(uri) && uri.startsWith("file://")) {
59-
String path = uri.substring(7);
60-
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
61-
if (file != null && file.isDirectory()) {
62-
result.add(file);
54+
if (configurationInstance != null) {
55+
List<VirtualFile> result = new ArrayList<>();
56+
MultiMap<String, String> resourceRoots = (MultiMap<String, String>) GET_RESOURCE_ROOTS.invoke(configurationInstance);
57+
for (Map.Entry<String, Collection<String>> entry : resourceRoots.entrySet()) {
58+
for (String uri : entry.getValue()) {
59+
if (!Strings.isNullOrEmpty(uri) && uri.startsWith("file://")) {
60+
String path = uri.substring(7);
61+
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
62+
if (file != null && file.isDirectory()) {
63+
result.add(file);
64+
}
6365
}
6466
}
6567
}
68+
return result.toArray(new VirtualFile[0]);
6669
}
67-
return result.toArray(new VirtualFile[0]);
6870
}
6971
} catch (Exception e) {
70-
LOGGER.error("Could not get source roots for WebCore IDE", e);
72+
LOGGER.warn("Could not get source roots for WebCore IDE", e);
7173
}
7274
return new VirtualFile[0];
7375
}

0 commit comments

Comments
 (0)