[json] color decorators

This commit is contained in:
Martin Aeschlimann
2017-03-27 14:26:56 +02:00
parent dc009ee150
commit 7d63b291cf
9 changed files with 202 additions and 10 deletions

View File

@@ -7,7 +7,7 @@
import {
createConnection, IConnection,
TextDocuments, TextDocument, InitializeParams, InitializeResult, NotificationType, RequestType,
DocumentRangeFormattingRequest, Disposable
DocumentRangeFormattingRequest, Disposable, Range
} from 'vscode-languageserver';
import { xhr, XHRResponse, configure as configureHttpRequests, getErrorStatusDescription } from 'request-light';
@@ -34,6 +34,10 @@ namespace VSCodeContentRequest {
export const type: RequestType<string, string, any, any> = new RequestType('vscode/content');
}
namespace ColorSymbolRequest {
export const type: RequestType<string, Range[], any, any> = new RequestType('json/colorSymbols');
}
// Create a connection for the server
let connection: IConnection = createConnection();
@@ -304,5 +308,14 @@ connection.onDocumentRangeFormatting(formatParams => {
return languageService.format(document, formatParams.range, formatParams.options);
});
connection.onRequest(ColorSymbolRequest.type, uri => {
let document = documents.get(uri);
if (document) {
let jsonDocument = getJSONDocument(document);
return languageService.findColorSymbols(document, jsonDocument);
}
return [];
});
// Listen on the connection
connection.listen();