-
Notifications
You must be signed in to change notification settings - Fork 1.1k
More IDE work #2885
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
More IDE work #2885
Changes from all commits
442915b
2cb53d9
221320f
49fd9bd
2f6cb08
0a8a2a3
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 |
---|---|---|
|
@@ -62,6 +62,9 @@ object Interactive { | |
sourceSymbol(sym.owner) | ||
else sym | ||
|
||
private def safely[T](op: => List[T]): List[T] = | ||
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. Mark it |
||
try op catch { case ex: TypeError => Nil } | ||
|
||
/** Possible completions at position `pos` */ | ||
def completions(trees: List[SourceTree], pos: SourcePosition)(implicit ctx: Context): List[Symbol] = { | ||
val path = pathTo(trees, pos) | ||
|
@@ -85,16 +88,13 @@ object Interactive { | |
} | ||
|
||
/** Possible completions of members of `prefix` which are accessible when called inside `boundary` */ | ||
def completions(prefix: Type, boundary: Symbol)(implicit ctx: Context): List[Symbol] = { | ||
val boundaryCtx = ctx.withOwner(boundary) | ||
try | ||
def completions(prefix: Type, boundary: Symbol)(implicit ctx: Context): List[Symbol] = | ||
safely { | ||
val boundaryCtx = ctx.withOwner(boundary) | ||
prefix.memberDenots(completionsFilter, (name, buf) => | ||
buf ++= prefix.member(name).altsWith(d => !d.isAbsent && d.symbol.isAccessibleFrom(prefix)(boundaryCtx)) | ||
).map(_.symbol).toList | ||
catch { | ||
case ex: TypeError => Nil | ||
} | ||
} | ||
|
||
/** Filter for names that should appear when looking for completions. */ | ||
private[this] object completionsFilter extends NameFilter { | ||
|
@@ -131,7 +131,7 @@ object Interactive { | |
* @param includeReferences If true, include references and not just definitions | ||
*/ | ||
def namedTrees(trees: List[SourceTree], includeReferences: Boolean, treePredicate: NameTree => Boolean) | ||
(implicit ctx: Context): List[SourceTree] = { | ||
(implicit ctx: Context): List[SourceTree] = safely { | ||
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. It's a bit of a shame that this means we'll discard all results when the problem might be localized. Alternatively, we could move the try/catch around 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. I think it's pretty rare that we would get a TypeError, so not a big deal either way. |
||
val buf = new mutable.ListBuffer[SourceTree] | ||
|
||
trees foreach { case SourceTree(topTree, source) => | ||
|
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.
It's suspicious that a
Context => Tree
function would capture a Context.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.
Oh actually I guess this is intentional: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/typer/Inliner.scala#L193