|
|
@ -4,7 +4,6 @@
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
import Thenable = monaco.Thenable;
|
|
|
|
|
|
|
|
import IWorkerContext = monaco.worker.IWorkerContext;
|
|
|
|
import IWorkerContext = monaco.worker.IWorkerContext;
|
|
|
|
|
|
|
|
|
|
|
|
import * as cssService from 'vscode-css-languageservice';
|
|
|
|
import * as cssService from 'vscode-css-languageservice';
|
|
|
@ -40,7 +39,7 @@ export class CSSWorker {
|
|
|
|
|
|
|
|
|
|
|
|
// --- language service host ---------------
|
|
|
|
// --- language service host ---------------
|
|
|
|
|
|
|
|
|
|
|
|
doValidation(uri: string): Thenable<cssService.Diagnostic[]> {
|
|
|
|
async doValidation(uri: string): Promise<cssService.Diagnostic[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
if (document) {
|
|
|
|
if (document) {
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
@ -49,72 +48,72 @@ export class CSSWorker {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Promise.resolve([]);
|
|
|
|
return Promise.resolve([]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doComplete(uri: string, position: cssService.Position): Thenable<cssService.CompletionList> {
|
|
|
|
async doComplete(uri: string, position: cssService.Position): Promise<cssService.CompletionList> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let completions = this._languageService.doComplete(document, position, stylesheet);
|
|
|
|
let completions = this._languageService.doComplete(document, position, stylesheet);
|
|
|
|
return Promise.resolve(completions);
|
|
|
|
return Promise.resolve(completions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doHover(uri: string, position: cssService.Position): Thenable<cssService.Hover> {
|
|
|
|
async doHover(uri: string, position: cssService.Position): Promise<cssService.Hover> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let hover = this._languageService.doHover(document, position, stylesheet);
|
|
|
|
let hover = this._languageService.doHover(document, position, stylesheet);
|
|
|
|
return Promise.resolve(hover);
|
|
|
|
return Promise.resolve(hover);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
findDefinition(uri: string, position: cssService.Position): Thenable<cssService.Location> {
|
|
|
|
async findDefinition(uri: string, position: cssService.Position): Promise<cssService.Location> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let definition = this._languageService.findDefinition(document, position, stylesheet);
|
|
|
|
let definition = this._languageService.findDefinition(document, position, stylesheet);
|
|
|
|
return Promise.resolve(definition);
|
|
|
|
return Promise.resolve(definition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
findReferences(uri: string, position: cssService.Position): Thenable<cssService.Location[]> {
|
|
|
|
async findReferences(uri: string, position: cssService.Position): Promise<cssService.Location[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let references = this._languageService.findReferences(document, position, stylesheet);
|
|
|
|
let references = this._languageService.findReferences(document, position, stylesheet);
|
|
|
|
return Promise.resolve(references);
|
|
|
|
return Promise.resolve(references);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
findDocumentHighlights(uri: string, position: cssService.Position): Thenable<cssService.DocumentHighlight[]> {
|
|
|
|
async findDocumentHighlights(uri: string, position: cssService.Position): Promise<cssService.DocumentHighlight[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let highlights = this._languageService.findDocumentHighlights(document, position, stylesheet);
|
|
|
|
let highlights = this._languageService.findDocumentHighlights(document, position, stylesheet);
|
|
|
|
return Promise.resolve(highlights);
|
|
|
|
return Promise.resolve(highlights);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
findDocumentSymbols(uri: string): Thenable<cssService.SymbolInformation[]> {
|
|
|
|
async findDocumentSymbols(uri: string): Promise<cssService.SymbolInformation[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let symbols = this._languageService.findDocumentSymbols(document, stylesheet);
|
|
|
|
let symbols = this._languageService.findDocumentSymbols(document, stylesheet);
|
|
|
|
return Promise.resolve(symbols);
|
|
|
|
return Promise.resolve(symbols);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doCodeActions(uri: string, range: cssService.Range, context: cssService.CodeActionContext): Thenable<cssService.Command[]> {
|
|
|
|
async doCodeActions(uri: string, range: cssService.Range, context: cssService.CodeActionContext): Promise<cssService.Command[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let actions = this._languageService.doCodeActions(document, range, context, stylesheet);
|
|
|
|
let actions = this._languageService.doCodeActions(document, range, context, stylesheet);
|
|
|
|
return Promise.resolve(actions);
|
|
|
|
return Promise.resolve(actions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
findDocumentColors(uri: string): Thenable<cssService.ColorInformation[]> {
|
|
|
|
async findDocumentColors(uri: string): Promise<cssService.ColorInformation[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
|
|
|
|
let colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
|
|
|
|
return Promise.resolve(colorSymbols);
|
|
|
|
return Promise.resolve(colorSymbols);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getColorPresentations(uri: string, color: cssService.Color, range: cssService.Range): Thenable<cssService.ColorPresentation[]> {
|
|
|
|
async getColorPresentations(uri: string, color: cssService.Color, range: cssService.Range): Promise<cssService.ColorPresentation[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let colorPresentations = this._languageService.getColorPresentations(document, stylesheet, color, range);
|
|
|
|
let colorPresentations = this._languageService.getColorPresentations(document, stylesheet, color, range);
|
|
|
|
return Promise.resolve(colorPresentations);
|
|
|
|
return Promise.resolve(colorPresentations);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getFoldingRanges(uri: string, context?: { rangeLimit?: number; }): Thenable<cssService.FoldingRange[]> {
|
|
|
|
async getFoldingRanges(uri: string, context?: { rangeLimit?: number; }): Promise<cssService.FoldingRange[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let ranges = this._languageService.getFoldingRanges(document, context);
|
|
|
|
let ranges = this._languageService.getFoldingRanges(document, context);
|
|
|
|
return Promise.resolve(ranges);
|
|
|
|
return Promise.resolve(ranges);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getSelectionRanges(uri: string, positions: cssService.Position[]): Thenable<cssService.SelectionRange[]> {
|
|
|
|
async getSelectionRanges(uri: string, positions: cssService.Position[]): Promise<cssService.SelectionRange[]> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let ranges = this._languageService.getSelectionRanges(document, positions, stylesheet);
|
|
|
|
let ranges = this._languageService.getSelectionRanges(document, positions, stylesheet);
|
|
|
|
return Promise.resolve(ranges);
|
|
|
|
return Promise.resolve(ranges);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doRename(uri: string, position: cssService.Position, newName: string): Thenable<cssService.WorkspaceEdit> {
|
|
|
|
async doRename(uri: string, position: cssService.Position, newName: string): Promise<cssService.WorkspaceEdit> {
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let document = this._getTextDocument(uri);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let stylesheet = this._languageService.parseStylesheet(document);
|
|
|
|
let renames = this._languageService.doRename(document, position, newName, stylesheet);
|
|
|
|
let renames = this._languageService.doRename(document, position, newName, stylesheet);
|
|
|
|