[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

@@ -6,9 +6,10 @@
import * as path from 'path';
import { workspace, languages, ExtensionContext, extensions, Uri } from 'vscode';
import { workspace, languages, ExtensionContext, extensions, Uri, Range } from 'vscode';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType } from 'vscode-languageclient';
import TelemetryReporter from 'vscode-extension-telemetry';
import { activateColorDecorations } from "./colorDecorators";
import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
@@ -17,6 +18,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');
}
export interface ISchemaAssociations {
[pattern: string]: string[];
}
@@ -81,6 +86,15 @@ export function activate(context: ExtensionContext) {
});
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
let colorRequestor = (uri: string) => {
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange));
};
let isDecoratorEnabled = (languageId: string) => {
return workspace.getConfiguration().get<boolean>(languageId + '.colorDecorators.enable');
};
disposable = activateColorDecorations(colorRequestor, { json: true }, isDecoratorEnabled);
context.subscriptions.push(disposable);
});
// Push the disposable to the context's subscriptions so that the