summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-09-09 16:23:51 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-09-09 16:31:29 +1000
commit0dbdaf8b1fb64806d35c18b362184293d46c89cb (patch)
tree5f31c5282c20da2af4ece8212478a6f6b6649634 /src
parente3f025c1e4fbef83528ab189b37e13ebdf1b9a72 (diff)
downloadscala-0dbdaf8b1fb64806d35c18b362184293d46c89cb.tar.gz
scala-0dbdaf8b1fb64806d35c18b362184293d46c89cb.tar.bz2
scala-0dbdaf8b1fb64806d35c18b362184293d46c89cb.zip
Hide some completion candidates on the first TAB
When `foo.<TAB>`, assume you don't want to see the inherited members from Any_ and universally applicable extension methods like `ensuring`. Hitting <TAB> a second time includes them in the results.
Diffstat (limited to 'src')
-rw-r--r--src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
index 7cff24cfa3..01735aed3a 100644
--- a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
+++ b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala
@@ -71,15 +71,26 @@ class PresentationCompilerCompleter(intp: IMain) extends Completion with ScalaCo
val found = result.completionsAt(cursor) match {
case NoResults => Completion.NoCandidates
case r =>
- def isInterpreterWrapperMember(m: Member): Boolean =
- definitions.isUniversalMember(m.sym) && nme.isReplWrapperName(m.prefix.typeSymbol.name)
- val matching = r.matchingResults().filterNot(isInterpreterWrapperMember)
+ def shouldHide(m: Member): Boolean = {
+ val isUniversal = definitions.isUniversalMember(m.sym)
+ def viaUniversalExtensionMethod = m match {
+ case t: TypeMember if t.implicitlyAdded && t.viaView.info.params.head.info.bounds.isEmptyBounds => true
+ case _ => false
+ }
+ (
+ isUniversal && nme.isReplWrapperName(m.prefix.typeSymbol.name)
+ || isUniversal && tabCount == 0 && r.name.isEmpty
+ || viaUniversalExtensionMethod && tabCount == 0 && r.name.isEmpty
+ )
+ }
+
+ val matching = r.matchingResults().filterNot(shouldHide)
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(matching, r.name)
else if (matching.isEmpty) {
// Lenient matching based on camel case and on eliding JavaBean "get" / "is" boilerplate
- val camelMatches: List[Member] = r.matchingResults(CompletionResult.camelMatch(_)).filterNot(isInterpreterWrapperMember)
+ val camelMatches: List[Member] = r.matchingResults(CompletionResult.camelMatch(_)).filterNot(shouldHide)
val memberCompletions = camelMatches.map(_.symNameDropLocal.decoded).distinct.sorted
def allowCompletion = (
(memberCompletions.size == 1)