Skip to content

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

Merged
merged 2 commits into from
Feb 27, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/interactive/Interactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ object Interactive {
if (tree.pos.contains(pos)) {
// FIXME: We shouldn't need a cast. Change NavigateAST.pathTo to return a List of Tree?
val path = NavigateAST.pathTo(pos, tree, skipZeroExtent = true).asInstanceOf[List[untpd.Tree]]
path.dropWhile(!_.hasType).asInstanceOf[List[tpd.Tree]]
path.dropWhile(!_.hasType) collect { case t: tpd.Tree @unchecked => t }
Copy link
Contributor

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 then hasType will also throws. Maybe change NavigateAST.pathTo to discard non-tree element and return a List[Tree] instead (as suggested in the comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Contributor Author

@odersky odersky Feb 21, 2018

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

}
else Nil

Expand All @@ -365,7 +365,7 @@ object Interactive {
case nested :: encl :: rest =>
import typer.Typer._
val outer = contextOfPath(encl :: rest)
encl match {
try encl match {
case tree @ PackageDef(pkg, stats) =>
assert(tree.symbol.exists)
if (nested `eq` pkg) outer
Expand Down Expand Up @@ -401,6 +401,9 @@ object Interactive {
case _ =>
outer
}
catch {
case ex: CyclicReference => outer
}
}

/** The first tree in the path that is a definition. */
Expand Down