@@ -29,7 +29,6 @@ object Interactive {
29
29
val definitions : Int = 8 // include definitions
30
30
val linkedClass : Int = 16 // include `symbol.linkedClass`
31
31
val imports : Int = 32 // include imports in the results
32
- val renamingImports : Int = 64 // Include renamed symbols and renaming part of imports in the results
33
32
}
34
33
35
34
/** Does this tree define a symbol ? */
@@ -302,7 +301,6 @@ object Interactive {
302
301
(implicit ctx : Context ): List [SourceNamedTree ] = safely {
303
302
val includeReferences = (include & Include .references) != 0
304
303
val includeImports = (include & Include .imports) != 0
305
- val includeRenamingImports = (include & Include .renamingImports) != 0
306
304
val buf = new mutable.ListBuffer [SourceNamedTree ]
307
305
308
306
def traverser (source : SourceFile ) = {
@@ -340,30 +338,31 @@ object Interactive {
340
338
/**
341
339
* Find trees that match `symbol` in `trees`.
342
340
*
343
- * @param trees The trees to inspect.
344
- * @param includes Whether to include references, definitions, etc.
345
- * @param symbol The symbol for which we want to find references.
341
+ * @param trees The trees to inspect.
342
+ * @param includes Whether to include references, definitions, etc.
343
+ * @param symbol The symbol for which we want to find references.
344
+ * @param predicate An additional predicate that the trees must match.
346
345
*/
347
346
def findTreesMatching (trees : List [SourceTree ],
348
347
includes : Include .Set ,
349
- symbol : Symbol )(implicit ctx : Context ): List [SourceNamedTree ] = {
348
+ symbol : Symbol ,
349
+ predicate : NameTree => Boolean = util.common.alwaysTrue
350
+ )(implicit ctx : Context ): List [SourceNamedTree ] = {
350
351
val linkedSym = symbol.linkedClass
351
352
val includeDeclaration = (includes & Include .definitions) != 0
352
353
val includeLinkedClass = (includes & Include .linkedClass) != 0
353
- val includeRenamingImports = (includes & Include .renamingImports) != 0
354
- val predicate : NameTree => Boolean = tree =>
354
+ val fullPredicate : NameTree => Boolean = tree =>
355
355
( ! tree.symbol.isPrimaryConstructor
356
356
&& (includeDeclaration || ! Interactive .isDefinition(tree))
357
- && (includeRenamingImports || ! isRenamed(tree))
358
357
&& ( Interactive .matchSymbol(tree, symbol, includes)
359
- || ( includeDeclaration
360
- && includeLinkedClass
358
+ || ( includeLinkedClass
361
359
&& linkedSym.exists
362
360
&& Interactive .matchSymbol(tree, linkedSym, includes)
363
361
)
364
362
)
363
+ && predicate(tree)
365
364
)
366
- namedTrees(trees, includes, predicate )
365
+ namedTrees(trees, includes, fullPredicate )
367
366
}
368
367
369
368
/** The reverse path to the node that closest encloses position `pos`,
@@ -577,35 +576,4 @@ object Interactive {
577
576
}
578
577
}
579
578
580
- /**
581
- * In `enclosing`, find all the references to any of `syms` that have been renamed to `toName`.
582
- *
583
- * If `enclosing` is empty, it means the renaming import was top-level and the whole source file
584
- * should be considered. Otherwise, we can restrict the search to this tree because renaming
585
- * imports are local.
586
- *
587
- * @param toName The name that is set by the renaming.
588
- * @param enclosing The tree that encloses the renaming import, if it exists.
589
- * @param syms The symbols to which we want to find renamed references.
590
- * @param allTrees All the trees in this source file, in case we can't find `enclosing`.
591
- * @param source The sourcefile that where to look for references.
592
- * @return All the references to the symbol under the cursor that are using `toName`.
593
- */
594
- def findTreesMatchingRenaming (toName : Name ,
595
- syms : List [Symbol ],
596
- trees : List [SourceTree ]
597
- )(implicit ctx : Context ): List [SourceNamedTree ] = {
598
-
599
- val includes =
600
- Include .references | Include .imports | Include .renamingImports
601
-
602
- syms.flatMap { sym =>
603
- Interactive .namedTrees(trees,
604
- includes,
605
- tree =>
606
- Interactive .sameName(tree.name, toName) &&
607
- (Interactive .matchSymbol(tree, sym, includes) || Interactive .matchSymbol(tree, sym.linkedClass, includes)))
608
- }
609
- }
610
-
611
579
}
0 commit comments