@volar/typescript 1.0.21 → 1.0.24

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.
package/out/getProgram.js CHANGED
@@ -42,9 +42,9 @@ function getProgram(ts, core, ls) {
42
42
  function getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, api) {
43
43
  var _a, _b, _c;
44
44
  if (sourceFile) {
45
- const source = core.virtualFiles.getSourceByVirtualFileName(sourceFile.fileName);
46
- if (source) {
47
- if (!source[2].capabilities.diagnostic)
45
+ const [virtualFile, source] = core.virtualFiles.getVirtualFile(sourceFile.fileName);
46
+ if (virtualFile && source) {
47
+ if (!virtualFile.capabilities.diagnostic)
48
48
  return [];
49
49
  const errors = transformDiagnostics((_b = (_a = ls.getProgram()) === null || _a === void 0 ? void 0 : _a[api](sourceFile, cancellationToken)) !== null && _b !== void 0 ? _b : []);
50
50
  return errors;
@@ -73,12 +73,12 @@ function getProgram(ts, core, ls) {
73
73
  if (diagnostic.file !== undefined
74
74
  && diagnostic.start !== undefined
75
75
  && diagnostic.length !== undefined) {
76
- const source = core.virtualFiles.getSourceByVirtualFileName(diagnostic.file.fileName);
77
- if (source) {
78
- if (((_b = (_a = core.typescript.languageServiceHost).fileExists) === null || _b === void 0 ? void 0 : _b.call(_a, source[0])) === false)
76
+ const [virtualFile, source] = core.virtualFiles.getVirtualFile(diagnostic.file.fileName);
77
+ if (virtualFile && source) {
78
+ if (((_b = (_a = core.typescript.languageServiceHost).fileExists) === null || _b === void 0 ? void 0 : _b.call(_a, source.fileName)) === false)
79
79
  continue;
80
- for (const [sourceFileName, map] of core.virtualFiles.getMaps(source[2])) {
81
- if (sourceFileName !== source[0])
80
+ for (const [sourceFileName, map] of core.virtualFiles.getMaps(virtualFile)) {
81
+ if (sourceFileName !== source.fileName)
82
82
  continue;
83
83
  for (const start of map.toSourceOffsets(diagnostic.start)) {
84
84
  if (!start[1].data.diagnostic)
@@ -86,7 +86,7 @@ function getProgram(ts, core, ls) {
86
86
  for (const end of map.toSourceOffsets(diagnostic.start + diagnostic.length, true)) {
87
87
  if (!end[1].data.diagnostic)
88
88
  continue;
89
- onMapping(diagnostic, source[0], start[0], end[0], source[1].getText(0, source[1].getLength()));
89
+ onMapping(diagnostic, source.fileName, start[0], end[0], source.snapshot.getText(0, source.snapshot.getLength()));
90
90
  break;
91
91
  }
92
92
  break;
package/out/index.js CHANGED
@@ -9,7 +9,6 @@ function createLanguageService(host, mods) {
9
9
  return new Proxy({
10
10
  organizeImports,
11
11
  // only support for .ts for now, not support for .vue
12
- getCompletionsAtPosition,
13
12
  getDefinitionAtPosition,
14
13
  getDefinitionAndBoundSpan,
15
14
  getTypeDefinitionAtPosition,
@@ -45,7 +44,7 @@ function createLanguageService(host, mods) {
45
44
  function organizeImports(args, formatOptions, preferences) {
46
45
  var _a;
47
46
  let edits = [];
48
- const file = (_a = core.virtualFiles.get(args.fileName)) === null || _a === void 0 ? void 0 : _a[1];
47
+ const file = (_a = core.virtualFiles.getSource(args.fileName)) === null || _a === void 0 ? void 0 : _a.root;
49
48
  if (file) {
50
49
  embedded.forEachEmbeddedFile(file, embedded => {
51
50
  if (embedded.kind && embedded.capabilities.codeAction) {
@@ -58,13 +57,6 @@ function createLanguageService(host, mods) {
58
57
  }
59
58
  return edits.map(transformFileTextChanges).filter(notEmpty);
60
59
  }
61
- function getCompletionsAtPosition(fileName, position, options) {
62
- const finalResult = ls.getCompletionsAtPosition(fileName, position, options);
63
- if (finalResult) {
64
- finalResult.entries = finalResult.entries.filter(entry => entry.name.indexOf('__VLS_') === -1);
65
- }
66
- return finalResult;
67
- }
68
60
  function getReferencesAtPosition(fileName, position) {
69
61
  return findLocations(fileName, position, 'references');
70
62
  }
@@ -86,7 +78,6 @@ function createLanguageService(host, mods) {
86
78
  withMirrors(fileName, position);
87
79
  return symbols.map(s => transformDocumentSpanLike(s)).filter(notEmpty);
88
80
  function withMirrors(fileName, position) {
89
- var _a;
90
81
  if (loopChecker.has(fileName + ':' + position))
91
82
  return;
92
83
  loopChecker.add(fileName + ':' + position);
@@ -101,7 +92,7 @@ function createLanguageService(host, mods) {
101
92
  symbols = symbols.concat(_symbols);
102
93
  for (const ref of _symbols) {
103
94
  loopChecker.add(ref.fileName + ':' + ref.textSpan.start);
104
- const virtualFile = (_a = core.virtualFiles.getSourceByVirtualFileName(ref.fileName)) === null || _a === void 0 ? void 0 : _a[2];
95
+ const [virtualFile] = core.virtualFiles.getVirtualFile(ref.fileName);
105
96
  if (!virtualFile)
106
97
  continue;
107
98
  const mirrorMap = core.virtualFiles.getMirrorMap(virtualFile);
@@ -133,7 +124,6 @@ function createLanguageService(host, mods) {
133
124
  definitions: symbols === null || symbols === void 0 ? void 0 : symbols.map(s => transformDocumentSpanLike(s)).filter(notEmpty),
134
125
  };
135
126
  function withMirrors(fileName, position) {
136
- var _a;
137
127
  if (loopChecker.has(fileName + ':' + position))
138
128
  return;
139
129
  loopChecker.add(fileName + ':' + position);
@@ -148,7 +138,7 @@ function createLanguageService(host, mods) {
148
138
  symbols = symbols.concat(_symbols.definitions);
149
139
  for (const ref of _symbols.definitions) {
150
140
  loopChecker.add(ref.fileName + ':' + ref.textSpan.start);
151
- const virtualFile = (_a = core.virtualFiles.getSourceByVirtualFileName(ref.fileName)) === null || _a === void 0 ? void 0 : _a[2];
141
+ const [virtualFile] = core.virtualFiles.getVirtualFile(ref.fileName);
152
142
  if (!virtualFile)
153
143
  continue;
154
144
  const mirrorMap = core.virtualFiles.getMirrorMap(virtualFile);
@@ -170,7 +160,6 @@ function createLanguageService(host, mods) {
170
160
  withMirrors(fileName, position);
171
161
  return symbols.map(s => transformReferencedSymbol(s)).filter(notEmpty);
172
162
  function withMirrors(fileName, position) {
173
- var _a;
174
163
  if (loopChecker.has(fileName + ':' + position))
175
164
  return;
176
165
  loopChecker.add(fileName + ':' + position);
@@ -181,7 +170,7 @@ function createLanguageService(host, mods) {
181
170
  for (const symbol of _symbols) {
182
171
  for (const ref of symbol.references) {
183
172
  loopChecker.add(ref.fileName + ':' + ref.textSpan.start);
184
- const virtualFile = (_a = core.virtualFiles.getSourceByVirtualFileName(ref.fileName)) === null || _a === void 0 ? void 0 : _a[2];
173
+ const [virtualFile] = core.virtualFiles.getVirtualFile(ref.fileName);
185
174
  if (!virtualFile)
186
175
  continue;
187
176
  const mirrorMap = core.virtualFiles.getMirrorMap(virtualFile);
@@ -200,9 +189,9 @@ function createLanguageService(host, mods) {
200
189
  }
201
190
  // transforms
202
191
  function transformFileTextChanges(changes) {
203
- const source = core.virtualFiles.getSourceByVirtualFileName(changes.fileName);
192
+ const [_, source] = core.virtualFiles.getVirtualFile(changes.fileName);
204
193
  if (source) {
205
- return Object.assign(Object.assign({}, changes), { fileName: source[0], textChanges: changes.textChanges.map(c => {
194
+ return Object.assign(Object.assign({}, changes), { fileName: source.fileName, textChanges: changes.textChanges.map(c => {
206
195
  const span = transformSpan(changes.fileName, c.span);
207
196
  if (span) {
208
197
  return Object.assign(Object.assign({}, c), { span: span.textSpan });
@@ -243,15 +232,15 @@ function createLanguageService(host, mods) {
243
232
  return;
244
233
  if (!textSpan)
245
234
  return;
246
- const source = core.virtualFiles.getSourceByVirtualFileName(fileName);
247
- if (source) {
248
- for (const [sourceFileName, map] of core.virtualFiles.getMaps(source[2])) {
249
- if (source[0] !== sourceFileName)
235
+ const [virtualFile, source] = core.virtualFiles.getVirtualFile(fileName);
236
+ if (virtualFile && source) {
237
+ for (const [sourceFileName, map] of core.virtualFiles.getMaps(virtualFile)) {
238
+ if (source.fileName !== sourceFileName)
250
239
  continue;
251
240
  const sourceLoc = map.toSourceOffset(textSpan.start);
252
241
  if (sourceLoc) {
253
242
  return {
254
- fileName: source[0],
243
+ fileName: source.fileName,
255
244
  textSpan: {
256
245
  start: sourceLoc[0],
257
246
  length: textSpan.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/typescript",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/typescript"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/language-core": "1.0.21"
16
+ "@volar/language-core": "1.0.24"
17
17
  },
18
- "gitHead": "72332760759e06eed18e62026185cbad70250367"
18
+ "gitHead": "46da609e8914e29642f4707dec31507ad51b03fc"
19
19
  }