@@ -54,10 +54,13 @@ object Interactive {
5454 path.dropWhile(! _.symbol.exists).headOption.getOrElse(tpd.EmptyTree )
5555
5656 /**
57- * The source symbol that is the closest to `path`.
57+ * The source symbols that are the closest to `path`.
5858 *
59- * @param path The path to the tree whose symbol to extract.
60- * @return The source symbol that is the closest to `path`.
59+ * If this path ends in an import, then this returns all the symbols that are imported by this
60+ * import statement.
61+ *
62+ * @param path The path to the tree whose symbols to extract.
63+ * @return The source symbols that are the closest to `path`.
6164 *
6265 * @see sourceSymbol
6366 */
@@ -69,20 +72,20 @@ object Interactive {
6972 if (funSym.name == StdNames .nme.copy
7073 && funSym.is(Synthetic )
7174 && funSym.owner.is(CaseClass )) {
72- funSym.owner.info.member(name).symbol :: Nil
75+ List ( funSym.owner.info.member(name).symbol)
7376 } else {
7477 val classTree = funSym.topLevelClass.asClass.rootTree
7578 val paramSymbol =
7679 for {
7780 DefDef (_, _, paramss, _, _) <- tpd.defPath(funSym, classTree).lastOption
7881 param <- paramss.flatten.find(_.name == name)
7982 } yield param.symbol
80- paramSymbol.getOrElse(fn.symbol) :: Nil
83+ List ( paramSymbol.getOrElse(fn.symbol))
8184 }
8285
8386 // For constructor calls, return the `<init>` that was selected
8487 case _ :: (_ : New ) :: (select : Select ) :: _ =>
85- select.symbol :: Nil
88+ List ( select.symbol)
8689
8790 case (_ : Thicket ) :: (imp : Import ) :: _ =>
8891 importedSymbols(imp, _.pos.contains(pos.pos))
@@ -91,7 +94,7 @@ object Interactive {
9194 importedSymbols(imp, _.pos.contains(pos.pos))
9295
9396 case _ =>
94- enclosingTree(path).symbol :: Nil
97+ List ( enclosingTree(path).symbol)
9598 }
9699
97100 syms.map(Interactive .sourceSymbol).filter(_.exists)
@@ -341,7 +344,7 @@ object Interactive {
341344 val tree = tpd.Select (imp.expr, sym.name).withPos(name.pos)
342345 val renameTree = rename.map { r =>
343346 val name = if (sym.name.isTypeName) r.name.toTypeName else r.name
344- RenameTree (name, tpd.Select (imp.expr, sym.name) ).withPos(r.pos)
347+ tpd.Select (imp.expr, sym.name).withPos(r.pos)
345348 }
346349 renameTree.foreach(traverse)
347350 traverse(tree)
@@ -547,20 +550,10 @@ object Interactive {
547550 */
548551 private def importedSymbols (expr : tpd.Tree , name : Name )(implicit ctx : Context ): List [Symbol ] = {
549552 def lookup (name : Name ): Symbol = expr.tpe.member(name).symbol
550- lookup(name.toTermName) ::
551- lookup(name.toTypeName) ::
552- lookup(name.moduleClassName) ::
553- lookup(name.sourceModuleName) :: Nil
554- }
555-
556- /**
557- * Used to represent a renaming import `{foo => bar}`.
558- * We need this because the name of the tree must be the new name, but the
559- * denotation must be that of the importee.
560- */
561- private case class RenameTree (name : Name , underlying : Tree ) extends NameTree {
562- override def denot (implicit ctx : Context ) = underlying.denot
563- myTpe = NoType
553+ List (lookup(name.toTermName),
554+ lookup(name.toTypeName),
555+ lookup(name.moduleClassName),
556+ lookup(name.sourceModuleName))
564557 }
565558
566559 /**
0 commit comments