@@ -29,7 +29,6 @@ object Interactive {
2929 val definitions : Int = 8 // include definitions
3030 val linkedClass : Int = 16 // include `symbol.linkedClass`
3131 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
3332 }
3433
3534 /** Does this tree define a symbol ? */
@@ -302,7 +301,6 @@ object Interactive {
302301 (implicit ctx : Context ): List [SourceNamedTree ] = safely {
303302 val includeReferences = (include & Include .references) != 0
304303 val includeImports = (include & Include .imports) != 0
305- val includeRenamingImports = (include & Include .renamingImports) != 0
306304 val buf = new mutable.ListBuffer [SourceNamedTree ]
307305
308306 def traverser (source : SourceFile ) = {
@@ -340,30 +338,31 @@ object Interactive {
340338 /**
341339 * Find trees that match `symbol` in `trees`.
342340 *
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.
346345 */
347346 def findTreesMatching (trees : List [SourceTree ],
348347 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 ] = {
350351 val linkedSym = symbol.linkedClass
351352 val includeDeclaration = (includes & Include .definitions) != 0
352353 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 =>
355355 ( ! tree.symbol.isPrimaryConstructor
356356 && (includeDeclaration || ! Interactive .isDefinition(tree))
357- && (includeRenamingImports || ! isRenamed(tree))
358357 && ( Interactive .matchSymbol(tree, symbol, includes)
359- || ( includeDeclaration
360- && includeLinkedClass
358+ || ( includeLinkedClass
361359 && linkedSym.exists
362360 && Interactive .matchSymbol(tree, linkedSym, includes)
363361 )
364362 )
363+ && predicate(tree)
365364 )
366- namedTrees(trees, includes, predicate )
365+ namedTrees(trees, includes, fullPredicate )
367366 }
368367
369368 /** The reverse path to the node that closest encloses position `pos`,
@@ -577,35 +576,4 @@ object Interactive {
577576 }
578577 }
579578
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-
611579}
0 commit comments