Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions jvm/src/main/scala/kiama/util/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ trait LanguageService[N] {
def getSymbols(source: Source): Option[Vector[DocumentSymbol]] =
None

/**
* Return the corresponding completion items of the symbol at the
* given position (if any).
*/
def getCompletion(position: Position): Option[Vector[CompletionItem]] =
None

/**
* The parameters are passed as an array, potentially containing gson.Json objects or primitives.
* The first argument is required to be { uri: String } and used to obtain the source.
Expand Down Expand Up @@ -454,6 +461,7 @@ class Services[N, C <: Config, M <: Message](
serverCapabilities.setDocumentSymbolProvider(true)
serverCapabilities.setHoverProvider(true)
serverCapabilities.setReferencesProvider(true)
serverCapabilities.setCompletionProvider(new CompletionOptions)
serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Full)
new InitializeResult(serverCapabilities)
}
Expand Down Expand Up @@ -608,6 +616,18 @@ class Services[N, C <: Config, M <: Message](
) yield locations.toArray
).getOrElse(null)
)

@JsonNotification("textDocument/completion")
def completion(params: CompletionParams): CompletableFuture[Array[CompletionItem]] =
CompletableFutures.computeAsync(
(_: CancelChecker) =>
(
for (
position <- positionOfNotification(params.getTextDocument, params.getPosition);
completion <- server.getCompletion(position)
) yield completion.toArray
).getOrElse(null)
)

@JsonNotification("workspace/executeCommand")
def commands(params: ExecuteCommandParams): CompletableFuture[Any] =
Expand Down