@volar/language-service 1.7.0 → 1.7.1

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.
@@ -34,7 +34,7 @@ export declare function createDocumentsAndSourceMaps(env: ServiceEnvironment, ho
34
34
  getSourceByUri(sourceFileUri: string): import("@volar/language-core").Source | undefined;
35
35
  isVirtualFileUri(virtualFileUri: string): boolean;
36
36
  getVirtualFileByUri(virtualFileUri: string): readonly [VirtualFile, import("@volar/language-core").Source] | readonly [undefined, undefined];
37
- getMirrorMapByUri(virtualFileUri: string): [VirtualFile, MirrorMapWithDocument] | undefined;
37
+ getMirrorMapByUri(virtualFileUri: string): readonly [VirtualFile, MirrorMapWithDocument] | undefined;
38
38
  getMapsBySourceFileUri(uri: string): {
39
39
  snapshot: ts.IScriptSnapshot;
40
40
  maps: [VirtualFile, SourceMapWithDocuments<FileRangeCapabilities>][];
package/out/documents.js CHANGED
@@ -152,9 +152,9 @@ function createDocumentsAndSourceMaps(env, host, mapper) {
152
152
  const map = mapper.getMirrorMap(virtualFile);
153
153
  if (map) {
154
154
  if (!mirrorMap2DocMirrorMap.has(map)) {
155
- mirrorMap2DocMirrorMap.set(map, [virtualFile, new MirrorMapWithDocument(getDocumentByFileName(virtualFile.snapshot, fileName), map)]);
155
+ mirrorMap2DocMirrorMap.set(map, new MirrorMapWithDocument(getDocumentByFileName(virtualFile.snapshot, fileName), map));
156
156
  }
157
- return mirrorMap2DocMirrorMap.get(map);
157
+ return [virtualFile, mirrorMap2DocMirrorMap.get(map)];
158
158
  }
159
159
  }
160
160
  },
@@ -165,18 +165,13 @@ function createDocumentsAndSourceMaps(env, host, mapper) {
165
165
  const source = mapper.getSource(fileName);
166
166
  if (source) {
167
167
  const result = [];
168
- (0, language_core_1.forEachEmbeddedFile)(source.root, (embedded) => {
169
- for (const [sourceFileName, [sourceSnapshot, map]] of mapper.getMaps(embedded)) {
168
+ (0, language_core_1.forEachEmbeddedFile)(source.root, (virtualFile) => {
169
+ for (const [sourceFileName, [sourceSnapshot, map]] of mapper.getMaps(virtualFile)) {
170
170
  if (sourceSnapshot === source.snapshot) {
171
171
  if (!map2DocMap.has(map)) {
172
- map2DocMap.set(map, [
173
- embedded,
174
- new SourceMapWithDocuments(getDocumentByFileName(sourceSnapshot, sourceFileName), getDocumentByFileName(embedded.snapshot, fileName), map)
175
- ]);
176
- }
177
- if (map2DocMap.has(map)) {
178
- result.push(map2DocMap.get(map));
172
+ map2DocMap.set(map, new SourceMapWithDocuments(getDocumentByFileName(sourceSnapshot, sourceFileName), getDocumentByFileName(virtualFile.snapshot, fileName), map));
179
173
  }
174
+ result.push([virtualFile, map2DocMap.get(map)]);
180
175
  }
181
176
  }
182
177
  });
@@ -194,11 +189,9 @@ function createDocumentsAndSourceMaps(env, host, mapper) {
194
189
  if (virtualFile) {
195
190
  for (const [sourceFileName, [sourceSnapshot, map]] of mapper.getMaps(virtualFile)) {
196
191
  if (!map2DocMap.has(map)) {
197
- map2DocMap.set(map, [virtualFile, new SourceMapWithDocuments(getDocumentByFileName(sourceSnapshot, sourceFileName), getDocumentByFileName(virtualFile.snapshot, virtualFileName), map)]);
198
- }
199
- if (map2DocMap.has(map)) {
200
- yield map2DocMap.get(map);
192
+ map2DocMap.set(map, new SourceMapWithDocuments(getDocumentByFileName(sourceSnapshot, sourceFileName), getDocumentByFileName(virtualFile.snapshot, virtualFileName), map));
201
193
  }
194
+ yield [virtualFile, map2DocMap.get(map)];
202
195
  }
203
196
  }
204
197
  },
@@ -209,14 +202,10 @@ function createDocumentsAndSourceMaps(env, host, mapper) {
209
202
  };
210
203
  function getDocumentByFileName(snapshot, fileName) {
211
204
  if (!snapshot2Doc.has(snapshot)) {
212
- snapshot2Doc.set(snapshot, new Map());
213
- }
214
- const map = snapshot2Doc.get(snapshot);
215
- if (!map.has(fileName)) {
216
205
  const uri = env.fileNameToUri(fileName);
217
- map.set(fileName, vscode_languageserver_textdocument_1.TextDocument.create(uri, host.getLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), version++, snapshot.getText(0, snapshot.getLength())));
206
+ snapshot2Doc.set(snapshot, vscode_languageserver_textdocument_1.TextDocument.create(uri, host.getLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), version++, snapshot.getText(0, snapshot.getLength())));
218
207
  }
219
- return map.get(fileName);
208
+ return snapshot2Doc.get(snapshot);
220
209
  }
221
210
  }
222
211
  exports.createDocumentsAndSourceMaps = createDocumentsAndSourceMaps;
package/out/types.js CHANGED
@@ -7,12 +7,12 @@ var FileType;
7
7
  FileType[FileType["File"] = 1] = "File";
8
8
  FileType[FileType["Directory"] = 2] = "Directory";
9
9
  FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
10
- })(FileType || (exports.FileType = FileType = {}));
10
+ })(FileType = exports.FileType || (exports.FileType = {}));
11
11
  var RuleType;
12
12
  (function (RuleType) {
13
13
  RuleType[RuleType["Format"] = 0] = "Format";
14
14
  RuleType[RuleType["Syntax"] = 1] = "Syntax";
15
15
  RuleType[RuleType["Semantic"] = 2] = "Semantic";
16
- })(RuleType || (exports.RuleType = RuleType = {}));
16
+ })(RuleType = exports.RuleType || (exports.RuleType = {}));
17
17
  ;
18
18
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-service",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -13,13 +13,11 @@
13
13
  "directory": "packages/language-service"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/language-core": "1.7.0",
17
- "@volar/source-map": "1.7.0",
16
+ "@volar/language-core": "1.7.1",
17
+ "@volar/source-map": "1.7.1",
18
+ "vscode-languageserver-protocol": "^3.17.3",
18
19
  "vscode-languageserver-textdocument": "^1.0.8",
19
20
  "vscode-uri": "^3.0.7"
20
21
  },
21
- "devDependencies": {
22
- "vscode-languageserver-protocol": "^3.17.3"
23
- },
24
- "gitHead": "38ec4f727b32dbf2cf3284ab02695e3a8effacc5"
22
+ "gitHead": "6d092d684c65ce43af8a401bc90d0b2769a2bf49"
25
23
  }