mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
[css] adopt snippettext API and update to TS2.0
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
import * as path from 'path';
|
||||
|
||||
import { languages, window, commands, ExtensionContext } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, Range, TextEdit, Protocol2Code } from 'vscode-languageclient';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, Range, TextEdit } from 'vscode-languageclient';
|
||||
import { activateColorDecorations } from './colorDecorators';
|
||||
|
||||
import * as nls from 'vscode-nls';
|
||||
let localize = nls.loadMessageBundle();
|
||||
|
||||
namespace ColorSymbolRequest {
|
||||
export const type: RequestType<string, Range[], any> = { get method() { return 'css/colorSymbols'; } };
|
||||
export const type: RequestType<string, Range[], any, any> = { get method() { return 'css/colorSymbols'; }, _: null };
|
||||
}
|
||||
|
||||
// this method is called when vs code is activated
|
||||
@@ -51,7 +51,7 @@ export function activate(context: ExtensionContext) {
|
||||
context.subscriptions.push(disposable);
|
||||
|
||||
let colorRequestor = (uri: string) => {
|
||||
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(Protocol2Code.asRange));
|
||||
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange));
|
||||
};
|
||||
disposable = activateColorDecorations(colorRequestor, { css: true, scss: true, less: true });
|
||||
context.subscriptions.push(disposable);
|
||||
@@ -69,23 +69,23 @@ export function activate(context: ExtensionContext) {
|
||||
});
|
||||
|
||||
commands.registerCommand('_css.applyCodeAction', applyCodeAction);
|
||||
}
|
||||
|
||||
function applyCodeAction(uri: string, documentVersion: number, edits: TextEdit[]) {
|
||||
let textEditor = window.activeTextEditor;
|
||||
if (textEditor && textEditor.document.uri.toString() === uri) {
|
||||
if (textEditor.document.version !== documentVersion) {
|
||||
window.showInformationMessage(`CSS fix is outdated and can't be applied to the document.`);
|
||||
function applyCodeAction(uri: string, documentVersion: number, edits: TextEdit[]) {
|
||||
let textEditor = window.activeTextEditor;
|
||||
if (textEditor && textEditor.document.uri.toString() === uri) {
|
||||
if (textEditor.document.version !== documentVersion) {
|
||||
window.showInformationMessage(`CSS fix is outdated and can't be applied to the document.`);
|
||||
}
|
||||
textEditor.edit(mutator => {
|
||||
for (let edit of edits) {
|
||||
mutator.replace(client.protocol2CodeConverter.asRange(edit.range), edit.newText);
|
||||
}
|
||||
}).then(success => {
|
||||
if (!success) {
|
||||
window.showErrorMessage('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.');
|
||||
}
|
||||
});
|
||||
}
|
||||
textEditor.edit(mutator => {
|
||||
for (let edit of edits) {
|
||||
mutator.replace(Protocol2Code.asRange(edit.range), edit.newText);
|
||||
}
|
||||
}).then(success => {
|
||||
if (!success) {
|
||||
window.showErrorMessage('Failed to apply CSS fix to the document. Please consider opening an issue with steps to reproduce.');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
extensions/css/client/src/typings/ref.d.ts
vendored
7
extensions/css/client/src/typings/ref.d.ts
vendored
@@ -3,9 +3,4 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../../src/typings/mocha.d.ts'/>
|
||||
/// <reference path='../../../../../extensions/node.d.ts'/>
|
||||
/// <reference path='../../../../../extensions/lib.core.d.ts'/>
|
||||
/// <reference path='../../../../../extensions/declares.d.ts'/>
|
||||
/// <reference path='../../../node_modules/vscode-languageclient/lib/main.d.ts'/>
|
||||
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
|
||||
Reference in New Issue
Block a user