volar-service-typescript 0.0.22 → 0.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/index.js +23 -15
- package/package.json +2 -3
package/index.js
CHANGED
|
@@ -53,6 +53,7 @@ function create(ts) {
|
|
|
53
53
|
const jsDocTriggerCharacter = '*';
|
|
54
54
|
const directiveCommentTriggerCharacter = '@';
|
|
55
55
|
return {
|
|
56
|
+
name: 'typescript',
|
|
56
57
|
triggerCharacters: [
|
|
57
58
|
...basicTriggerCharacters,
|
|
58
59
|
jsDocTriggerCharacter,
|
|
@@ -117,8 +118,7 @@ function create(ts) {
|
|
|
117
118
|
provideAutoInsertionEdit(document, position, lastChange) {
|
|
118
119
|
if ((document.languageId === 'javascriptreact' || document.languageId === 'typescriptreact')
|
|
119
120
|
&& lastChange.text.endsWith('>')) {
|
|
120
|
-
const
|
|
121
|
-
const config = context.env.getConfiguration?.(configName) ?? true;
|
|
121
|
+
const config = context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.autoClosingTags') ?? true;
|
|
122
122
|
if (config) {
|
|
123
123
|
prepareSyntacticService(document);
|
|
124
124
|
const close = syntacticCtx.typescript.languageService.getJsxClosingTagAtPosition(context.env.uriToFileName(document.uri), document.offsetAt(position));
|
|
@@ -143,8 +143,8 @@ function create(ts) {
|
|
|
143
143
|
async provideDocumentFormattingEdits(document, range, options_2) {
|
|
144
144
|
if (!(0, shared_1.isTsDocument)(document))
|
|
145
145
|
return;
|
|
146
|
-
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format.enable');
|
|
147
|
-
if (enable
|
|
146
|
+
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format.enable') ?? true;
|
|
147
|
+
if (!enable) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
prepareSyntacticService(document);
|
|
@@ -153,8 +153,8 @@ function create(ts) {
|
|
|
153
153
|
async provideOnTypeFormattingEdits(document, position, key, options_2) {
|
|
154
154
|
if (!(0, shared_1.isTsDocument)(document))
|
|
155
155
|
return;
|
|
156
|
-
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format.enable');
|
|
157
|
-
if (enable
|
|
156
|
+
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.format.enable') ?? true;
|
|
157
|
+
if (!enable) {
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
prepareSyntacticService(document);
|
|
@@ -291,31 +291,35 @@ function create(ts) {
|
|
|
291
291
|
dispose() {
|
|
292
292
|
languageService.dispose();
|
|
293
293
|
},
|
|
294
|
-
provideCompletionItems(document, position,
|
|
294
|
+
async provideCompletionItems(document, position, completeContext, token) {
|
|
295
295
|
if (!(0, shared_1.isTsDocument)(document))
|
|
296
296
|
return;
|
|
297
|
-
|
|
297
|
+
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.suggest.enabled') ?? true;
|
|
298
|
+
if (!enable) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
return await worker(token, async () => {
|
|
298
302
|
let result = {
|
|
299
303
|
isIncomplete: false,
|
|
300
304
|
items: [],
|
|
301
305
|
};
|
|
302
|
-
if (!
|
|
306
|
+
if (!completeContext || completeContext.triggerKind !== 2 || (completeContext.triggerCharacter && basicTriggerCharacters.includes(completeContext.triggerCharacter))) {
|
|
303
307
|
const completeOptions = {
|
|
304
|
-
triggerCharacter:
|
|
305
|
-
triggerKind:
|
|
308
|
+
triggerCharacter: completeContext.triggerCharacter,
|
|
309
|
+
triggerKind: completeContext.triggerKind,
|
|
306
310
|
};
|
|
307
311
|
const basicResult = await doComplete(document.uri, position, completeOptions);
|
|
308
312
|
if (basicResult) {
|
|
309
313
|
result = basicResult;
|
|
310
314
|
}
|
|
311
315
|
}
|
|
312
|
-
if (!
|
|
316
|
+
if (!completeContext || completeContext.triggerKind !== 2 || completeContext.triggerCharacter === jsDocTriggerCharacter) {
|
|
313
317
|
const jsdocResult = await doJsDocComplete(document.uri, position);
|
|
314
318
|
if (jsdocResult) {
|
|
315
319
|
result.items.push(jsdocResult);
|
|
316
320
|
}
|
|
317
321
|
}
|
|
318
|
-
if (!
|
|
322
|
+
if (!completeContext || completeContext.triggerKind !== 2 || completeContext.triggerCharacter === directiveCommentTriggerCharacter) {
|
|
319
323
|
const directiveCommentResult = await doDirectiveCommentComplete(document.uri, position);
|
|
320
324
|
if (directiveCommentResult) {
|
|
321
325
|
result.items = result.items.concat(directiveCommentResult);
|
|
@@ -393,10 +397,14 @@ function create(ts) {
|
|
|
393
397
|
return findTypeDefinition(document.uri, position);
|
|
394
398
|
});
|
|
395
399
|
},
|
|
396
|
-
provideDiagnostics(document, token) {
|
|
400
|
+
async provideDiagnostics(document, token) {
|
|
397
401
|
if (!(0, shared_1.isTsDocument)(document))
|
|
398
402
|
return;
|
|
399
|
-
|
|
403
|
+
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.validate.enable') ?? true;
|
|
404
|
+
if (!enable) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
return await worker(token, () => {
|
|
400
408
|
return doValidation(document.uri, { syntactic: true, suggestion: true });
|
|
401
409
|
});
|
|
402
410
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Integrate TypeScript into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/typescript",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"keywords": [
|
|
9
9
|
"volar-service"
|
|
10
10
|
],
|
|
11
|
-
"main": "out/index.js",
|
|
12
11
|
"license": "MIT",
|
|
13
12
|
"files": [
|
|
14
13
|
"**/*.js",
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"optional": true
|
|
47
46
|
}
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "f0532815ff3cdcf289dc582ddd3b8e3bff0cba26"
|
|
50
49
|
}
|