@volar/language-server 1.0.0 → 1.0.2

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.
@@ -16,21 +16,19 @@ const protocol_1 = require("../protocol");
16
16
  const language_core_1 = require("@volar/language-core");
17
17
  function register(connection, projects) {
18
18
  connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
19
- var _a;
20
19
  const project = (yield projects.getProject(params.uri));
21
20
  if (project) {
22
21
  return {
23
22
  fileName: project.tsconfig,
24
- raw: (_a = project.project) === null || _a === void 0 ? void 0 : _a.getParsedCommandLine().raw,
25
23
  };
26
24
  }
27
25
  }));
28
26
  connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) => __awaiter(this, void 0, void 0, function* () {
29
- var _b, _c;
27
+ var _a, _b;
30
28
  const project = yield projects.getProject(document.uri);
31
29
  const fileNames = [];
32
30
  if (project) {
33
- const sourceFile = (_c = (_b = project.project) === null || _b === void 0 ? void 0 : _b.getLanguageService().context.core.mapper.get(shared.getPathOfUri(document.uri))) === null || _c === void 0 ? void 0 : _c[0];
31
+ const sourceFile = (_b = (_a = project.project) === null || _a === void 0 ? void 0 : _a.getLanguageService().context.core.mapper.get(shared.getPathOfUri(document.uri))) === null || _b === void 0 ? void 0 : _b[0];
34
32
  if (sourceFile) {
35
33
  (0, language_core_1.forEachEmbeddeds)(sourceFile.embeddeds, e => {
36
34
  if (e.text && e.kind === 1) {
@@ -42,10 +40,10 @@ function register(connection, projects) {
42
40
  return fileNames;
43
41
  }));
44
42
  connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
45
- var _d, _e;
43
+ var _c, _d;
46
44
  const project = yield projects.getProject(params.sourceFileUri);
47
45
  if (project) {
48
- const embeddedFile = (_e = (_d = project.project) === null || _d === void 0 ? void 0 : _d.getLanguageService().context.core.mapper.fromEmbeddedFileName(params.virtualFileName)) === null || _e === void 0 ? void 0 : _e.embedded;
46
+ const embeddedFile = (_d = (_c = project.project) === null || _c === void 0 ? void 0 : _c.getLanguageService().context.core.mapper.fromEmbeddedFileName(params.virtualFileName)) === null || _d === void 0 ? void 0 : _d.embedded;
49
47
  if (embeddedFile) {
50
48
  return {
51
49
  content: embeddedFile.text,
@@ -58,11 +56,11 @@ function register(connection, projects) {
58
56
  projects.reloadProject();
59
57
  }));
60
58
  connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
61
- var _f;
59
+ var _e;
62
60
  const fs = yield Promise.resolve().then(() => require('fs'));
63
61
  const project = yield projects.getProject(params.uri);
64
62
  if (project) {
65
- const ls = (_f = (yield project.project)) === null || _f === void 0 ? void 0 : _f.getLanguageServiceDontCreate();
63
+ const ls = (_e = (yield project.project)) === null || _e === void 0 ? void 0 : _e.getLanguageServiceDontCreate();
66
64
  if (ls) {
67
65
  const sourceFiles = new Set(ls.context.host.getScriptFileNames());
68
66
  for (const virtualFile of ls.context.core.typescriptLanguageServiceHost.getScriptFileNames()) {
@@ -77,14 +75,14 @@ function register(connection, projects) {
77
75
  }
78
76
  }));
79
77
  connection.onNotification(protocol_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
80
- var _g;
78
+ var _f;
81
79
  let errors = 0;
82
80
  let warnings = 0;
83
81
  const progress = yield connection.window.createWorkDoneProgress();
84
82
  progress.begin('Verify', 0, '', true);
85
83
  const project = yield projects.getProject(params.uri);
86
84
  if (project) {
87
- const ls = (_g = (yield project.project)) === null || _g === void 0 ? void 0 : _g.getLanguageServiceDontCreate();
85
+ const ls = (_f = (yield project.project)) === null || _f === void 0 ? void 0 : _f.getLanguageServiceDontCreate();
88
86
  if (ls) {
89
87
  const allVueDocuments = ls.context.documents.getAll();
90
88
  let i = 0;
package/out/protocol.d.ts CHANGED
@@ -24,7 +24,6 @@ export declare namespace GetMatchTsConfigRequest {
24
24
  type ParamsType = vscode.TextDocumentIdentifier;
25
25
  type ResponseType = {
26
26
  fileName: string;
27
- raw: any;
28
27
  } | null | undefined;
29
28
  type ErrorType = never;
30
29
  const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
@@ -38,7 +38,6 @@ export declare function createSnapshots(connection: vscode.Connection): {
38
38
  pathHas: (rootUri: shared._2.URI, path: string) => IncrementalScriptSnapshot | undefined;
39
39
  pathSet: (rootUri: shared._2.URI, path: string, item: IncrementalScriptSnapshot) => void;
40
40
  };
41
- onDidOpen: (cb: (params: vscode.DidOpenTextDocumentParams) => void) => () => boolean;
42
41
  onDidChangeContent: (cb: (params: vscode.DidChangeTextDocumentParams) => void) => () => boolean;
43
42
  onDidClose: (cb: (params: vscode.DidCloseTextDocumentParams) => void) => () => boolean;
44
43
  };
@@ -144,13 +144,12 @@ function _combineContinuousChangeRanges(a, b) {
144
144
  }
145
145
  function createSnapshots(connection) {
146
146
  const snapshots = shared.createUriMap();
147
- const onDidOpens = new Set();
148
147
  const onDidChangeContents = new Set();
149
148
  const onDidCloses = new Set();
150
149
  connection.onDidOpenTextDocument(params => {
151
150
  snapshots.uriSet(params.textDocument.uri, new IncrementalScriptSnapshot(params.textDocument.uri, params.textDocument.languageId, params.textDocument.version, params.textDocument.text));
152
- for (const cb of onDidOpens) {
153
- cb(params);
151
+ for (const cb of onDidChangeContents) {
152
+ cb({ textDocument: params.textDocument, contentChanges: [{ text: params.textDocument.text }] });
154
153
  }
155
154
  });
156
155
  connection.onDidChangeTextDocument(params => {
@@ -183,10 +182,6 @@ function createSnapshots(connection) {
183
182
  });
184
183
  return {
185
184
  data: snapshots,
186
- onDidOpen: (cb) => {
187
- onDidOpens.add(cb);
188
- return () => onDidOpens.delete(cb);
189
- },
190
185
  onDidChangeContent: (cb) => {
191
186
  onDidChangeContents.add(cb);
192
187
  return () => onDidChangeContents.delete(cb);
@@ -19,12 +19,9 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
19
19
  let semanticTokensReq = 0;
20
20
  let documentUpdatedReq = 0;
21
21
  const workspaces = new Map();
22
- documents.onDidOpen(params => {
22
+ documents.onDidChangeContent(params => {
23
23
  updateDiagnostics(params.textDocument.uri);
24
24
  });
25
- documents.onDidChangeContent((params) => __awaiter(this, void 0, void 0, function* () {
26
- updateDiagnostics(params.textDocument.uri);
27
- }));
28
25
  documents.onDidClose(params => {
29
26
  connection.sendDiagnostics({ uri: params.textDocument.uri, diagnostics: [] });
30
27
  });
@@ -84,12 +81,12 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
84
81
  });
85
82
  }
86
83
  function updateDiagnostics(docUri) {
87
- var _a;
84
+ var _a, _b;
88
85
  return __awaiter(this, void 0, void 0, function* () {
89
86
  if (((_a = options.diagnosticModel) !== null && _a !== void 0 ? _a : types_1.DiagnosticModel.Push) !== types_1.DiagnosticModel.Push)
90
87
  return;
91
88
  const req = ++documentUpdatedReq;
92
- const delay = yield (configurationHost === null || configurationHost === void 0 ? void 0 : configurationHost.getConfiguration('volar.diagnostics.delay'));
89
+ const delay = (_b = yield (configurationHost === null || configurationHost === void 0 ? void 0 : configurationHost.getConfiguration('volar.diagnostics.delay'))) !== null && _b !== void 0 ? _b : 200;
93
90
  const cancel = cancelTokenHost.createCancellactionToken({
94
91
  get isCancellationRequested() {
95
92
  return req !== documentUpdatedReq;
@@ -99,11 +96,11 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
99
96
  const changeDoc = docUri ? documents.data.uriGet(docUri) : undefined;
100
97
  const otherDocs = [...documents.data.values()].filter(doc => doc !== changeDoc);
101
98
  if (changeDoc) {
102
- yield shared.sleep(delay !== null && delay !== void 0 ? delay : 200);
99
+ yield shared.sleep(delay);
103
100
  yield sendDocumentDiagnostics(changeDoc.uri, changeDoc.version, cancel);
104
101
  }
105
102
  for (const doc of otherDocs) {
106
- yield shared.sleep(delay !== null && delay !== void 0 ? delay : 200);
103
+ yield shared.sleep(delay);
107
104
  yield sendDocumentDiagnostics(doc.uri, doc.version, cancel);
108
105
  if (cancel.isCancellationRequested) {
109
106
  break;
@@ -137,6 +134,7 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
137
134
  var _a;
138
135
  return __awaiter(this, void 0, void 0, function* () {
139
136
  const rootUris = [...workspaces.keys()]
137
+ .filter(rootUri => vscode_uri_1.URI.parse(rootUri).scheme === vscode_uri_1.URI.parse(uri).scheme) // fix https://github.com/johnsoncodehk/volar/issues/1946#issuecomment-1272430742
140
138
  .filter(rootUri => shared.isFileInDir(vscode_uri_1.URI.parse(uri).fsPath, vscode_uri_1.URI.parse(rootUri).fsPath))
141
139
  .sort((a, b) => (0, workspaceProjects_1.sortTsConfigs)(vscode_uri_1.URI.parse(uri).fsPath, vscode_uri_1.URI.parse(a).fsPath, vscode_uri_1.URI.parse(b).fsPath));
142
140
  for (const rootUri of rootUris) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "directory": "packages/language-server"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-core": "1.0.0",
21
- "@volar/language-service": "1.0.0",
22
- "@volar/shared": "1.0.0",
20
+ "@volar/language-core": "1.0.2",
21
+ "@volar/language-service": "1.0.2",
22
+ "@volar/shared": "1.0.2",
23
23
  "request-light": "^0.5.8",
24
24
  "typesafe-path": "^0.2.1",
25
25
  "vscode-html-languageservice": "^5.0.1",
@@ -28,5 +28,5 @@
28
28
  "vscode-languageserver-textdocument": "^1.0.7",
29
29
  "vscode-uri": "^3.0.3"
30
30
  },
31
- "gitHead": "5496c1ecc0ae6207d6fa7da745f047c44c32db81"
31
+ "gitHead": "4e750f808450c0f70b0a439cb6954cf29345e8f2"
32
32
  }