mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
[json] color decorators
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user