Fix IDEA debugger exception. See #307

This commit is contained in:
Alexey Andreev 2018-01-08 14:43:53 +03:00
parent a9beef3a15
commit a24d628603

View File

@ -15,6 +15,7 @@
*/
package org.teavm.idea.debug;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
@ -67,13 +68,17 @@ public class TeaVMExecutionStack extends XExecutionStack {
@Nullable
VirtualFile findVirtualFile(@NotNull String partialPath) {
Stream<VirtualFile> roots = Stream.concat(
Arrays.stream(rootManager.getContentSourceRoots()),
Arrays.stream(rootManager.orderEntries().getAllSourceRoots()));
return roots
.map(sourceRoot -> sourceRoot.findFileByRelativePath(partialPath))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
VirtualFile[] resultHolder = new VirtualFile[1];
ApplicationManager.getApplication().runReadAction(() -> {
Stream<VirtualFile> roots = Stream.concat(
Arrays.stream(rootManager.getContentSourceRoots()),
Arrays.stream(rootManager.orderEntries().getAllSourceRoots()));
resultHolder[0] = roots
.map(sourceRoot -> sourceRoot.findFileByRelativePath(partialPath))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
});
return resultHolder[0];
}
}