@volar/language-server 1.4.0-alpha.0 → 1.4.0-alpha.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.
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  Object.defineProperty(exports, "__esModule", { value: true });
11
2
  exports.sleep = exports.register = void 0;
12
3
  const embedded = require("@volar/language-service");
@@ -19,73 +10,71 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
19
10
  let lastCodeLensLs;
20
11
  let lastCodeActionLs;
21
12
  let lastCallHierarchyLs;
22
- connection.onDocumentFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
13
+ connection.onDocumentFormatting(async (params, token) => {
23
14
  return worker(params.textDocument.uri, token, service => {
24
15
  return service.format(params.textDocument.uri, params.options, undefined, undefined, token);
25
16
  });
26
- }));
27
- connection.onDocumentRangeFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
17
+ });
18
+ connection.onDocumentRangeFormatting(async (params, token) => {
28
19
  return worker(params.textDocument.uri, token, service => {
29
20
  return service.format(params.textDocument.uri, params.options, params.range, undefined, token);
30
21
  });
31
- }));
32
- connection.onDocumentOnTypeFormatting((params, token) => __awaiter(this, void 0, void 0, function* () {
22
+ });
23
+ connection.onDocumentOnTypeFormatting(async (params, token) => {
33
24
  return worker(params.textDocument.uri, token, service => {
34
25
  return service.format(params.textDocument.uri, params.options, undefined, params, token);
35
26
  });
36
- }));
37
- connection.onSelectionRanges((params, token) => __awaiter(this, void 0, void 0, function* () {
27
+ });
28
+ connection.onSelectionRanges(async (params, token) => {
38
29
  return worker(params.textDocument.uri, token, service => {
39
30
  return service.getSelectionRanges(params.textDocument.uri, params.positions, token);
40
31
  });
41
- }));
42
- connection.onFoldingRanges((params, token) => __awaiter(this, void 0, void 0, function* () {
32
+ });
33
+ connection.onFoldingRanges(async (params, token) => {
43
34
  return worker(params.textDocument.uri, token, service => {
44
35
  return service.getFoldingRanges(params.textDocument.uri, token);
45
36
  });
46
- }));
47
- connection.languages.onLinkedEditingRange((params, token) => __awaiter(this, void 0, void 0, function* () {
37
+ });
38
+ connection.languages.onLinkedEditingRange(async (params, token) => {
48
39
  return worker(params.textDocument.uri, token, service => {
49
40
  return service.findLinkedEditingRanges(params.textDocument.uri, params.position, token);
50
41
  });
51
- }));
52
- connection.onDocumentSymbol((params, token) => __awaiter(this, void 0, void 0, function* () {
42
+ });
43
+ connection.onDocumentSymbol(async (params, token) => {
53
44
  return worker(params.textDocument.uri, token, service => {
54
45
  return service.findDocumentSymbols(params.textDocument.uri, token);
55
46
  });
56
- }));
57
- connection.onDocumentColor((params, token) => __awaiter(this, void 0, void 0, function* () {
47
+ });
48
+ connection.onDocumentColor(async (params, token) => {
58
49
  return worker(params.textDocument.uri, token, service => {
59
50
  return service.findDocumentColors(params.textDocument.uri, token);
60
51
  });
61
- }));
62
- connection.onColorPresentation((params, token) => __awaiter(this, void 0, void 0, function* () {
52
+ });
53
+ connection.onColorPresentation(async (params, token) => {
63
54
  return worker(params.textDocument.uri, token, service => {
64
55
  return service.getColorPresentations(params.textDocument.uri, params.color, params.range, token);
65
56
  });
66
- }));
67
- connection.onCompletion((params, token) => __awaiter(this, void 0, void 0, function* () {
68
- return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
69
- var _a;
57
+ });
58
+ connection.onCompletion(async (params, token) => {
59
+ return worker(params.textDocument.uri, token, async (service) => {
70
60
  lastCompleteUri = params.textDocument.uri;
71
61
  lastCompleteLs = service;
72
- const document = (_a = documents.data.uriGet(params.textDocument.uri)) === null || _a === void 0 ? void 0 : _a.getDocument();
73
- const list = yield service.doComplete(params.textDocument.uri, params.position, params.context, token);
62
+ const document = documents.data.uriGet(params.textDocument.uri)?.getDocument();
63
+ const list = await service.doComplete(params.textDocument.uri, params.position, params.context, token);
74
64
  for (const item of list.items) {
75
65
  fixTextEdit(item);
76
66
  }
77
67
  if (!initOptions.fullCompletionList && document) {
78
68
  list.items = list.items.filter(item => {
79
- var _a, _b;
80
69
  const range = item.textEdit ? (vscode.InsertReplaceEdit.is(item.textEdit)
81
70
  ? item.textEdit.replace
82
- : item.textEdit.range) : ((_a = list.itemDefaults) === null || _a === void 0 ? void 0 : _a.editRange) ? (vscode.Range.is(list.itemDefaults.editRange)
71
+ : item.textEdit.range) : list.itemDefaults?.editRange ? (vscode.Range.is(list.itemDefaults.editRange)
83
72
  ? list.itemDefaults.editRange
84
73
  : list.itemDefaults.editRange.replace) : undefined;
85
74
  if (range) {
86
75
  const sourceText = document.getText(range).toLowerCase();
87
76
  if (sourceText.trim()) {
88
- let filterText = ((_b = item.filterText) !== null && _b !== void 0 ? _b : item.label).toLowerCase();
77
+ let filterText = (item.filterText ?? item.label).toLowerCase();
89
78
  for (const char of sourceText) {
90
79
  const index = filterText.indexOf(char);
91
80
  if (index === -1) {
@@ -99,50 +88,49 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
99
88
  });
100
89
  }
101
90
  return list;
102
- }));
103
- }));
104
- connection.onCompletionResolve((item, token) => __awaiter(this, void 0, void 0, function* () {
91
+ });
92
+ });
93
+ connection.onCompletionResolve(async (item, token) => {
105
94
  if (lastCompleteUri && lastCompleteLs) {
106
- item = yield lastCompleteLs.doCompletionResolve(item, token);
95
+ item = await lastCompleteLs.doCompletionResolve(item, token);
107
96
  fixTextEdit(item);
108
97
  }
109
98
  return item;
110
- }));
111
- connection.onHover((params, token) => __awaiter(this, void 0, void 0, function* () {
99
+ });
100
+ connection.onHover(async (params, token) => {
112
101
  return worker(params.textDocument.uri, token, service => {
113
102
  return service.doHover(params.textDocument.uri, params.position, token);
114
103
  });
115
- }));
116
- connection.onSignatureHelp((params, token) => __awaiter(this, void 0, void 0, function* () {
104
+ });
105
+ connection.onSignatureHelp(async (params, token) => {
117
106
  return worker(params.textDocument.uri, token, service => {
118
107
  return service.getSignatureHelp(params.textDocument.uri, params.position, params.context, token);
119
108
  });
120
- }));
121
- connection.onPrepareRename((params, token) => __awaiter(this, void 0, void 0, function* () {
109
+ });
110
+ connection.onPrepareRename(async (params, token) => {
122
111
  return worker(params.textDocument.uri, token, service => {
123
112
  return service.prepareRename(params.textDocument.uri, params.position, token);
124
113
  });
125
- }));
126
- connection.onRenameRequest((params, token) => __awaiter(this, void 0, void 0, function* () {
114
+ });
115
+ connection.onRenameRequest(async (params, token) => {
127
116
  return worker(params.textDocument.uri, token, service => {
128
117
  return service.doRename(params.textDocument.uri, params.position, params.newName, token);
129
118
  });
130
- }));
131
- connection.onCodeLens((params, token) => __awaiter(this, void 0, void 0, function* () {
132
- return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
119
+ });
120
+ connection.onCodeLens(async (params, token) => {
121
+ return worker(params.textDocument.uri, token, async (service) => {
133
122
  lastCodeLensLs = service;
134
123
  return service.doCodeLens(params.textDocument.uri, token);
135
- }));
136
- }));
137
- connection.onCodeLensResolve((codeLens, token) => __awaiter(this, void 0, void 0, function* () {
138
- var _b;
139
- return (_b = yield (lastCodeLensLs === null || lastCodeLensLs === void 0 ? void 0 : lastCodeLensLs.doCodeLensResolve(codeLens, token))) !== null && _b !== void 0 ? _b : codeLens;
140
- }));
141
- connection.onExecuteCommand((params) => __awaiter(this, void 0, void 0, function* () {
124
+ });
125
+ });
126
+ connection.onCodeLensResolve(async (codeLens, token) => {
127
+ return await lastCodeLensLs?.doCodeLensResolve(codeLens, token) ?? codeLens;
128
+ });
129
+ connection.onExecuteCommand(async (params) => {
142
130
  if (params.command === embedded.showReferencesCommand
143
131
  && params.arguments) {
144
132
  const args = params.arguments;
145
- yield connection.sendNotification(protocol_1.ShowReferencesNotification.type, {
133
+ await connection.sendNotification(protocol_1.ShowReferencesNotification.type, {
146
134
  textDocument: {
147
135
  uri: args[0],
148
136
  },
@@ -150,12 +138,11 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
150
138
  references: args[2],
151
139
  });
152
140
  }
153
- }));
154
- connection.onCodeAction((params, token) => __awaiter(this, void 0, void 0, function* () {
155
- return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
156
- var _c, _d, _e;
141
+ });
142
+ connection.onCodeAction(async (params, token) => {
143
+ return worker(params.textDocument.uri, token, async (service) => {
157
144
  lastCodeActionLs = service;
158
- let codeActions = (_c = yield service.doCodeActions(params.textDocument.uri, params.range, params.context, token)) !== null && _c !== void 0 ? _c : [];
145
+ let codeActions = await service.doCodeActions(params.textDocument.uri, params.range, params.context, token) ?? [];
159
146
  for (const codeAction of codeActions) {
160
147
  if (codeAction.data && typeof codeAction.data === 'object') {
161
148
  codeAction.data.uri = params.textDocument.uri;
@@ -164,104 +151,98 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
164
151
  codeAction.data = { uri: params.textDocument.uri };
165
152
  }
166
153
  }
167
- if (!((_e = (_d = initParams.capabilities.textDocument) === null || _d === void 0 ? void 0 : _d.codeAction) === null || _e === void 0 ? void 0 : _e.disabledSupport)) {
154
+ if (!initParams.capabilities.textDocument?.codeAction?.disabledSupport) {
168
155
  codeActions = codeActions.filter(codeAction => !codeAction.disabled);
169
156
  }
170
157
  return codeActions;
171
- }));
172
- }));
173
- connection.onCodeActionResolve((codeAction, token) => __awaiter(this, void 0, void 0, function* () {
174
- var _f;
175
- return (_f = yield lastCodeActionLs.doCodeActionResolve(codeAction, token)) !== null && _f !== void 0 ? _f : codeAction;
176
- }));
177
- connection.onReferences((params, token) => __awaiter(this, void 0, void 0, function* () {
158
+ });
159
+ });
160
+ connection.onCodeActionResolve(async (codeAction, token) => {
161
+ return await lastCodeActionLs.doCodeActionResolve(codeAction, token) ?? codeAction;
162
+ });
163
+ connection.onReferences(async (params, token) => {
178
164
  return worker(params.textDocument.uri, token, service => {
179
165
  return service.findReferences(params.textDocument.uri, params.position, token);
180
166
  });
181
- }));
182
- connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params, token) => __awaiter(this, void 0, void 0, function* () {
167
+ });
168
+ connection.onRequest(protocol_1.FindFileReferenceRequest.type, async (params, token) => {
183
169
  return worker(params.textDocument.uri, token, service => {
184
170
  return service.findFileReferences(params.textDocument.uri, token);
185
171
  });
186
- }));
187
- connection.onImplementation((params, token) => __awaiter(this, void 0, void 0, function* () {
172
+ });
173
+ connection.onImplementation(async (params, token) => {
188
174
  return worker(params.textDocument.uri, token, service => {
189
175
  return service.findImplementations(params.textDocument.uri, params.position, token);
190
176
  });
191
- }));
192
- connection.onDefinition((params, token) => __awaiter(this, void 0, void 0, function* () {
177
+ });
178
+ connection.onDefinition(async (params, token) => {
193
179
  return worker(params.textDocument.uri, token, service => {
194
180
  return service.findDefinition(params.textDocument.uri, params.position, token);
195
181
  });
196
- }));
197
- connection.onTypeDefinition((params, token) => __awaiter(this, void 0, void 0, function* () {
182
+ });
183
+ connection.onTypeDefinition(async (params, token) => {
198
184
  return worker(params.textDocument.uri, token, service => {
199
185
  return service.findTypeDefinition(params.textDocument.uri, params.position, token);
200
186
  });
201
- }));
202
- connection.onDocumentHighlight((params, token) => __awaiter(this, void 0, void 0, function* () {
187
+ });
188
+ connection.onDocumentHighlight(async (params, token) => {
203
189
  return worker(params.textDocument.uri, token, service => {
204
190
  return service.findDocumentHighlights(params.textDocument.uri, params.position, token);
205
191
  });
206
- }));
207
- connection.onDocumentLinks((params, token) => __awaiter(this, void 0, void 0, function* () {
208
- return yield worker(params.textDocument.uri, token, service => {
192
+ });
193
+ connection.onDocumentLinks(async (params, token) => {
194
+ return await worker(params.textDocument.uri, token, service => {
209
195
  return service.findDocumentLinks(params.textDocument.uri, token);
210
196
  });
211
- }));
212
- connection.onWorkspaceSymbol((params, token) => __awaiter(this, void 0, void 0, function* () {
197
+ });
198
+ connection.onWorkspaceSymbol(async (params, token) => {
213
199
  let results = [];
214
200
  for (const _workspace of projects.workspaces.values()) {
215
- const workspace = yield _workspace;
201
+ const workspace = await _workspace;
216
202
  let projects = [...workspace.projects.values()];
217
203
  projects = projects.length ? projects : [workspace.getInferredProject()];
218
204
  for (const project of projects) {
219
205
  if (token.isCancellationRequested)
220
206
  return;
221
- const service = (yield project).getLanguageService();
222
- results = results.concat(yield service.findWorkspaceSymbols(params.query, token));
207
+ const service = (await project).getLanguageService();
208
+ results = results.concat(await service.findWorkspaceSymbols(params.query, token));
223
209
  }
224
210
  }
225
211
  return results;
226
- }));
227
- connection.languages.callHierarchy.onPrepare((params, token) => __awaiter(this, void 0, void 0, function* () {
228
- var _g;
229
- return (_g = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
212
+ });
213
+ connection.languages.callHierarchy.onPrepare(async (params, token) => {
214
+ return await worker(params.textDocument.uri, token, async (service) => {
230
215
  lastCallHierarchyLs = service;
231
216
  return service.callHierarchy.doPrepare(params.textDocument.uri, params.position, token);
232
- }))) !== null && _g !== void 0 ? _g : [];
233
- }));
234
- connection.languages.callHierarchy.onIncomingCalls((params, token) => __awaiter(this, void 0, void 0, function* () {
235
- var _h;
236
- return (_h = yield (lastCallHierarchyLs === null || lastCallHierarchyLs === void 0 ? void 0 : lastCallHierarchyLs.callHierarchy.getIncomingCalls(params.item, token))) !== null && _h !== void 0 ? _h : [];
237
- }));
238
- connection.languages.callHierarchy.onOutgoingCalls((params, token) => __awaiter(this, void 0, void 0, function* () {
239
- var _j;
240
- return (_j = yield (lastCallHierarchyLs === null || lastCallHierarchyLs === void 0 ? void 0 : lastCallHierarchyLs.callHierarchy.getOutgoingCalls(params.item, token))) !== null && _j !== void 0 ? _j : [];
241
- }));
242
- connection.languages.semanticTokens.on((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
243
- var _k;
244
- yield sleep(200);
245
- return (_k = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
246
- return yield (service === null || service === void 0 ? void 0 : service.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(tokens)));
247
- }))) !== null && _k !== void 0 ? _k : { data: [] };
248
- }));
249
- connection.languages.semanticTokens.onRange((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
250
- var _l;
251
- yield sleep(200);
252
- return (_l = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
253
- return yield (service === null || service === void 0 ? void 0 : service.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(tokens)));
254
- }))) !== null && _l !== void 0 ? _l : { data: [] };
255
- }));
256
- connection.languages.diagnostics.on((params, token, _workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
257
- const result = yield worker(params.textDocument.uri, token, service => {
217
+ }) ?? [];
218
+ });
219
+ connection.languages.callHierarchy.onIncomingCalls(async (params, token) => {
220
+ return await lastCallHierarchyLs?.callHierarchy.getIncomingCalls(params.item, token) ?? [];
221
+ });
222
+ connection.languages.callHierarchy.onOutgoingCalls(async (params, token) => {
223
+ return await lastCallHierarchyLs?.callHierarchy.getOutgoingCalls(params.item, token) ?? [];
224
+ });
225
+ connection.languages.semanticTokens.on(async (params, token, _, resultProgress) => {
226
+ await sleep(200);
227
+ return await worker(params.textDocument.uri, token, async (service) => {
228
+ return await service?.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress?.report(tokens));
229
+ }) ?? { data: [] };
230
+ });
231
+ connection.languages.semanticTokens.onRange(async (params, token, _, resultProgress) => {
232
+ await sleep(200);
233
+ return await worker(params.textDocument.uri, token, async (service) => {
234
+ return await service?.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress?.report(tokens));
235
+ }) ?? { data: [] };
236
+ });
237
+ connection.languages.diagnostics.on(async (params, token, _workDoneProgressReporter, resultProgressReporter) => {
238
+ const result = await worker(params.textDocument.uri, token, service => {
258
239
  const tsToken = cancelHost.createCancellationToken(token);
259
240
  const mode = initOptions.serverMode === types_1.ServerMode.PartialSemantic ? 'semantic'
260
241
  : initOptions.serverMode === types_1.ServerMode.Syntactic ? 'syntactic'
261
242
  : 'all';
262
- return service.doValidation(params.textDocument.uri, tsToken, mode, errors => {
243
+ return service.doValidation(params.textDocument.uri, mode, tsToken, errors => {
263
244
  // resultProgressReporter is undefined in vscode
264
- resultProgressReporter === null || resultProgressReporter === void 0 ? void 0 : resultProgressReporter.report({
245
+ resultProgressReporter?.report({
265
246
  relatedDocuments: {
266
247
  [params.textDocument.uri]: {
267
248
  kind: vscode.DocumentDiagnosticReportKind.Full,
@@ -273,57 +254,55 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
273
254
  });
274
255
  return {
275
256
  kind: vscode.DocumentDiagnosticReportKind.Full,
276
- items: result !== null && result !== void 0 ? result : [],
257
+ items: result ?? [],
277
258
  };
278
- }));
279
- connection.languages.inlayHint.on((params, token) => __awaiter(this, void 0, void 0, function* () {
280
- return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
259
+ });
260
+ connection.languages.inlayHint.on(async (params, token) => {
261
+ return worker(params.textDocument.uri, token, async (service) => {
281
262
  return service.getInlayHints(params.textDocument.uri, params.range, token);
282
- }));
283
- }));
263
+ });
264
+ });
284
265
  // TODO: connection.languages.inlayHint.resolve
285
- connection.workspace.onWillRenameFiles((params, token) => __awaiter(this, void 0, void 0, function* () {
286
- const config = yield connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
266
+ connection.workspace.onWillRenameFiles(async (params, token) => {
267
+ const config = await connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
287
268
  if (!config) {
288
269
  return null;
289
270
  }
290
- const _edits = yield Promise.all(params.files.map((file) => __awaiter(this, void 0, void 0, function* () {
291
- var _m;
292
- return (_m = yield worker(file.oldUri, token, service => {
293
- var _a;
294
- return (_a = service.getEditsForFileRename(file.oldUri, file.newUri, token)) !== null && _a !== void 0 ? _a : null;
295
- })) !== null && _m !== void 0 ? _m : null;
296
- })));
271
+ const _edits = await Promise.all(params.files.map(async (file) => {
272
+ return await worker(file.oldUri, token, service => {
273
+ return service.getEditsForFileRename(file.oldUri, file.newUri, token) ?? null;
274
+ }) ?? null;
275
+ }));
297
276
  const edits = _edits.filter((edit) => !!edit);
298
277
  if (edits.length) {
299
278
  embedded.mergeWorkspaceEdits(edits[0], ...edits.slice(1));
300
279
  return edits[0];
301
280
  }
302
281
  return null;
303
- }));
304
- connection.onRequest(protocol_1.AutoInsertRequest.type, (params, token) => __awaiter(this, void 0, void 0, function* () {
282
+ });
283
+ connection.onRequest(protocol_1.AutoInsertRequest.type, async (params, token) => {
305
284
  return worker(params.textDocument.uri, token, service => {
306
285
  return service.doAutoInsert(params.textDocument.uri, params.position, params.options, token);
307
286
  });
308
- }));
287
+ });
309
288
  function worker(uri, token, cb) {
310
289
  return new Promise(resolve => {
311
- runtime.timer.setImmediate(() => __awaiter(this, void 0, void 0, function* () {
290
+ runtime.timer.setImmediate(async () => {
312
291
  if (token.isCancellationRequested) {
313
292
  resolve(undefined);
314
293
  return;
315
294
  }
316
- const service = yield getLanguageService(uri);
295
+ const service = await getLanguageService(uri);
317
296
  if (service) {
318
297
  try { // handle TS cancel throw
319
- const result = yield cb(service);
298
+ const result = await cb(service);
320
299
  if (token.isCancellationRequested) {
321
300
  resolve(undefined);
322
301
  return;
323
302
  }
324
303
  resolve(result);
325
304
  }
326
- catch (_a) {
305
+ catch {
327
306
  resolve(undefined);
328
307
  return;
329
308
  }
@@ -331,19 +310,15 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
331
310
  else {
332
311
  resolve(undefined);
333
312
  }
334
- }));
313
+ });
335
314
  });
336
315
  }
337
- function getLanguageService(uri) {
338
- var _a;
339
- return __awaiter(this, void 0, void 0, function* () {
340
- const project = (_a = (yield projects.getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
341
- return project === null || project === void 0 ? void 0 : project.getLanguageService();
342
- });
316
+ async function getLanguageService(uri) {
317
+ const project = (await projects.getProject(uri))?.project;
318
+ return project?.getLanguageService();
343
319
  }
344
320
  function fixTextEdit(item) {
345
- var _a, _b, _c, _d;
346
- const insertReplaceSupport = (_d = (_c = (_b = (_a = initParams.capabilities.textDocument) === null || _a === void 0 ? void 0 : _a.completion) === null || _b === void 0 ? void 0 : _b.completionItem) === null || _c === void 0 ? void 0 : _c.insertReplaceSupport) !== null && _d !== void 0 ? _d : false;
321
+ const insertReplaceSupport = initParams.capabilities.textDocument?.completion?.completionItem?.insertReplaceSupport ?? false;
347
322
  if (!insertReplaceSupport) {
348
323
  if (item.textEdit && vscode.InsertReplaceEdit.is(item.textEdit)) {
349
324
  item.textEdit = vscode.TextEdit.replace(item.textEdit.insert, item.textEdit.newText);