@volar/language-service 1.0.24 → 1.1.0-alpha.0

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.
@@ -35,7 +35,8 @@ const format = require("./documentFeatures/format");
35
35
  const linkedEditingRanges = require("./documentFeatures/linkedEditingRanges");
36
36
  const selectionRanges = require("./documentFeatures/selectionRanges");
37
37
  function createLanguageServiceContext(options) {
38
- const ts = options.host.getTypeScriptModule();
38
+ var _a, _b;
39
+ const ts = (_b = (_a = options.host).getTypeScriptModule) === null || _b === void 0 ? void 0 : _b.call(_a);
39
40
  const tsLs = ts === null || ts === void 0 ? void 0 : ts.createLanguageService(options.context.typescript.languageServiceHost, options.documentRegistry);
40
41
  if (ts && tsLs) {
41
42
  tsFaster.decorate(ts, options.context.typescript.languageServiceHost, tsLs);
@@ -5,12 +5,10 @@ const transformer = require("../transformer");
5
5
  const vscode = require("vscode-languageserver-protocol");
6
6
  function register(context) {
7
7
  return (uri) => {
8
- return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, // TODO: add color capabilitie setting
9
- (plugin, document) => { var _a; return (_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => map ? transformer.asSymbolInformations(data, location => {
8
+ return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => { var _a; return (_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => map ? transformer.asSymbolInformations(data, location => {
10
9
  const range = map.toSourceRange(location.range);
11
10
  if (range) {
12
- // use document.uri instead of map.sourceDocument.uri to fix https://github.com/johnsoncodehk/volar/issues/1925
13
- return vscode.Location.create(uri, range);
11
+ return vscode.Location.create(map.sourceFileDocument.uri, range);
14
12
  }
15
13
  }) : data, arr => arr.flat());
16
14
  };
@@ -90,7 +90,7 @@ function register(context) {
90
90
  if (edits.length > 0) {
91
91
  const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
92
92
  document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
93
- context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()));
93
+ context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
94
94
  edited = true;
95
95
  }
96
96
  if (toPatchIndent) {
@@ -99,7 +99,7 @@ function register(context) {
99
99
  if (indentEdits.length > 0) {
100
100
  const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, indentEdits);
101
101
  document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
102
- context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()));
102
+ context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
103
103
  edited = true;
104
104
  }
105
105
  }
@@ -107,7 +107,7 @@ function register(context) {
107
107
  }
108
108
  if (edited) {
109
109
  // recover
110
- context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), originalSnapshot);
110
+ context.core.virtualFiles.updateSource(shared.uriToFileName(document.uri), originalSnapshot, undefined);
111
111
  }
112
112
  if (document.getText() === originalDocument.getText())
113
113
  return;
@@ -19,7 +19,7 @@ function register(context) {
19
19
  if (rootFile) {
20
20
  let tsExt;
21
21
  (0, language_core_1.forEachEmbeddedFile)(rootFile, embedded => {
22
- if (embedded.kind && embedded.fileName.replace(rootFile.fileName, '').match(/^\.(js|ts)x?$/)) {
22
+ if (embedded.kind === language_core_1.FileKind.TypeScriptHostFile && embedded.fileName.replace(rootFile.fileName, '').match(/^\.(js|ts)x?$/)) {
23
23
  tsExt = embedded.fileName.substring(embedded.fileName.lastIndexOf('.'));
24
24
  }
25
25
  });
@@ -10,14 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
12
  const vscode = require("vscode-languageserver-protocol");
13
- const common_1 = require("../utils/common");
14
13
  const featureWorkers_1 = require("../utils/featureWorkers");
15
- // https://github.com/microsoft/vscode/blob/dcf27391b7dd7c1cece483806af75b4f87188e70/extensions/html/language-configuration.json#L35
16
- const htmlWordPatterns = /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\\"\,\.\<\>\/\s]+)/g;
17
14
  function register(context) {
18
15
  return (uri, position) => __awaiter(this, void 0, void 0, function* () {
19
- const document = context.getTextDocument(uri);
20
- const result = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.apply : !!data.rename), (plugin, document, position) => { var _a, _b; return (_b = (_a = plugin.rename) === null || _a === void 0 ? void 0 : _a.prepare) === null || _b === void 0 ? void 0 : _b.call(_a, document, position); }, (item, map) => {
16
+ return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.apply : !!data.rename), (plugin, document, position) => { var _a, _b; return (_b = (_a = plugin.rename) === null || _a === void 0 ? void 0 : _a.prepare) === null || _b === void 0 ? void 0 : _b.call(_a, document, position); }, (item, map) => {
21
17
  if (!map) {
22
18
  return item;
23
19
  }
@@ -32,7 +28,6 @@ function register(context) {
32
28
  }
33
29
  return prepares[0];
34
30
  });
35
- return result !== null && result !== void 0 ? result : (document ? (0, common_1.getWordRange)(htmlWordPatterns, position, document) : undefined);
36
31
  });
37
32
  }
38
33
  exports.register = register;
package/out/types.d.ts CHANGED
@@ -17,7 +17,7 @@ export interface LanguageServiceRuntimeContext<Host extends LanguageServiceHost
17
17
  env: {
18
18
  rootUri: URI;
19
19
  configurationHost?: ConfigurationHost;
20
- documentContext?: DocumentContext;
20
+ documentContext: DocumentContext;
21
21
  fileSystemProvider?: FileSystemProvider;
22
22
  schemaRequestService?: SchemaRequestService;
23
23
  };
@@ -1,9 +1,7 @@
1
1
  import type * as vscode from 'vscode-languageserver-protocol';
2
- import type { TextDocument } from 'vscode-languageserver-textdocument';
3
2
  export declare function getOverlapRange(range1Start: number, range1End: number, range2Start: number, range2End: number): {
4
3
  start: number;
5
4
  end: number;
6
5
  } | undefined;
7
6
  export declare function isInsideRange(parent: vscode.Range, child: vscode.Range): boolean;
8
- export declare function getWordRange(wordPattern: RegExp, position: vscode.Position, document: TextDocument): vscode.Range | undefined;
9
7
  export declare function stringToSnapshot(str: string): ts.IScriptSnapshot;
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.stringToSnapshot = exports.getWordRange = exports.isInsideRange = exports.getOverlapRange = void 0;
2
+ exports.stringToSnapshot = exports.isInsideRange = exports.getOverlapRange = void 0;
3
3
  function getOverlapRange(range1Start, range1End, range2Start, range2End) {
4
4
  const start = Math.max(range1Start, range2Start);
5
5
  const end = Math.min(range1End, range2End);
@@ -23,33 +23,6 @@ function isInsideRange(parent, child) {
23
23
  return true;
24
24
  }
25
25
  exports.isInsideRange = isInsideRange;
26
- function getWordRange(wordPattern, position, document) {
27
- const lineStart = {
28
- line: position.line,
29
- character: 0,
30
- };
31
- const lineEnd = {
32
- line: position.line + 1,
33
- character: 0,
34
- };
35
- const offset = document.offsetAt(position);
36
- const lineStartOffset = document.offsetAt(lineStart);
37
- const lineText = document.getText({ start: lineStart, end: lineEnd });
38
- for (const match of lineText.matchAll(wordPattern)) {
39
- if (match.index === undefined)
40
- continue;
41
- const matchStart = match.index + lineStartOffset;
42
- const matchEnd = matchStart + match[0].length;
43
- if (offset >= matchStart && offset <= matchEnd) {
44
- return {
45
- start: document.positionAt(matchStart),
46
- end: document.positionAt(matchEnd),
47
- };
48
- }
49
- }
50
- return undefined;
51
- }
52
- exports.getWordRange = getWordRange;
53
26
  function stringToSnapshot(str) {
54
27
  return {
55
28
  getText: (start, end) => str.substring(start, end),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "1.0.24",
3
+ "version": "1.1.0-alpha.0",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -9,19 +9,19 @@
9
9
  ],
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/johnsoncodehk/volar.git",
12
+ "url": "https://github.com/volarjs/framework.git",
13
13
  "directory": "packages/language-service"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/language-core": "1.0.24",
17
- "@volar/shared": "1.0.24",
18
- "@volar/source-map": "1.0.24",
19
- "@volar/typescript-faster": "1.0.24",
16
+ "@volar/language-core": "1.1.0-alpha.0",
17
+ "@volar/shared": "1.1.0-alpha.0",
18
+ "@volar/source-map": "1.1.0-alpha.0",
19
+ "@volar/typescript-faster": "1.1.0-alpha.0",
20
20
  "vscode-html-languageservice": "^5.0.3",
21
21
  "vscode-json-languageservice": "^5.1.3",
22
22
  "vscode-languageserver-protocol": "^3.17.2",
23
23
  "vscode-languageserver-textdocument": "^1.0.8",
24
24
  "vscode-uri": "^3.0.7"
25
25
  },
26
- "gitHead": "46da609e8914e29642f4707dec31507ad51b03fc"
26
+ "gitHead": "1cb85f17f5b90e40633e26710be7ecd4fd2994fb"
27
27
  }