Skip to content

Commit

Permalink
fix #24: get rid of vscode-base-languageclient
Browse files Browse the repository at this point in the history
vscode compatiblity layer is introduced to make use of vscode-languageclient directly instead of vscode-base-languageclient.

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Jul 24, 2018
1 parent b79d075 commit dff0e38
Show file tree
Hide file tree
Showing 22 changed files with 4,523 additions and 1,127 deletions.
3,049 changes: 2,064 additions & 985 deletions example/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"rimraf": "^2.6.2",
"source-map-loader": "^0.2.3",
"style-loader": "^0.20.3",
"typescript": "^2.7.2",
"typescript": "^2.9.2",
"uglifyjs-webpack-plugin": "^1.2.4",
"webpack": "^3.11.0",
"webpack-merge": "^4.1.2"
Expand Down
15 changes: 8 additions & 7 deletions example/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* ------------------------------------------------------------------------------------------ */
import { listen, MessageConnection } from 'vscode-ws-jsonrpc';
import {
BaseLanguageClient, CloseAction, ErrorAction,
createMonacoServices, createConnection
LanguageClient, CloseAction, ErrorAction,
MonacoServices, createConnection
} from 'monaco-languageclient';
import normalizeUrl = require('normalize-url');
const ReconnectingWebSocket = require('reconnecting-websocket');
Expand All @@ -31,6 +31,9 @@ const editor = monaco.editor.create(document.getElementById("container")!, {
}
});

// install Monaco language client services
MonacoServices.install(editor);

// create the web socket
const url = createUrl('/sampleServer')
const webSocket = createWebSocket(url);
Expand All @@ -45,9 +48,8 @@ listen({
}
});

const services = createMonacoServices(editor);
function createLanguageClient(connection: MessageConnection): BaseLanguageClient {
return new BaseLanguageClient({
function createLanguageClient(connection: MessageConnection): LanguageClient {
return new LanguageClient({
name: "Sample Language Client",
clientOptions: {
// use a language id as a document selector
Expand All @@ -58,14 +60,13 @@ function createLanguageClient(connection: MessageConnection): BaseLanguageClient
closed: () => CloseAction.DoNotRestart
}
},
services,
// create a language client connection from the JSON RPC connection on demand
connectionProvider: {
get: (errorHandler, closeHandler) => {
return Promise.resolve(createConnection(connection, errorHandler, closeHandler))
}
}
})
});
}

function createUrl(path: string): string {
Expand Down
6 changes: 3 additions & 3 deletions example/src/json-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
TextDocument, Diagnostic, Command, CompletionList, CompletionItem, Hover,
SymbolInformation, DocumentSymbolParams, TextEdit
} from "vscode-languageserver-types";
import { TextDocumentPositionParams, DocumentRangeFormattingParams, ExecuteCommandParams, CodeActionParams } from 'vscode-base-languageclient/lib/protocol';
import { TextDocumentPositionParams, DocumentRangeFormattingParams, ExecuteCommandParams, CodeActionParams } from 'vscode-languageserver-protocol';
import { getLanguageService, LanguageService, JSONDocument } from "vscode-json-languageservice";

export function start(reader: MessageReader, writer: MessageWriter): JsonServer {
Expand Down Expand Up @@ -137,7 +137,7 @@ export class JsonServer {
}
}

protected hover(params: TextDocumentPositionParams): Thenable<Hover> {
protected hover(params: TextDocumentPositionParams): Thenable<Hover | null> {
const document = this.documents.get(params.textDocument.uri);
const jsonDocument = this.getJSONDocument(document);
return this.jsonService.doHover(document, params.position, jsonDocument);
Expand All @@ -163,7 +163,7 @@ export class JsonServer {
return this.jsonService.doResolve(item);
}

protected completion(params: TextDocumentPositionParams): Thenable<CompletionList> {
protected completion(params: TextDocumentPositionParams): Thenable<CompletionList | null> {
const document = this.documents.get(params.textDocument.uri);
const jsonDocument = this.getJSONDocument(document);
return this.jsonService.doComplete(document, params.position, jsonDocument);
Expand Down
5 changes: 5 additions & 0 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const common = {
child_process: 'empty',
net: 'empty',
crypto: 'empty'
},
resolve: {
alias: {
'vscode': 'monaco-languageclient/lib/vscode-compatibility'
}
}
};

Expand Down
Loading

0 comments on commit dff0e38

Please sign in to comment.