Skip to content

Commit

Permalink
Add NotebookDocumentService getter and tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Brown <[email protected]>
  • Loading branch information
Matthew Brown authored and Matthew Brown committed Jul 4, 2022
1 parent 68ced59 commit da79045
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ default void initialized() {
@JsonNotification
void exit();

/**
* Provides access to the notebookDocument services.
*/
@JsonDelegate
NotebookDocumentService getNotebookDocumentService();

/**
* Provides access to the textDocument services.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletionException
import java.util.concurrent.TimeUnit
import org.eclipse.lsp4j.DidChangeConfigurationParams
import org.eclipse.lsp4j.DidChangeNotebookDocumentParams
import org.eclipse.lsp4j.DidChangeTextDocumentParams
import org.eclipse.lsp4j.DidChangeWatchedFilesParams
import org.eclipse.lsp4j.DidCloseNotebookDocumentParams
import org.eclipse.lsp4j.DidCloseTextDocumentParams
import org.eclipse.lsp4j.DidOpenNotebookDocumentParams
import org.eclipse.lsp4j.DidOpenTextDocumentParams
import org.eclipse.lsp4j.DidSaveNotebookDocumentParams
import org.eclipse.lsp4j.DidSaveTextDocumentParams
import org.eclipse.lsp4j.HoverParams
import org.eclipse.lsp4j.InitializeParams
Expand All @@ -36,6 +40,7 @@ import org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint
import org.eclipse.lsp4j.launch.LSPLauncher
import org.eclipse.lsp4j.services.LanguageClient
import org.eclipse.lsp4j.services.LanguageServer
import org.eclipse.lsp4j.services.NotebookDocumentService
import org.eclipse.lsp4j.services.TextDocumentService
import org.eclipse.lsp4j.services.WorkspaceService
import org.eclipse.xtend.lib.annotations.Accessors
Expand Down Expand Up @@ -108,6 +113,12 @@ class LSPEndpointTest {

@Accessors
private static class DummyServer implements LanguageServer {
val notebookDocumentService = new NotebookDocumentService {
override didChange(DidChangeNotebookDocumentParams params) {}
override didClose(DidCloseNotebookDocumentParams params) {}
override didOpen(DidOpenNotebookDocumentParams params) {}
override didSave(DidSaveNotebookDocumentParams params) {}
}

val textDocumentService = new TextDocumentService {
override didChange(DidChangeTextDocumentParams params) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@
import java.util.concurrent.CompletableFuture;

import org.eclipse.lsp4j.DidChangeConfigurationParams;
import org.eclipse.lsp4j.DidChangeNotebookDocumentParams;
import org.eclipse.lsp4j.DidChangeTextDocumentParams;
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
import org.eclipse.lsp4j.DidCloseNotebookDocumentParams;
import org.eclipse.lsp4j.DidCloseTextDocumentParams;
import org.eclipse.lsp4j.DidOpenNotebookDocumentParams;
import org.eclipse.lsp4j.DidOpenTextDocumentParams;
import org.eclipse.lsp4j.DidSaveNotebookDocumentParams;
import org.eclipse.lsp4j.DidSaveTextDocumentParams;
import org.eclipse.lsp4j.InitializeParams;
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.WorkDoneProgressCancelParams;
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.lsp4j.services.NotebookDocumentService;
import org.eclipse.lsp4j.services.TextDocumentService;
import org.eclipse.lsp4j.services.WorkspaceService;

public class MockLanguageServer implements LanguageServer, TextDocumentService, WorkspaceService {
public class MockLanguageServer implements LanguageServer, NotebookDocumentService, TextDocumentService, WorkspaceService {

@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
Expand All @@ -42,6 +47,11 @@ public CompletableFuture<Object> shutdown() {
public void exit() {
}

@Override
public NotebookDocumentService getNotebookDocumentService() {
return this;
}

@Override
public TextDocumentService getTextDocumentService() {
return this;
Expand Down Expand Up @@ -76,6 +86,22 @@ public void didClose(DidCloseTextDocumentParams params) {
public void didSave(DidSaveTextDocumentParams params) {
}

@Override
public void didOpen(DidOpenNotebookDocumentParams params) {
}

@Override
public void didChange(DidChangeNotebookDocumentParams params) {
}

@Override
public void didClose(DidCloseNotebookDocumentParams params) {
}

@Override
public void didSave(DidSaveNotebookDocumentParams params) {
}

@Override
public void cancelProgress(WorkDoneProgressCancelParams params) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint;
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints;
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.lsp4j.services.NotebookDocumentService;
import org.eclipse.lsp4j.services.TextDocumentService;
import org.eclipse.lsp4j.services.WorkspaceService;
import org.eclipse.lsp4j.test.LogMessageAccumulator;
Expand Down Expand Up @@ -83,6 +84,11 @@ public void exit() {
throw new UnsupportedOperationException();
}

@Override
public NotebookDocumentService getNotebookDocumentService() {
return null;
}

@Override
public TextDocumentService getTextDocumentService() {
return null;
Expand Down

0 comments on commit da79045

Please sign in to comment.