From 76155fa4e9ef103de4b8283097f6cde18c6f1e08 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 22 Nov 2016 21:06:40 +1000 Subject: 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 --- test/junit/scala/tools/nsc/interpreter/CompletionTest.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/junit') 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) } -- cgit v1.2.3