summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-11-06 15:38:02 +0100
committerLuc Bourlier <luc.bourlier@typesafe.com>2013-11-21 12:24:00 +0100
commit3a8796da1a321b5b7bb547c3c0cd9f62b5d0279d (patch)
tree3ec43d7aeca79c9d7975c274050cb398c8df7ff7
parentb9f68601bee026bff2c494add399de61de7fc79d (diff)
downloadscala-3a8796da1a321b5b7bb547c3c0cd9f62b5d0279d.tar.gz
scala-3a8796da1a321b5b7bb547c3c0cd9f62b5d0279d.tar.bz2
scala-3a8796da1a321b5b7bb547c3c0cd9f62b5d0279d.zip
[nomaster] Test infrastructure for scope completion
Adds a new marker /*_*/ to trigger scope completion test. Original type completion test oracles update for the tweaked output (cherry picked from commit 9c7c66ff7907e3ab814f0f4375eeaf6cdd230d5e)
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala19
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala47
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala4
-rw-r--r--test/files/presentation/callcc-interpreter.check2
-rw-r--r--test/files/presentation/completion-implicit-chained.check2
-rw-r--r--test/files/presentation/ide-bug-1000349.check2
-rw-r--r--test/files/presentation/ide-bug-1000475.check6
-rw-r--r--test/files/presentation/ide-bug-1000531.check2
-rw-r--r--test/files/presentation/implicit-member.check2
-rw-r--r--test/files/presentation/ping-pong.check4
-rw-r--r--test/files/presentation/t5708.check2
-rw-r--r--test/files/presentation/visibility.check10
13 files changed, 76 insertions, 28 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala
index 597b9012ce..1c722ea3a0 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala
@@ -69,7 +69,7 @@ abstract class InteractiveTest
* Override this member if you need to change the default set of executed test actions.
*/
protected lazy val testActions: ListBuffer[PresentationCompilerTestDef] = {
- ListBuffer(new CompletionAction(compiler), new TypeAction(compiler), new HyperlinkAction(compiler))
+ ListBuffer(new TypeCompletionAction(compiler), new ScopeCompletionAction(compiler), new TypeAction(compiler), new HyperlinkAction(compiler))
}
/** Add new presentation compiler actions to test. Presentation compiler's test
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
index 8d446cbbf8..4f9df6808f 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
@@ -42,7 +42,7 @@ trait AskParse extends AskCommand {
import compiler.Tree
/** `sources` need to be entirely parsed before running the test
- * (else commands such as `AskCompletionAt` may fail simply because
+ * (else commands such as `AskTypeCompletionAt` may fail simply because
* the source's AST is not yet loaded).
*/
def askParse(sources: Seq[SourceFile]) {
@@ -72,10 +72,10 @@ trait AskReload extends AskCommand {
}
/** Ask the presentation compiler for completion at a given position. */
-trait AskCompletionAt extends AskCommand {
+trait AskTypeCompletionAt extends AskCommand {
import compiler.Member
- private[tests] def askCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
+ private[tests] def askTypeCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
reporter.println("\naskTypeCompletion at " + pos.source.file.name + ((pos.line, pos.column)))
ask {
@@ -84,6 +84,19 @@ trait AskCompletionAt extends AskCommand {
}
}
+/** Ask the presentation compiler for scope completion at a given position. */
+trait AskScopeCompletionAt extends AskCommand {
+ import compiler.Member
+
+ private[tests] def askScopeCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
+ reporter.println("\naskScopeCompletion at " + pos.source.file.name + ((pos.line, pos.column)))
+
+ ask {
+ compiler.askScopeCompletion(pos, _)
+ }
+ }
+}
+
/** Ask the presentation compiler for type info at a given position. */
trait AskTypeAt extends AskCommand {
import compiler.Tree
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
index c8e6b6ccce..214f7a4553 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
@@ -13,19 +13,19 @@ private[tests] trait CoreTestDefs
/** Ask the presentation compiler for completion at all locations
* (in all sources) where the defined `marker` is found. */
- class CompletionAction(override val compiler: Global)
+ class TypeCompletionAction(override val compiler: Global)
extends PresentationCompilerTestDef
- with AskCompletionAt {
+ with AskTypeCompletionAt {
def memberPrinter(member: compiler.Member): String =
"[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`"
override def runTest() {
- askAllSources(CompletionMarker) { pos =>
- askCompletionAt(pos)
+ askAllSources(TypeCompletionMarker) { pos =>
+ askTypeCompletionAt(pos)
} { (pos, members) =>
withResponseDelimiter {
- reporter.println("[response] aksTypeCompletion at " + format(pos))
+ reporter.println("[response] askTypeCompletion at " + format(pos))
// we skip getClass because it changed signature between 1.5 and 1.6, so there is no
// universal check file that we can provide for this to work
reporter.println("retrieved %d members".format(members.size))
@@ -38,6 +38,39 @@ private[tests] trait CoreTestDefs
}
}
+ /** Ask the presentation compiler for completion at all locations
+ * (in all sources) where the defined `marker` is found. */
+ class ScopeCompletionAction(override val compiler: Global)
+ extends PresentationCompilerTestDef
+ with AskScopeCompletionAt {
+
+ def memberPrinter(member: compiler.Member): String =
+ "[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`"
+
+ override def runTest() {
+ askAllSources(ScopeCompletionMarker) { pos =>
+ askScopeCompletionAt(pos)
+ } { (pos, members) =>
+ withResponseDelimiter {
+ reporter.println("[response] askScopeCompletion at " + format(pos))
+ try {
+ // exclude members not from source (don't have position), for more focussed and self contained tests.
+ def eligible(sym: compiler.Symbol) = sym.pos != compiler.NoPosition
+ val filtered = members.filter(member => eligible(member.sym))
+ reporter.println("retrieved %d members".format(filtered.size))
+ compiler ask { () =>
+ reporter.println(filtered.map(memberPrinter).sortBy(_.toString()).mkString("\n"))
+ }
+ } catch {
+ case t: Throwable =>
+ t.printStackTrace()
+ }
+
+ }
+ }
+ }
+ }
+
/** Ask the presentation compiler for type info at all locations
* (in all sources) where the defined `marker` is found. */
class TypeAction(override val compiler: Global)
@@ -61,7 +94,7 @@ private[tests] trait CoreTestDefs
class HyperlinkAction(override val compiler: Global)
extends PresentationCompilerTestDef
with AskTypeAt
- with AskCompletionAt {
+ with AskTypeCompletionAt {
override def runTest() {
askAllSources(HyperlinkMarker) { pos =>
@@ -97,4 +130,4 @@ private[tests] trait CoreTestDefs
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala
index ba1722382b..8698ada4ad 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/TestMarker.scala
@@ -20,7 +20,9 @@ abstract case class TestMarker(val marker: String) {
TestMarker.checkForDuplicate(this)
}
-object CompletionMarker extends TestMarker("/*!*/")
+object TypeCompletionMarker extends TestMarker("/*!*/")
+
+object ScopeCompletionMarker extends TestMarker("/*_*/")
object TypeMarker extends TestMarker("/*?*/")
diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check
index 3a08e2a2ea..9a92c40609 100644
--- a/test/files/presentation/callcc-interpreter.check
+++ b/test/files/presentation/callcc-interpreter.check
@@ -2,7 +2,7 @@ reload: CallccInterpreter.scala
askTypeCompletion at CallccInterpreter.scala(51,38)
================================================================================
-[response] aksTypeCompletion at (51,38)
+[response] askTypeCompletion at (51,38)
retrieved 64 members
[accessible: true] `class AddcallccInterpreter.Add`
[accessible: true] `class AppcallccInterpreter.App`
diff --git a/test/files/presentation/completion-implicit-chained.check b/test/files/presentation/completion-implicit-chained.check
index 6d30a61cf9..24417cfa46 100644
--- a/test/files/presentation/completion-implicit-chained.check
+++ b/test/files/presentation/completion-implicit-chained.check
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(11,16)
================================================================================
-[response] aksTypeCompletion at (11,16)
+[response] askTypeCompletion at (11,16)
retrieved 24 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check
index 44a3207d75..ada307d0b2 100644
--- a/test/files/presentation/ide-bug-1000349.check
+++ b/test/files/presentation/ide-bug-1000349.check
@@ -2,7 +2,7 @@ reload: CompletionOnEmptyArgMethod.scala
askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17)
================================================================================
-[response] aksTypeCompletion at (2,17)
+[response] askTypeCompletion at (2,17)
retrieved 37 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check
index 34c3b557d8..07902727e3 100644
--- a/test/files/presentation/ide-bug-1000475.check
+++ b/test/files/presentation/ide-bug-1000475.check
@@ -2,7 +2,7 @@ reload: Foo.scala
askTypeCompletion at Foo.scala(3,7)
================================================================================
-[response] aksTypeCompletion at (3,7)
+[response] askTypeCompletion at (3,7)
retrieved 36 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -40,7 +40,7 @@ retrieved 36 members
askTypeCompletion at Foo.scala(6,10)
================================================================================
-[response] aksTypeCompletion at (6,10)
+[response] askTypeCompletion at (6,10)
retrieved 36 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -78,7 +78,7 @@ retrieved 36 members
askTypeCompletion at Foo.scala(7,7)
================================================================================
-[response] aksTypeCompletion at (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 36 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check
index 4be98a6b21..a28ecb3437 100644
--- a/test/files/presentation/ide-bug-1000531.check
+++ b/test/files/presentation/ide-bug-1000531.check
@@ -2,7 +2,7 @@ reload: CrashOnLoad.scala
askTypeCompletion at CrashOnLoad.scala(6,12)
================================================================================
-[response] aksTypeCompletion at (6,12)
+[response] askTypeCompletion at (6,12)
retrieved 126 members
[accessible: true] `class GroupedIteratorIterator[B]#GroupedIterator`
[accessible: true] `method !=(x$1: Any)Boolean`
diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check
index 05d6f61699..111d06dfa8 100644
--- a/test/files/presentation/implicit-member.check
+++ b/test/files/presentation/implicit-member.check
@@ -2,7 +2,7 @@ reload: ImplicitMember.scala
askTypeCompletion at ImplicitMember.scala(7,7)
================================================================================
-[response] aksTypeCompletion at (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 39 members
[accessible: true] `class AppliedImplicitImplicit.AppliedImplicit`
[accessible: true] `method !=(x$1: Any)Boolean`
diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check
index b666d51de5..f714c1b4da 100644
--- a/test/files/presentation/ping-pong.check
+++ b/test/files/presentation/ping-pong.check
@@ -2,7 +2,7 @@ reload: PingPong.scala
askTypeCompletion at PingPong.scala(10,23)
================================================================================
-[response] aksTypeCompletion at (10,23)
+[response] askTypeCompletion at (10,23)
retrieved 40 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -43,7 +43,7 @@ retrieved 40 members
askTypeCompletion at PingPong.scala(19,20)
================================================================================
-[response] aksTypeCompletion at (19,20)
+[response] askTypeCompletion at (19,20)
retrieved 40 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check
index c6d4762635..fe43f83cf4 100644
--- a/test/files/presentation/t5708.check
+++ b/test/files/presentation/t5708.check
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(17,9)
================================================================================
-[response] aksTypeCompletion at (17,9)
+[response] askTypeCompletion at (17,9)
retrieved 44 members
[accessible: true] `lazy value fooInt`
[accessible: true] `method !=(x$1: Any)Boolean`
diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check
index 3026e58f7e..221e3fc6a0 100644
--- a/test/files/presentation/visibility.check
+++ b/test/files/presentation/visibility.check
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(14,12)
================================================================================
-[response] aksTypeCompletion at (14,12)
+[response] askTypeCompletion at (14,12)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -46,7 +46,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(16,11)
================================================================================
-[response] aksTypeCompletion at (16,11)
+[response] askTypeCompletion at (16,11)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -90,7 +90,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(22,11)
================================================================================
-[response] aksTypeCompletion at (22,11)
+[response] askTypeCompletion at (22,11)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -134,7 +134,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(28,10)
================================================================================
-[response] aksTypeCompletion at (28,10)
+[response] askTypeCompletion at (28,10)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -178,7 +178,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(37,8)
================================================================================
-[response] aksTypeCompletion at (37,8)
+[response] askTypeCompletion at (37,8)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`