use thenable

This commit is contained in:
Martin Aeschlimann 2018-08-06 22:00:47 +02:00
parent e6f882e3f1
commit 54f904f6fe

View file

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