summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2015-02-19 10:25:59 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-02-19 10:25:59 -0800
commita3a794fc3ba7128342310517da43e1ec143f85bd (patch)
tree74c9b733f0eb21723460c684a39cc0031b757f32
parent2d26cacd24b396c7f7449e731f059811d0d1fac4 (diff)
parent9cd5c881fc13acbd9aca08fd6ae2830292e5f1b4 (diff)
downloadscala-a3a794fc3ba7128342310517da43e1ec143f85bd.tar.gz
scala-a3a794fc3ba7128342310517da43e1ec143f85bd.tar.bz2
scala-a3a794fc3ba7128342310517da43e1ec143f85bd.zip
Merge pull request #4340 from retronym/topic/infix-completion
SI-9153 More complete and stable results for completions
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala6
-rw-r--r--src/interactive/scala/tools/nsc/interactive/ContextTrees.scala6
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala3
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala1
-rw-r--r--src/reflect/scala/reflect/internal/util/Collections.scala3
-rw-r--r--test/files/presentation/infix-completion.check193
-rw-r--r--test/files/presentation/infix-completion/Runner.scala3
-rw-r--r--test/files/presentation/infix-completion/src/Snippet.scala1
-rw-r--r--test/files/presentation/infix-completion2.check211
-rw-r--r--test/files/presentation/infix-completion2/Runner.scala3
-rw-r--r--test/files/presentation/infix-completion2/src/Snippet.scala1
11 files changed, 425 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 71558273a6..d3cd26f256 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -609,7 +609,7 @@ trait Implicits {
val itree2 = if (!isView) fallback else pt match {
case Function1(arg1, arg2) =>
typed1(
- atPos(itree0.pos)(Apply(itree1, List(Ident("<argument>") setType approximate(arg1)))),
+ atPos(itree0.pos)(Apply(itree1, List(Ident(nme.argument) setType approximate(arg1)))),
EXPRmode,
approximate(arg2)
) match {
@@ -918,7 +918,7 @@ trait Implicits {
/** Returns all eligible ImplicitInfos and their SearchResults in a map.
*/
- def findAll() = mapFrom(eligible)(typedImplicit(_, ptChecked = false, isLocalToCallsite))
+ def findAll() = linkedMapFrom(eligible)(typedImplicit(_, ptChecked = false, isLocalToCallsite))
/** Returns the SearchResult of the best match.
*/
@@ -963,7 +963,7 @@ trait Implicits {
* symbols of the same name in succeeding lists.
* @return map from infos to search results
*/
- def applicableInfos(iss: Infoss, isLocalToCallsite: Boolean): Map[ImplicitInfo, SearchResult] = {
+ def applicableInfos(iss: Infoss, isLocalToCallsite: Boolean): mutable.LinkedHashMap[ImplicitInfo, SearchResult] = {
val start = if (Statistics.canEnable) Statistics.startCounter(subtypeAppInfos) else null
val computation = new ImplicitComputation(iss, isLocalToCallsite) { }
val applicable = computation.findAll()
diff --git a/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala b/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala
index bf718c27cc..a4cb3efa4f 100644
--- a/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala
+++ b/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala
@@ -55,7 +55,11 @@ trait ContextTrees { self: Global =>
context
}
}
- locateContextTree(contexts, pos) map locateFinestContextTree map (_.context)
+ def sanitizeContext(c: Context): Context = {
+ c.retyping = false
+ c
+ }
+ locateContextTree(contexts, pos) map locateFinestContextTree map (ct => sanitizeContext(ct.context))
}
/** Returns the ContextTree containing `pos`, or the ContextTree positioned just before `pos`,
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index a3d0346f81..2d09435f60 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -1084,7 +1084,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
case t => t
}
val context = doLocateContext(pos)
-
val shouldTypeQualifier = tree0.tpe match {
case null => true
case mt: MethodType => mt.isImplicit
@@ -1139,7 +1138,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
for (view <- applicableViews) {
val vtree = viewApply(view)
val vpre = stabilizedType(vtree)
- for (sym <- vtree.tpe.members) {
+ for (sym <- vtree.tpe.members if sym.isTerm) {
addTypeMember(sym, vpre, inherited = false, view.tree.symbol)
}
}
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index f32b7326fe..c0562b0679 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -1078,6 +1078,7 @@ trait StdNames {
val reflPolyCacheName: NameType = "reflPoly$Cache"
val reflParamsCacheName: NameType = "reflParams$Cache"
val reflMethodName: NameType = "reflMethod$Method"
+ val argument: NameType = "<argument>"
}
diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala
index d128521be8..a743d8962a 100644
--- a/src/reflect/scala/reflect/internal/util/Collections.scala
+++ b/src/reflect/scala/reflect/internal/util/Collections.scala
@@ -181,6 +181,9 @@ trait Collections {
final def mapFrom[A, A1 >: A, B](xs: List[A])(f: A => B): Map[A1, B] = {
Map[A1, B](xs map (x => (x, f(x))): _*)
}
+ final def linkedMapFrom[A, A1 >: A, B](xs: List[A])(f: A => B): mutable.LinkedHashMap[A1, B] = {
+ mutable.LinkedHashMap[A1, B](xs map (x => (x, f(x))): _*)
+ }
final def mapWithIndex[A, B](xs: List[A])(f: (A, Int) => B): List[B] = {
val lb = new ListBuffer[B]
diff --git a/test/files/presentation/infix-completion.check b/test/files/presentation/infix-completion.check
new file mode 100644
index 0000000000..f62dc81d34
--- /dev/null
+++ b/test/files/presentation/infix-completion.check
@@ -0,0 +1,193 @@
+reload: Snippet.scala
+
+askTypeCompletion at Snippet.scala(1,34)
+================================================================================
+[response] askTypeCompletion at (1,34)
+retrieved 192 members
+[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type
+[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type
+[inaccessible] protected def ord: math.Ordering.Double.type
+[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean
+[inaccessible] protected def unifiedPrimitiveHashcode(): Int
+[inaccessible] protected[package lang] def clone(): Object
+[inaccessible] protected[package lang] def finalize(): Unit
+def !=(x: Byte): Boolean
+def !=(x: Char): Boolean
+def !=(x: Double): Boolean
+def !=(x: Float): Boolean
+def !=(x: Int): Boolean
+def !=(x: Long): Boolean
+def !=(x: Short): Boolean
+def %(x: Byte): Int
+def %(x: Char): Int
+def %(x: Double): Double
+def %(x: Float): Float
+def %(x: Int): Int
+def %(x: Long): Long
+def %(x: Short): Int
+def &(x: Byte): Int
+def &(x: Char): Int
+def &(x: Int): Int
+def &(x: Long): Long
+def &(x: Short): Int
+def *(x: Byte): Int
+def *(x: Char): Int
+def *(x: Double): Double
+def *(x: Float): Float
+def *(x: Int): Int
+def *(x: Long): Long
+def *(x: Short): Int
+def +(x: Byte): Int
+def +(x: Char): Int
+def +(x: Double): Double
+def +(x: Float): Float
+def +(x: Int): Int
+def +(x: Long): Long
+def +(x: Short): Int
+def +(x: String): String
+def -(x: Byte): Int
+def -(x: Char): Int
+def -(x: Double): Double
+def -(x: Float): Float
+def -(x: Int): Int
+def -(x: Long): Long
+def -(x: Short): Int
+def ->[B](y: B): (Int, B)
+def /(x: Byte): Int
+def /(x: Char): Int
+def /(x: Double): Double
+def /(x: Float): Float
+def /(x: Int): Int
+def /(x: Long): Long
+def /(x: Short): Int
+def <(x: Byte): Boolean
+def <(x: Char): Boolean
+def <(x: Double): Boolean
+def <(x: Float): Boolean
+def <(x: Int): Boolean
+def <(x: Long): Boolean
+def <(x: Short): Boolean
+def <<(x: Int): Int
+def <<(x: Long): Int
+def <=(x: Byte): Boolean
+def <=(x: Char): Boolean
+def <=(x: Double): Boolean
+def <=(x: Float): Boolean
+def <=(x: Int): Boolean
+def <=(x: Long): Boolean
+def <=(x: Short): Boolean
+def ==(x: Byte): Boolean
+def ==(x: Char): Boolean
+def ==(x: Double): Boolean
+def ==(x: Float): Boolean
+def ==(x: Int): Boolean
+def ==(x: Long): Boolean
+def ==(x: Short): Boolean
+def >(x: Byte): Boolean
+def >(x: Char): Boolean
+def >(x: Double): Boolean
+def >(x: Float): Boolean
+def >(x: Int): Boolean
+def >(x: Long): Boolean
+def >(x: Short): Boolean
+def >=(x: Byte): Boolean
+def >=(x: Char): Boolean
+def >=(x: Double): Boolean
+def >=(x: Float): Boolean
+def >=(x: Int): Boolean
+def >=(x: Long): Boolean
+def >=(x: Short): Boolean
+def >>(x: Int): Int
+def >>(x: Long): Int
+def >>>(x: Int): Int
+def >>>(x: Long): Int
+def ^(x: Byte): Int
+def ^(x: Char): Int
+def ^(x: Int): Int
+def ^(x: Long): Long
+def ^(x: Short): Int
+def byteValue(): Byte
+def ceil: Double
+def compare(y: Double): Int
+def compare(y: Long): Int
+def compareTo(that: Double): Int
+def compareTo(that: Long): Int
+def compareTo(x$1: Double): Int
+def compareTo(x$1: Long): Int
+def doubleValue(): Double
+def ensuring(cond: Boolean): Int
+def ensuring(cond: Boolean,msg: => Any): Int
+def ensuring(cond: Int => Boolean): Int
+def ensuring(cond: Int => Boolean,msg: => Any): Int
+def equals(x$1: Any): Boolean
+def floatValue(): Float
+def floor: Double
+def formatted(fmtstr: String): String
+def hashCode(): Int
+def intValue(): Int
+def isInfinite(): Boolean
+def isInfinity: Boolean
+def isNaN(): Boolean
+def isNegInfinity: Boolean
+def isPosInfinity: Boolean
+def isValidLong: Boolean
+def longValue(): Long
+def round: Long
+def shortValue(): Short
+def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double]
+def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def toBinaryString: String
+def toByte: Byte
+def toChar: Char
+def toDegrees: Double
+def toDouble: Double
+def toFloat: Float
+def toHexString: String
+def toInt: Int
+def toLong: Long
+def toOctalString: String
+def toRadians: Double
+def toShort: Short
+def toString(): String
+def unary_+: Int
+def unary_-: Int
+def unary_~: Int
+def underlying(): AnyRef
+def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double]
+def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def |(x: Byte): Int
+def |(x: Char): Int
+def |(x: Int): Int
+def |(x: Long): Long
+def |(x: Short): Int
+def →[B](y: B): (Int, B)
+final def !=(x$1: Any): Boolean
+final def ##(): Int
+final def ==(x$1: Any): Boolean
+final def asInstanceOf[T0]: T0
+final def eq(x$1: AnyRef): Boolean
+final def isInstanceOf[T0]: Boolean
+final def ne(x$1: AnyRef): Boolean
+final def notify(): Unit
+final def notifyAll(): Unit
+final def synchronized[T0](x$1: T0): T0
+final def wait(): Unit
+final def wait(x$1: Long): Unit
+final def wait(x$1: Long,x$2: Int): Unit
+override def abs: Double
+override def isValidByte: Boolean
+override def isValidChar: Boolean
+override def isValidInt: Boolean
+override def isValidShort: Boolean
+override def isWhole(): Boolean
+override def max(that: Double): Double
+override def max(that: Long): Long
+override def min(that: Double): Double
+override def min(that: Long): Long
+override def signum: Int
+private[this] val self: Double
+================================================================================
diff --git a/test/files/presentation/infix-completion/Runner.scala b/test/files/presentation/infix-completion/Runner.scala
new file mode 100644
index 0000000000..1c03e3d5ba
--- /dev/null
+++ b/test/files/presentation/infix-completion/Runner.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests._
+
+object Test extends InteractiveTest
diff --git a/test/files/presentation/infix-completion/src/Snippet.scala b/test/files/presentation/infix-completion/src/Snippet.scala
new file mode 100644
index 0000000000..7e03c486ba
--- /dev/null
+++ b/test/files/presentation/infix-completion/src/Snippet.scala
@@ -0,0 +1 @@
+object Snippet{val x = 123; 1 + 1./*!*/}
diff --git a/test/files/presentation/infix-completion2.check b/test/files/presentation/infix-completion2.check
new file mode 100644
index 0000000000..5c69cd84cb
--- /dev/null
+++ b/test/files/presentation/infix-completion2.check
@@ -0,0 +1,211 @@
+reload: Snippet.scala
+
+askTypeCompletion at Snippet.scala(1,34)
+================================================================================
+[response] askTypeCompletion at (1,34)
+retrieved 211 members
+[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type
+[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type
+[inaccessible] protected def ord: math.Ordering.Double.type
+[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean
+[inaccessible] protected def unifiedPrimitiveHashcode(): Int
+[inaccessible] protected[package lang] def clone(): Object
+[inaccessible] protected[package lang] def finalize(): Unit
+def !=(x: Byte): Boolean
+def !=(x: Char): Boolean
+def !=(x: Double): Boolean
+def !=(x: Float): Boolean
+def !=(x: Int): Boolean
+def !=(x: Long): Boolean
+def !=(x: Short): Boolean
+def %(x: Byte): Int
+def %(x: Char): Int
+def %(x: Double): Double
+def %(x: Float): Float
+def %(x: Int): Int
+def %(x: Long): Long
+def %(x: Short): Int
+def &(x: Byte): Int
+def &(x: Char): Int
+def &(x: Int): Int
+def &(x: Long): Long
+def &(x: Short): Int
+def *(x: Byte): Int
+def *(x: Char): Int
+def *(x: Double): Double
+def *(x: Float): Float
+def *(x: Int): Int
+def *(x: Long): Long
+def *(x: Short): Int
+def +(x: Byte): Int
+def +(x: Char): Int
+def +(x: Double): Double
+def +(x: Float): Float
+def +(x: Int): Int
+def +(x: Long): Long
+def +(x: Short): Int
+def +(x: String): String
+def -(x: Byte): Int
+def -(x: Char): Int
+def -(x: Double): Double
+def -(x: Float): Float
+def -(x: Int): Int
+def -(x: Long): Long
+def -(x: Short): Int
+def ->[B](y: B): (Int, B)
+def /(x: Byte): Int
+def /(x: Char): Int
+def /(x: Double): Double
+def /(x: Float): Float
+def /(x: Int): Int
+def /(x: Long): Long
+def /(x: Short): Int
+def <(x: Byte): Boolean
+def <(x: Char): Boolean
+def <(x: Double): Boolean
+def <(x: Float): Boolean
+def <(x: Int): Boolean
+def <(x: Long): Boolean
+def <(x: Short): Boolean
+def <<(x: Int): Int
+def <<(x: Long): Int
+def <=(x: Byte): Boolean
+def <=(x: Char): Boolean
+def <=(x: Double): Boolean
+def <=(x: Float): Boolean
+def <=(x: Int): Boolean
+def <=(x: Long): Boolean
+def <=(x: Short): Boolean
+def ==(x: Byte): Boolean
+def ==(x: Char): Boolean
+def ==(x: Double): Boolean
+def ==(x: Float): Boolean
+def ==(x: Int): Boolean
+def ==(x: Long): Boolean
+def ==(x: Short): Boolean
+def >(x: Byte): Boolean
+def >(x: Char): Boolean
+def >(x: Double): Boolean
+def >(x: Float): Boolean
+def >(x: Int): Boolean
+def >(x: Long): Boolean
+def >(x: Short): Boolean
+def >=(x: Byte): Boolean
+def >=(x: Char): Boolean
+def >=(x: Double): Boolean
+def >=(x: Float): Boolean
+def >=(x: Int): Boolean
+def >=(x: Long): Boolean
+def >=(x: Short): Boolean
+def >>(x: Int): Int
+def >>(x: Long): Int
+def >>>(x: Int): Int
+def >>>(x: Long): Int
+def ^(x: Byte): Int
+def ^(x: Char): Int
+def ^(x: Int): Int
+def ^(x: Long): Long
+def ^(x: Short): Int
+def byteValue(): Byte
+def ceil: Double
+def compare(y: Double): Int
+def compare(y: Float): Int
+def compare(y: Int): Int
+def compare(y: Long): Int
+def compareTo(that: Double): Int
+def compareTo(that: Float): Int
+def compareTo(that: Int): Int
+def compareTo(that: Long): Int
+def compareTo(x$1: Double): Int
+def compareTo(x$1: Float): Int
+def compareTo(x$1: Integer): Int
+def compareTo(x$1: Long): Int
+def doubleValue(): Double
+def ensuring(cond: Boolean): Int
+def ensuring(cond: Boolean,msg: => Any): Int
+def ensuring(cond: Int => Boolean): Int
+def ensuring(cond: Int => Boolean,msg: => Any): Int
+def equals(x$1: Any): Boolean
+def floatValue(): Float
+def floor: Double
+def formatted(fmtstr: String): String
+def hashCode(): Int
+def intValue(): Int
+def isInfinite(): Boolean
+def isInfinity: Boolean
+def isNaN(): Boolean
+def isNegInfinity: Boolean
+def isPosInfinity: Boolean
+def isValidLong: Boolean
+def longValue(): Long
+def round: Long
+def shortValue(): Short
+def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double]
+def to(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]]
+def to(end: Float,step: Float): scala.collection.immutable.NumericRange.Inclusive[Float]
+def to(end: Int): scala.collection.immutable.Range.Inclusive
+def to(end: Int,step: Int): scala.collection.immutable.Range.Inclusive
+def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def toBinaryString: String
+def toByte: Byte
+def toChar: Char
+def toDegrees: Double
+def toDouble: Double
+def toFloat: Float
+def toHexString: String
+def toInt: Int
+def toLong: Long
+def toOctalString: String
+def toRadians: Double
+def toShort: Short
+def toString(): String
+def unary_+: Int
+def unary_-: Int
+def unary_~: Int
+def underlying(): AnyRef
+def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double]
+def until(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]]
+def until(end: Float,step: Float): scala.collection.immutable.NumericRange.Exclusive[Float]
+def until(end: Int): scala.collection.immutable.Range
+def until(end: Int,step: Int): scala.collection.immutable.Range
+def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def |(x: Byte): Int
+def |(x: Char): Int
+def |(x: Int): Int
+def |(x: Long): Long
+def |(x: Short): Int
+def →[B](y: B): (Int, B)
+final def !=(x$1: Any): Boolean
+final def ##(): Int
+final def ==(x$1: Any): Boolean
+final def asInstanceOf[T0]: T0
+final def eq(x$1: AnyRef): Boolean
+final def isInstanceOf[T0]: Boolean
+final def ne(x$1: AnyRef): Boolean
+final def notify(): Unit
+final def notifyAll(): Unit
+final def synchronized[T0](x$1: T0): T0
+final def wait(): Unit
+final def wait(x$1: Long): Unit
+final def wait(x$1: Long,x$2: Int): Unit
+override def abs: Double
+override def isValidByte: Boolean
+override def isValidChar: Boolean
+override def isValidInt: Boolean
+override def isValidShort: Boolean
+override def isWhole(): Boolean
+override def max(that: Double): Double
+override def max(that: Float): Float
+override def max(that: Int): Int
+override def max(that: Long): Long
+override def min(that: Double): Double
+override def min(that: Float): Float
+override def min(that: Int): Int
+override def min(that: Long): Long
+override def signum: Int
+private[this] val self: Double
+================================================================================
diff --git a/test/files/presentation/infix-completion2/Runner.scala b/test/files/presentation/infix-completion2/Runner.scala
new file mode 100644
index 0000000000..1c03e3d5ba
--- /dev/null
+++ b/test/files/presentation/infix-completion2/Runner.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests._
+
+object Test extends InteractiveTest
diff --git a/test/files/presentation/infix-completion2/src/Snippet.scala b/test/files/presentation/infix-completion2/src/Snippet.scala
new file mode 100644
index 0000000000..4eb8c24a2e
--- /dev/null
+++ b/test/files/presentation/infix-completion2/src/Snippet.scala
@@ -0,0 +1 @@
+object Snippet{val x = 123; 1 + x./*!*/}