volar-service-html 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/index.js +3 -63
  2. package/package.json +2 -2
package/out/index.js CHANGED
@@ -1,31 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.create = exports.getHtmlDocument = void 0;
27
- const html = __importStar(require("vscode-html-languageservice"));
28
- const path = __importStar(require("path"));
4
+ const html = require("vscode-html-languageservice");
5
+ const path = require("path");
29
6
  const vscode_uri_1 = require("vscode-uri");
30
7
  const parserLs = html.getLanguageService();
31
8
  const htmlDocuments = new WeakMap();
@@ -132,12 +109,7 @@ function create({ languageId = 'html', useDefaultDataProvider = true, useCustomD
132
109
  },
133
110
  provideDocumentSymbols(document) {
134
111
  return worker(document, (htmlDocument) => {
135
- // TODO: wait for https://github.com/microsoft/vscode-html-languageservice/pull/152
136
- const symbols = [];
137
- htmlDocument.roots.forEach(node => {
138
- provideFileSymbolsInternal(document, node, symbols);
139
- });
140
- return symbols;
112
+ return htmlLs.findDocumentSymbols2(document, htmlDocument);
141
113
  });
142
114
  },
143
115
  provideFoldingRanges(document) {
@@ -305,36 +277,4 @@ const NL = '\n'.charCodeAt(0);
305
277
  function isNewlineCharacter(charCode) {
306
278
  return charCode === CR || charCode === NL;
307
279
  }
308
- function provideFileSymbolsInternal(document, node, symbols) {
309
- const name = nodeToName(node);
310
- const range = {
311
- start: document.positionAt(node.start),
312
- end: document.positionAt(node.end),
313
- };
314
- const symbol = {
315
- name,
316
- kind: 8,
317
- range,
318
- selectionRange: range,
319
- };
320
- symbols.push(symbol);
321
- node.children.forEach(child => {
322
- symbol.children ??= [];
323
- provideFileSymbolsInternal(document, child, symbol.children);
324
- });
325
- }
326
- function nodeToName(node) {
327
- let name = node.tag;
328
- if (node.attributes) {
329
- const id = node.attributes['id'];
330
- const classes = node.attributes['class'];
331
- if (id) {
332
- name += `#${id.replace(/[\"\']/g, '')}`;
333
- }
334
- if (classes) {
335
- name += classes.replace(/[\"\']/g, '').split(/\s+/).map(className => `.${className}`).join('');
336
- }
337
- }
338
- return name || '?';
339
- }
340
280
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-html",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "Integrate vscode-languageservice-html into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/html",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -39,5 +39,5 @@
39
39
  "optional": true
40
40
  }
41
41
  },
42
- "gitHead": "6fb81d23ead08b2fdb0812b272216ced8497aed0"
42
+ "gitHead": "3a59378715a959b433ca65700d2515d708469388"
43
43
  }