@@ -54,10 +54,13 @@ object Interactive {
54
54
path.dropWhile(! _.symbol.exists).headOption.getOrElse(tpd.EmptyTree )
55
55
56
56
/**
57
- * The source symbol that is the closest to `path`.
57
+ * The source symbols that are the closest to `path`.
58
58
*
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`.
61
64
*
62
65
* @see sourceSymbol
63
66
*/
@@ -69,20 +72,20 @@ object Interactive {
69
72
if (funSym.name == StdNames .nme.copy
70
73
&& funSym.is(Synthetic )
71
74
&& funSym.owner.is(CaseClass )) {
72
- funSym.owner.info.member(name).symbol :: Nil
75
+ List ( funSym.owner.info.member(name).symbol)
73
76
} else {
74
77
val classTree = funSym.topLevelClass.asClass.rootTree
75
78
val paramSymbol =
76
79
for {
77
80
DefDef (_, _, paramss, _, _) <- tpd.defPath(funSym, classTree).lastOption
78
81
param <- paramss.flatten.find(_.name == name)
79
82
} yield param.symbol
80
- paramSymbol.getOrElse(fn.symbol) :: Nil
83
+ List ( paramSymbol.getOrElse(fn.symbol))
81
84
}
82
85
83
86
// For constructor calls, return the `<init>` that was selected
84
87
case _ :: (_ : New ) :: (select : Select ) :: _ =>
85
- select.symbol :: Nil
88
+ List ( select.symbol)
86
89
87
90
case (_ : Thicket ) :: (imp : Import ) :: _ =>
88
91
importedSymbols(imp, _.pos.contains(pos.pos))
@@ -91,7 +94,7 @@ object Interactive {
91
94
importedSymbols(imp, _.pos.contains(pos.pos))
92
95
93
96
case _ =>
94
- enclosingTree(path).symbol :: Nil
97
+ List ( enclosingTree(path).symbol)
95
98
}
96
99
97
100
syms.map(Interactive .sourceSymbol).filter(_.exists)
@@ -547,10 +550,10 @@ object Interactive {
547
550
*/
548
551
private def importedSymbols (expr : tpd.Tree , name : Name )(implicit ctx : Context ): List [Symbol ] = {
549
552
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
553
+ List ( lookup(name.toTermName),
554
+ lookup(name.toTypeName),
555
+ lookup(name.moduleClassName),
556
+ lookup(name.sourceModuleName))
554
557
}
555
558
556
559
/**
0 commit comments