mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 23:13:02 +01:00
update dependencies, adopt textdocument
This commit is contained in:
parent
a819bbcf45
commit
24a660f022
5 changed files with 56 additions and 39 deletions
|
|
@ -9,7 +9,6 @@ import IWorkerContext = monaco.worker.IWorkerContext;
|
|||
import Thenable = monaco.Thenable;
|
||||
|
||||
import * as htmlService from 'vscode-html-languageservice';
|
||||
import * as ls from 'vscode-languageserver-types';
|
||||
|
||||
import * as poli from './fillers/polyfills';
|
||||
|
||||
|
|
@ -29,53 +28,53 @@ export class HTMLWorker {
|
|||
this._languageService = htmlService.getLanguageService();
|
||||
}
|
||||
|
||||
doValidation(uri: string): Thenable<ls.Diagnostic[]> {
|
||||
doValidation(uri: string): Thenable<htmlService.Diagnostic[]> {
|
||||
// not yet suported
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
doComplete(uri: string, position: ls.Position): Thenable<ls.CompletionList> {
|
||||
doComplete(uri: string, position: htmlService.Position): Thenable<htmlService.CompletionList> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||
return Promise.resolve(this._languageService.doComplete(document, position, htmlDocument, this._languageSettings && this._languageSettings.suggest));
|
||||
}
|
||||
format(uri: string, range: ls.Range, options: ls.FormattingOptions): Thenable<ls.TextEdit[]> {
|
||||
format(uri: string, range: htmlService.Range, options: htmlService.FormattingOptions): Thenable<htmlService.TextEdit[]> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let textEdits = this._languageService.format(document, range, this._languageSettings && this._languageSettings.format);
|
||||
return Promise.resolve(textEdits);
|
||||
}
|
||||
doHover(uri: string, position: ls.Position): Thenable<ls.Hover> {
|
||||
doHover(uri: string, position: htmlService.Position): Thenable<htmlService.Hover> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||
let hover = this._languageService.doHover(document, position, htmlDocument);
|
||||
return Promise.resolve(hover);
|
||||
}
|
||||
findDocumentHighlights(uri: string, position: ls.Position): Thenable<ls.DocumentHighlight[]> {
|
||||
findDocumentHighlights(uri: string, position: htmlService.Position): Thenable<htmlService.DocumentHighlight[]> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||
let highlights = this._languageService.findDocumentHighlights(document, position, htmlDocument);
|
||||
return Promise.resolve(highlights);
|
||||
}
|
||||
findDocumentLinks(uri: string): Thenable<ls.DocumentLink[]> {
|
||||
findDocumentLinks(uri: string): Thenable<htmlService.DocumentLink[]> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let links = this._languageService.findDocumentLinks(document, null);
|
||||
return Promise.resolve(links);
|
||||
}
|
||||
findDocumentSymbols(uri: string): Thenable<ls.SymbolInformation[]> {
|
||||
findDocumentSymbols(uri: string): Thenable<htmlService.SymbolInformation[]> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
||||
let symbols = this._languageService.findDocumentSymbols(document, htmlDocument);
|
||||
return Promise.resolve(symbols);
|
||||
}
|
||||
provideFoldingRanges(uri: string, context?: { rangeLimit?: number; }): Thenable<ls.FoldingRange[]> {
|
||||
provideFoldingRanges(uri: string, context?: { rangeLimit?: number; }): Thenable<htmlService.FoldingRange[]> {
|
||||
let document = this._getTextDocument(uri);
|
||||
let ranges = this._languageService.getFoldingRanges(document, context);
|
||||
return Promise.resolve(ranges);
|
||||
}
|
||||
private _getTextDocument(uri: string): ls.TextDocument {
|
||||
private _getTextDocument(uri: string): htmlService.TextDocument {
|
||||
let models = this._ctx.getMirrorModels();
|
||||
for (let model of models) {
|
||||
if (model.uri.toString() === uri) {
|
||||
return ls.TextDocument.create(uri, this._languageId, model.version, model.getValue());
|
||||
return htmlService.TextDocument.create(uri, this._languageId, model.version, model.getValue());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue