Skip to content

Commit 4efe998

Browse files
committed
Harden IDE: Catch NoSuchFileException
A NoSuchFileException was observed for a non-existing directory on the classpath: /Users/odersky/workspace/dotty/compiler/../out/bootstrap/dotty-compiler-bootstrapped/scala-0.7/classes It was after a dotty-bootstrapped/clean. I believe this should be ignored, or maybe handled with an error message. But certainly not a crash.
1 parent 3365ed3 commit 4efe998

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,24 @@ class InteractiveDriver(settings: List[String]) extends Driver {
148148
val names = new mutable.ListBuffer[String]
149149
dirClassPaths.foreach { dirCp =>
150150
val root = dirCp.dir.toPath
151-
Files.walkFileTree(root, new SimpleFileVisitor[Path] {
152-
override def visitFile(path: Path, attrs: BasicFileAttributes) = {
153-
if (!attrs.isDirectory) {
154-
val name = path.getFileName.toString
155-
for {
156-
tastySuffix <- tastySuffixes
157-
if name.endsWith(tastySuffix)
158-
} {
159-
names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix)
151+
try
152+
Files.walkFileTree(root, new SimpleFileVisitor[Path] {
153+
override def visitFile(path: Path, attrs: BasicFileAttributes) = {
154+
if (!attrs.isDirectory) {
155+
val name = path.getFileName.toString
156+
for {
157+
tastySuffix <- tastySuffixes
158+
if name.endsWith(tastySuffix)
159+
} {
160+
names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix)
161+
}
160162
}
163+
FileVisitResult.CONTINUE
161164
}
162-
FileVisitResult.CONTINUE
163-
}
164-
})
165+
})
166+
catch {
167+
case _: NoSuchFileException =>
168+
}
165169
}
166170
names.toList
167171
}

0 commit comments

Comments
 (0)