summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-11-22 21:06:40 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-11-22 21:12:20 +1000
commit76155fa4e9ef103de4b8283097f6cde18c6f1e08 (patch)
treede2e99a568bab8d9e15210d3945562f3c83feb25 /test/junit
parent35f8908c214b5458ffe32c782dc81055773f5fb4 (diff)
downloadscala-76155fa4e9ef103de4b8283097f6cde18c6f1e08.tar.gz
scala-76155fa4e9ef103de4b8283097f6cde18c6f1e08.tar.bz2
scala-76155fa4e9ef103de4b8283097f6cde18c6f1e08.zip
Improve performance of REPL autocompletion
The code used to fuzzily match, e.g, `declasses` with `getDeclaredClasses` was exploring fruitless parts of the search space. The enclosed test case was hanging the REPL. This commit improves this by performing a prefix match of the unconsumed input against the current chunk of the candidate before exploring the `inits`. Fixes scala/scala-dev#271
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/tools/nsc/interpreter/CompletionTest.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala
index 78ebb7cf9c..7c37be126d 100644
--- a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala
+++ b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala
@@ -174,6 +174,14 @@ class CompletionTest {
checkExact(completer, "case class D(a: Int, b: Int) { this.a")("a", "asInstanceOf")
}
+ @Test
+ def performanceOfLenientMatch(): Unit = {
+ val intp = newIMain()
+ val completer = new PresentationCompilerCompleter(intp)
+ val ident: String = "thisIsAReallyLongMethodNameWithManyManyManyManyChunks"
+ checkExact(completer, s"($ident: Int) => tia")(ident)
+ }
+
def checkExact(completer: PresentationCompilerCompleter, before: String, after: String = "")(expected: String*): Unit = {
assertEquals(expected.toSet, completer.complete(before, after).candidates.toSet)
}