This commit is contained in:
Pine Wu
2019-11-22 10:16:38 -08:00
parent 6b78be0286
commit 0d25d0a798
9 changed files with 196 additions and 6 deletions

View File

@@ -10,7 +10,7 @@
"main": "./out/htmlServerMain",
"dependencies": {
"vscode-css-languageservice": "^4.0.3-next.20",
"vscode-html-languageservice": "^3.0.4-next.9",
"vscode-html-languageservice": "^3.0.4-next.10",
"vscode-languageserver": "^6.0.0-next.3",
"vscode-nls": "^4.1.1",
"vscode-uri": "^2.0.3"

View File

@@ -24,6 +24,9 @@ import { getDataProviders } from './customData';
namespace TagCloseRequest {
export const type: RequestType<TextDocumentPositionParams, string | null, any, any> = new RequestType('html/tag');
}
namespace MatchingTagPositionRequest {
export const type: RequestType<TextDocumentPositionParams, Position | null, any, any> = new RequestType('html/matchingTagPosition');
}
// Create a connection for the server
const connection: IConnection = createConnection();
@@ -485,5 +488,21 @@ connection.onRenameRequest((params, token) => {
}, null, `Error while computing rename for ${params.textDocument.uri}`, token);
});
connection.onRequest(MatchingTagPositionRequest.type, (params, token) => {
return runSafe(() => {
const document = documents.get(params.textDocument.uri);
if (document) {
const pos = params.position;
if (pos.character > 0) {
const mode = languageModes.getModeAtPosition(document, Position.create(pos.line, pos.character - 1));
if (mode && mode.findMatchingTagPosition) {
return mode.findMatchingTagPosition(document, pos);
}
}
}
return null;
}, null, `Error while computing matching tag position for ${params.textDocument.uri}`, token);
});
// Listen on the connection
connection.listen();

View File

@@ -81,6 +81,10 @@ export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace:
onDocumentRemoved(document: TextDocument) {
htmlDocuments.onDocumentRemoved(document);
},
findMatchingTagPosition(document: TextDocument, position: Position) {
const htmlDocument = htmlDocuments.get(document);
return htmlLanguageService.findMatchingTagPosition(document, position, htmlDocument);
},
dispose() {
htmlDocuments.dispose();
}

View File

@@ -48,6 +48,7 @@ export interface LanguageMode {
findDocumentColors?: (document: TextDocument) => ColorInformation[];
getColorPresentations?: (document: TextDocument, color: Color, range: Range) => ColorPresentation[];
doAutoClose?: (document: TextDocument, position: Position) => string | null;
findMatchingTagPosition?: (document: TextDocument, position: Position) => Position | null;
getFoldingRanges?: (document: TextDocument) => FoldingRange[];
onDocumentRemoved(document: TextDocument): void;
dispose(): void;

View File

@@ -621,10 +621,10 @@ vscode-css-languageservice@^4.0.3-next.20:
vscode-nls "^4.1.1"
vscode-uri "^2.1.1"
vscode-html-languageservice@^3.0.4-next.9:
version "3.0.4-next.9"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.0.4-next.9.tgz#b27f26c29f3af64fa32eabb7425749f95f64036a"
integrity sha512-9V9G7508ybFcn9gQpuucEZIGv8kKlBMEVD8lFFWwWS1yEonKchsxIGJZFbmSGr/n//2anfya8F8yL5ybKuWIRA==
vscode-html-languageservice@^3.0.4-next.10:
version "3.0.4-next.10"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.0.4-next.10.tgz#da426326833770c51712abb2c7473b9b30bf1cbc"
integrity sha512-8P0QBtMPJ9nDMhW8MF/z+5JGg6rK6UOa9po18KIleNuV0rDHU9CAqDyUjxW0CEfLrHYz6dQdkW12ZTClvQnNHw==
dependencies:
vscode-languageserver-textdocument "^1.0.0-next.4"
vscode-languageserver-types "^3.15.0-next.6"