summaryrefslogtreecommitdiff
path: root/src/interactive
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-09-03 12:38:54 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-09-03 14:10:40 +1000
commita67b04079716812004b0d44ad65d48c508cf7d9e (patch)
tree626bcec9c809a4e7583445f30c1392fa272f7db6 /src/interactive
parentb6a812e0fa5bf333610884e72b0306f2bd7efee7 (diff)
downloadscala-a67b04079716812004b0d44ad65d48c508cf7d9e.tar.gz
scala-a67b04079716812004b0d44ad65d48c508cf7d9e.tar.bz2
scala-a67b04079716812004b0d44ad65d48c508cf7d9e.zip
Add the prefix the autocompletion results (Scope-, TypeMember)
This makes life easier for clients of these APIs, we use this to avoid passing this around in the wrapper result `TypeMembers`.
Diffstat (limited to 'src/interactive')
-rw-r--r--src/interactive/scala/tools/nsc/interactive/CompilerControl.scala8
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala11
2 files changed, 14 insertions, 5 deletions
diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
index fc6403afa3..586f011429 100644
--- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
@@ -268,6 +268,7 @@ trait CompilerControl { self: Global =>
/** Info given for every member found by completion
*/
abstract class Member {
+ def prefix: Type
val sym: Symbol
val tpe: Type
val accessible: Boolean
@@ -289,6 +290,8 @@ trait CompilerControl { self: Global =>
accessible: Boolean,
inherited: Boolean,
viaView: Symbol) extends Member {
+ // should be a case class parameter, but added as a var instead to preserve compatibility with the IDE
+ var prefix: Type = NoType
override def implicitlyAdded = viaView != NoSymbol
}
@@ -296,7 +299,10 @@ trait CompilerControl { self: Global =>
sym: Symbol,
tpe: Type,
accessible: Boolean,
- viaImport: Tree) extends Member
+ viaImport: Tree) extends Member {
+ // should be a case class parameter, but added as a var instead to preserve compatibility with the IDE
+ var prefix: Type = NoType
+ }
// items that get sent to scheduler
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index d5caf28991..b9d06b3633 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -1031,10 +1031,12 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
def addScopeMember(sym: Symbol, pre: Type, viaImport: Tree) =
locals.add(sym, pre, implicitlyAdded = false) { (s, st) =>
// imported val and var are always marked as inaccessible, but they could be accessed through their getters. SI-7995
- if (s.hasGetter)
+ val member = if (s.hasGetter)
new ScopeMember(s, st, context.isAccessible(s.getter, pre, superAccess = false), viaImport)
else
new ScopeMember(s, st, context.isAccessible(s, pre, superAccess = false), viaImport)
+ member.prefix = pre
+ member
}
def localsToEnclosing() = {
enclosing.addNonShadowed(locals)
@@ -1101,10 +1103,13 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
def addTypeMember(sym: Symbol, pre: Type, inherited: Boolean, viaView: Symbol) = {
val implicitlyAdded = viaView != NoSymbol
members.add(sym, pre, implicitlyAdded) { (s, st) =>
- new TypeMember(s, st,
+ val result = new TypeMember(s, st,
context.isAccessible(if (s.hasGetter) s.getter(s.owner) else s, pre, superAccess && !implicitlyAdded),
inherited,
viaView)
+ result.prefix = pre
+ result
+
}
}
@@ -1157,7 +1162,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
def matchingResults(matcher: (M, Name) => Boolean = CompletionResult.prefixMatcher): List[M] = {
results filter (r => matcher(r, name))
}
- def qualifierType: Type = NoType
}
object CompletionResult {
final case class ScopeMembers(positionDelta: Int, results: List[ScopeMember], name: Name) extends CompletionResult {
@@ -1165,7 +1169,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
final case class TypeMembers(positionDelta: Int, qualifier: Tree, tree: Tree, results: List[TypeMember], name: Name) extends CompletionResult {
type M = TypeMember
- override def qualifierType: Type = qualifier.tpe
}
case object NoResults extends CompletionResult {
override def results = Nil