-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement textDocument/signatureHelper.
This feature is only triggered when opening a parentheses at a function call-site. The box disappears as soon as you write the first parameter. We reuse the completion mechanism to find the method symbol and extract the parameter lists.
- Loading branch information
Showing
6 changed files
with
163 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
metaserver/src/test/scala/tests/compiler/CompilerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package tests.compiler | ||
|
||
import scala.meta.languageserver.Compiler | ||
import scala.tools.nsc.interactive.Global | ||
import tests.MegaSuite | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
object CompilerTest extends MegaSuite { | ||
test("signatureHelp") { | ||
val compiler: Global = Compiler.newCompiler("", Nil) | ||
val TIMEOUT = 100 | ||
// very bad test, we should be calling our wrapper around the compiler | ||
// instead, see https://github.com/scalameta/language-server/issues/47 | ||
val code = | ||
""" | ||
|object a { | ||
| Predef.assert(xxx) | ||
| def xxx = 42 | ||
|} | ||
""".stripMargin | ||
val unit = Compiler.addCompilationUnit(compiler, code, "a.scala") | ||
val cursor = code.indexOf("(") | ||
val pos = unit.position(cursor) | ||
val completions = compiler.completionsAt(pos).matchingResults().distinct | ||
assert(completions.nonEmpty) | ||
val assertName = completions.head.sym.nameString | ||
assert(assertName == "assert") | ||
val assertParams = | ||
completions.head.sym.asMethod.paramLists.head.head.nameString | ||
assert(assertParams == "assertion") | ||
} | ||
} |