|
@@ -9,7 +9,6 @@ import IWorkerContext = monaco.worker.IWorkerContext;
|
|
import Thenable = monaco.Thenable;
|
|
import Thenable = monaco.Thenable;
|
|
|
|
|
|
import * as htmlService from 'vscode-html-languageservice';
|
|
import * as htmlService from 'vscode-html-languageservice';
|
|
-import * as ls from 'vscode-languageserver-types';
|
|
|
|
|
|
|
|
import * as poli from './fillers/polyfills';
|
|
import * as poli from './fillers/polyfills';
|
|
|
|
|
|
@@ -29,53 +28,53 @@ export class HTMLWorker {
|
|
this._languageService = htmlService.getLanguageService();
|
|
this._languageService = htmlService.getLanguageService();
|
|
}
|
|
}
|
|
|
|
|
|
- doValidation(uri: string): Thenable<ls.Diagnostic[]> {
|
|
|
|
|
|
+ doValidation(uri: string): Thenable<htmlService.Diagnostic[]> {
|
|
// not yet suported
|
|
// not yet suported
|
|
return Promise.resolve([]);
|
|
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 document = this._getTextDocument(uri);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
return Promise.resolve(this._languageService.doComplete(document, position, htmlDocument, this._languageSettings && this._languageSettings.suggest));
|
|
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 document = this._getTextDocument(uri);
|
|
let textEdits = this._languageService.format(document, range, this._languageSettings && this._languageSettings.format);
|
|
let textEdits = this._languageService.format(document, range, this._languageSettings && this._languageSettings.format);
|
|
return Promise.resolve(textEdits);
|
|
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 document = this._getTextDocument(uri);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let hover = this._languageService.doHover(document, position, htmlDocument);
|
|
let hover = this._languageService.doHover(document, position, htmlDocument);
|
|
return Promise.resolve(hover);
|
|
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 document = this._getTextDocument(uri);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let highlights = this._languageService.findDocumentHighlights(document, position, htmlDocument);
|
|
let highlights = this._languageService.findDocumentHighlights(document, position, htmlDocument);
|
|
return Promise.resolve(highlights);
|
|
return Promise.resolve(highlights);
|
|
}
|
|
}
|
|
- findDocumentLinks(uri: string): Thenable<ls.DocumentLink[]> {
|
|
|
|
|
|
+ findDocumentLinks(uri: string): Thenable<htmlService.DocumentLink[]> {
|
|
let document = this._getTextDocument(uri);
|
|
let document = this._getTextDocument(uri);
|
|
let links = this._languageService.findDocumentLinks(document, null);
|
|
let links = this._languageService.findDocumentLinks(document, null);
|
|
return Promise.resolve(links);
|
|
return Promise.resolve(links);
|
|
}
|
|
}
|
|
- findDocumentSymbols(uri: string): Thenable<ls.SymbolInformation[]> {
|
|
|
|
|
|
+ findDocumentSymbols(uri: string): Thenable<htmlService.SymbolInformation[]> {
|
|
let document = this._getTextDocument(uri);
|
|
let document = this._getTextDocument(uri);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let htmlDocument = this._languageService.parseHTMLDocument(document);
|
|
let symbols = this._languageService.findDocumentSymbols(document, htmlDocument);
|
|
let symbols = this._languageService.findDocumentSymbols(document, htmlDocument);
|
|
return Promise.resolve(symbols);
|
|
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 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);
|
|
}
|
|
}
|
|
- private _getTextDocument(uri: string): ls.TextDocument {
|
|
|
|
|
|
+ private _getTextDocument(uri: string): htmlService.TextDocument {
|
|
let models = this._ctx.getMirrorModels();
|
|
let models = this._ctx.getMirrorModels();
|
|
for (let model of models) {
|
|
for (let model of models) {
|
|
if (model.uri.toString() === uri) {
|
|
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;
|
|
return null;
|