@@ -62,6 +62,9 @@ object Interactive {
62
62
sourceSymbol(sym.owner)
63
63
else sym
64
64
65
+ private def safely [T ](default : T )(op : => T ) =
66
+ try op catch { case ex : TypeError => default }
67
+
65
68
/** Possible completions at position `pos` */
66
69
def completions (trees : List [SourceTree ], pos : SourcePosition )(implicit ctx : Context ): List [Symbol ] = {
67
70
val path = pathTo(trees, pos)
@@ -85,16 +88,13 @@ object Interactive {
85
88
}
86
89
87
90
/** Possible completions of members of `prefix` which are accessible when called inside `boundary` */
88
- def completions (prefix : Type , boundary : Symbol )(implicit ctx : Context ): List [Symbol ] = {
89
- val boundaryCtx = ctx.withOwner(boundary)
90
- try
91
+ def completions (prefix : Type , boundary : Symbol )(implicit ctx : Context ): List [Symbol ] =
92
+ safely( Nil ) {
93
+ val boundaryCtx = ctx.withOwner(boundary)
91
94
prefix.memberDenots(completionsFilter, (name, buf) =>
92
95
buf ++= prefix.member(name).altsWith(d => ! d.isAbsent && d.symbol.isAccessibleFrom(prefix)(boundaryCtx))
93
96
).map(_.symbol).toList
94
- catch {
95
- case ex : TypeError => Nil
96
97
}
97
- }
98
98
99
99
/** Filter for names that should appear when looking for completions. */
100
100
private [this ] object completionsFilter extends NameFilter {
@@ -131,7 +131,7 @@ object Interactive {
131
131
* @param includeReferences If true, include references and not just definitions
132
132
*/
133
133
def namedTrees (trees : List [SourceTree ], includeReferences : Boolean , treePredicate : NameTree => Boolean )
134
- (implicit ctx : Context ): List [SourceTree ] = {
134
+ (implicit ctx : Context ): List [SourceTree ] = safely( Nil ) {
135
135
val buf = new mutable.ListBuffer [SourceTree ]
136
136
137
137
trees foreach { case SourceTree (topTree, source) =>
0 commit comments