-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Harden IDE: Catch NoSuchFileException #4002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,20 +148,24 @@ class InteractiveDriver(settings: List[String]) extends Driver { | |
val names = new mutable.ListBuffer[String] | ||
dirClassPaths.foreach { dirCp => | ||
val root = dirCp.dir.toPath | ||
Files.walkFileTree(root, new SimpleFileVisitor[Path] { | ||
override def visitFile(path: Path, attrs: BasicFileAttributes) = { | ||
if (!attrs.isDirectory) { | ||
val name = path.getFileName.toString | ||
for { | ||
tastySuffix <- tastySuffixes | ||
if name.endsWith(tastySuffix) | ||
} { | ||
names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix) | ||
try | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Files.walkFileTree(root, new SimpleFileVisitor[Path] { | ||
override def visitFile(path: Path, attrs: BasicFileAttributes) = { | ||
if (!attrs.isDirectory) { | ||
val name = path.getFileName.toString | ||
for { | ||
tastySuffix <- tastySuffixes | ||
if name.endsWith(tastySuffix) | ||
} { | ||
names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix) | ||
} | ||
} | ||
FileVisitResult.CONTINUE | ||
} | ||
FileVisitResult.CONTINUE | ||
} | ||
}) | ||
}) | ||
catch { | ||
case _: NoSuchFileException => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should emit an error or warning. If we don't add it in this PR we might have silent failures that are impossible to debug. |
||
} | ||
} | ||
names.toList | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
path
can contain non-tree elements thenhasType
will also throws. Maybe changeNavigateAST.pathTo
to discard non-tree element and return aList[Tree]
instead (as suggested in the comment).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the change on the other PR #3967