[html] update service (multi semantic selection, webpack)

This commit is contained in:
Martin Aeschlimann
2019-03-05 15:22:49 +01:00
parent c9370aeaf1
commit 8e986b18a0
11 changed files with 65 additions and 78 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IHTMLDataProvider, HTMLDataProvider } from 'vscode-html-languageservice';
import { IHTMLDataProvider, newHTMLDataProvider } from 'vscode-html-languageservice';
import * as fs from 'fs';
export function getDataProviders(dataPaths?: string[]): IHTMLDataProvider[] {
@@ -18,7 +18,7 @@ export function getDataProviders(dataPaths?: string[]): IHTMLDataProvider[] {
if (fs.existsSync(path)) {
const htmlData = JSON.parse(fs.readFileSync(path, 'utf-8'));
providers.push(new HTMLDataProvider(`customProvider${i}`, htmlData));
providers.push(newHTMLDataProvider(`customProvider${i}`, htmlData));
}
} catch (err) {
console.log(`Failed to load tag from ${path}`);

View File

@@ -455,15 +455,15 @@ connection.onFoldingRanges((params, token) => {
}, null, `Error while computing folding regions for ${params.textDocument.uri}`, token);
});
connection.onRequest('$/textDocument/selectionRange', async (params, token) => {
connection.onRequest('$/textDocument/selectionRanges', async (params, token) => {
return runSafe(() => {
const document = documents.get(params.textDocument.uri);
const position: Position = params.position;
const positions: Position[] = params.positions;
if (document) {
const htmlMode = languageModes.getMode('html');
if (htmlMode && htmlMode.doSelection) {
return htmlMode.doSelection(document, position);
if (htmlMode && htmlMode.getSelectionRanges) {
return htmlMode.getSelectionRanges(document, positions);
}
}
return Promise.resolve(null);

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { getLanguageModelCache } from '../languageModelCache';
import { LanguageService as HTMLLanguageService, HTMLDocument, DocumentContext, FormattingOptions, HTMLFormatConfiguration } from 'vscode-html-languageservice';
import { LanguageService as HTMLLanguageService, HTMLDocument, DocumentContext, FormattingOptions, HTMLFormatConfiguration, SelectionRange } from 'vscode-html-languageservice';
import { TextDocument, Position, Range, CompletionItem, FoldingRange } from 'vscode-languageserver-types';
import { LanguageMode, Workspace } from './languageModes';
import { getPathCompletionParticipant } from './pathCompletion';
@@ -15,8 +15,8 @@ export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace:
getId() {
return 'html';
},
doSelection(document: TextDocument, position: Position): Range[] {
return htmlLanguageService.getSelectionRanges(document, position);
getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[][] {
return htmlLanguageService.getSelectionRanges(document, positions);
},
doComplete(document: TextDocument, position: Position, settings = workspace.settings) {
let options = settings && settings.html && settings.html.suggest;

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { getLanguageService as getHTMLLanguageService, DocumentContext, IHTMLDataProvider } from 'vscode-html-languageservice';
import { getLanguageService as getHTMLLanguageService, DocumentContext, IHTMLDataProvider, SelectionRange } from 'vscode-html-languageservice';
import {
CompletionItem, Location, SignatureHelp, Definition, TextEdit, TextDocument, Diagnostic, DocumentLink, Range,
Hover, DocumentHighlight, CompletionList, Position, FormattingOptions, SymbolInformation, FoldingRange
@@ -31,7 +31,7 @@ export interface Workspace {
export interface LanguageMode {
getId(): string;
doSelection?: (document: TextDocument, position: Position) => Range[];
getSelectionRanges?: (document: TextDocument, positions: Position[]) => SelectionRange[][];
doValidation?: (document: TextDocument, settings?: Settings) => Diagnostic[];
doComplete?: (document: TextDocument, position: Position, settings?: Settings) => CompletionList;
doResolve?: (document: TextDocument, item: CompletionItem) => CompletionItem;