summaryrefslogtreecommitdiff
path: root/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
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/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
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/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala')
-rw-r--r--src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
index ee901db1a0..3fb4428e76 100644
--- a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
+++ b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
@@ -54,28 +54,27 @@ class PresentationCompilerCompleter(intp: IMain) extends Completion with ScalaCo
Candidates(cursor, "" :: tpString :: Nil)
}
def candidates(result: Result): Candidates = {
- import result.compiler.CompletionResult._, result.compiler.{Symbol, NoSymbol, Type, Member, NoType, Name}
- def defStringCandidates(qualTpe: Type, matching: List[Member], name: Name): Candidates = {
+ import result.compiler._
+ import CompletionResult._
+ def defStringCandidates(matching: List[Member], name: Name): Candidates = {
val defStrings = for {
member <- matching
if member.symNameDropLocal == name
sym <- member.sym.alternatives
sugared = sym.sugaredSymbolOrSelf
} yield {
- val tp = qualTpe match {
- case NoType => member.tpe
- case _ => qualTpe memberType sym
- }
+ val tp = member.prefix memberType sym
sugared.defStringSeenAs(tp)
}
Candidates(cursor, "" :: defStrings.distinct)
}
val found = result.completionsAt(cursor) match {
case NoResults => Completion.NoCandidates
- case r => val matching = r.matchingResults()
+ case r =>
+ val matching = r.matchingResults()
val tabAfterCommonPrefixCompletion = lastCommonPrefixCompletion.contains(buf.substring(0, cursor)) && matching.exists(_.symNameDropLocal == r.name)
val doubleTab = tabCount > 0 && matching.forall(_.symNameDropLocal == r.name)
- if (tabAfterCommonPrefixCompletion || doubleTab) defStringCandidates(r.qualifierType, matching, r.name)
+ if (tabAfterCommonPrefixCompletion || doubleTab) defStringCandidates(matching, r.name)
else {
if (matching.nonEmpty && matching.forall(_.symNameDropLocal == r.name))
Completion.NoCandidates // don't offer completion if the only option has been fully typed already