volar-service-typescript 0.0.31-patch.1 → 0.0.32
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.d.ts +4 -17
- package/index.js +12 -545
- package/lib/configs/getFormatCodeSettings.d.ts +2 -3
- package/lib/configs/getUserPreferences.d.ts +1 -1
- package/lib/plugins/directiveComment.d.ts +3 -0
- package/lib/plugins/directiveComment.js +65 -0
- package/lib/plugins/docCommentTemplate.d.ts +3 -0
- package/lib/{features/completions/jsDoc.js → plugins/docCommentTemplate.js} +42 -30
- package/lib/plugins/semantic.d.ts +23 -0
- package/lib/plugins/semantic.js +706 -0
- package/lib/plugins/syntactic.d.ts +7 -0
- package/lib/plugins/syntactic.js +92 -0
- package/lib/{features → semanticFeatures}/codeAction.d.ts +3 -2
- package/lib/{features → semanticFeatures}/codeAction.js +14 -17
- package/lib/{features → semanticFeatures}/codeActionResolve.d.ts +1 -1
- package/lib/{features → semanticFeatures}/codeActionResolve.js +7 -7
- package/lib/semanticFeatures/semanticTokens.d.ts +5 -0
- package/lib/{features → semanticFeatures}/semanticTokens.js +4 -8
- package/lib/{types.d.ts → semanticFeatures/types.d.ts} +1 -2
- package/lib/shared.d.ts +1 -0
- package/lib/shared.js +5 -1
- package/lib/syntacticLanguageService.d.ts +7 -0
- package/lib/syntacticLanguageService.js +38 -0
- package/lib/utils/lspConverters.d.ts +27 -0
- package/lib/utils/lspConverters.js +782 -0
- package/lib/utils/previewer.d.ts +5 -11
- package/lib/utils/previewer.js +30 -35
- package/package.json +5 -6
- package/lib/features/callHierarchy.d.ts +0 -8
- package/lib/features/callHierarchy.js +0 -102
- package/lib/features/completions/basic.d.ts +0 -17
- package/lib/features/completions/basic.js +0 -326
- package/lib/features/completions/directiveComment.d.ts +0 -4
- package/lib/features/completions/directiveComment.js +0 -54
- package/lib/features/completions/jsDoc.d.ts +0 -4
- package/lib/features/completions/resolve.d.ts +0 -6
- package/lib/features/completions/resolve.js +0 -146
- package/lib/features/definition.d.ts +0 -4
- package/lib/features/definition.js +0 -20
- package/lib/features/diagnostics.d.ts +0 -11
- package/lib/features/diagnostics.js +0 -120
- package/lib/features/documentHighlight.d.ts +0 -4
- package/lib/features/documentHighlight.js +0 -32
- package/lib/features/documentSymbol.d.ts +0 -4
- package/lib/features/documentSymbol.js +0 -94
- package/lib/features/fileReferences.d.ts +0 -4
- package/lib/features/fileReferences.js +0 -19
- package/lib/features/fileRename.d.ts +0 -4
- package/lib/features/fileRename.js +0 -25
- package/lib/features/foldingRanges.d.ts +0 -4
- package/lib/features/foldingRanges.js +0 -55
- package/lib/features/formatting.d.ts +0 -8
- package/lib/features/formatting.js +0 -55
- package/lib/features/hover.d.ts +0 -4
- package/lib/features/hover.js +0 -43
- package/lib/features/implementation.d.ts +0 -4
- package/lib/features/implementation.js +0 -20
- package/lib/features/inlayHints.d.ts +0 -4
- package/lib/features/inlayHints.js +0 -34
- package/lib/features/prepareRename.d.ts +0 -9
- package/lib/features/prepareRename.js +0 -27
- package/lib/features/references.d.ts +0 -4
- package/lib/features/references.js +0 -35
- package/lib/features/rename.d.ts +0 -6
- package/lib/features/rename.js +0 -116
- package/lib/features/selectionRanges.d.ts +0 -4
- package/lib/features/selectionRanges.js +0 -32
- package/lib/features/semanticTokens.d.ts +0 -4
- package/lib/features/signatureHelp.d.ts +0 -4
- package/lib/features/signatureHelp.js +0 -63
- package/lib/features/typeDefinition.d.ts +0 -4
- package/lib/features/typeDefinition.js +0 -20
- package/lib/features/workspaceSymbol.d.ts +0 -4
- package/lib/features/workspaceSymbol.js +0 -63
- package/lib/utils/transforms.d.ts +0 -15
- package/lib/utils/transforms.js +0 -85
- /package/lib/{types.js → semanticFeatures/types.js} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = void 0;
|
|
4
|
+
const nls = require("vscode-nls");
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
const localize = nls.loadMessageBundle(); // TODO: not working
|
|
7
|
+
const directives = [
|
|
8
|
+
{
|
|
9
|
+
value: '@ts-check',
|
|
10
|
+
description: localize('ts-check', "Enables semantic checking in a JavaScript file. Must be at the top of a file.")
|
|
11
|
+
}, {
|
|
12
|
+
value: '@ts-nocheck',
|
|
13
|
+
description: localize('ts-nocheck', "Disables semantic checking in a JavaScript file. Must be at the top of a file.")
|
|
14
|
+
}, {
|
|
15
|
+
value: '@ts-ignore',
|
|
16
|
+
description: localize('ts-ignore', "Suppresses @ts-check errors on the next line of a file.")
|
|
17
|
+
}, {
|
|
18
|
+
value: '@ts-expect-error',
|
|
19
|
+
description: localize('ts-expect-error', "Suppresses @ts-check errors on the next line of a file, expecting at least one to exist.")
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
function create() {
|
|
23
|
+
return {
|
|
24
|
+
name: 'typescript-directive-comment',
|
|
25
|
+
triggerCharacters: ['@'],
|
|
26
|
+
create() {
|
|
27
|
+
return {
|
|
28
|
+
provideCompletionItems(document, position) {
|
|
29
|
+
if (!(0, shared_1.isTsDocument)(document))
|
|
30
|
+
return;
|
|
31
|
+
const prefix = document.getText({
|
|
32
|
+
start: { line: position.line, character: 0 },
|
|
33
|
+
end: position,
|
|
34
|
+
});
|
|
35
|
+
const match = prefix.match(/^\s*\/\/+\s?(@[a-zA-Z\-]*)?$/);
|
|
36
|
+
if (match) {
|
|
37
|
+
const items = directives.map(directive => {
|
|
38
|
+
const item = { label: directive.value };
|
|
39
|
+
item.insertTextFormat = 2;
|
|
40
|
+
item.detail = directive.description;
|
|
41
|
+
const range = {
|
|
42
|
+
start: {
|
|
43
|
+
line: position.line,
|
|
44
|
+
character: Math.max(0, position.character - (match[1] ? match[1].length : 0)),
|
|
45
|
+
},
|
|
46
|
+
end: position,
|
|
47
|
+
};
|
|
48
|
+
item.textEdit = {
|
|
49
|
+
range,
|
|
50
|
+
newText: directive.value,
|
|
51
|
+
};
|
|
52
|
+
return item;
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
isIncomplete: false,
|
|
56
|
+
items,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.create = create;
|
|
65
|
+
//# sourceMappingURL=directiveComment.js.map
|
|
@@ -1,44 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.create = void 0;
|
|
4
4
|
const nls = require("vscode-nls");
|
|
5
|
-
const
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
const syntacticLanguageService_1 = require("../syntacticLanguageService");
|
|
7
|
+
const lspConverters_1 = require("../utils/lspConverters");
|
|
6
8
|
const localize = nls.loadMessageBundle(); // TODO: not working
|
|
7
9
|
const defaultJsDoc = `/**\n * $0\n */`;
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
function create(ts) {
|
|
11
|
+
return {
|
|
12
|
+
name: 'typescript-doc-comment-template',
|
|
13
|
+
triggerCharacters: ['*'],
|
|
14
|
+
create() {
|
|
15
|
+
return {
|
|
16
|
+
provideCompletionItems(document, position) {
|
|
17
|
+
if (!(0, shared_1.isTsDocument)(document))
|
|
18
|
+
return;
|
|
19
|
+
if (!isPotentiallyValidDocCompletionPosition(document, position))
|
|
20
|
+
return;
|
|
21
|
+
const { languageService, fileName } = (0, syntacticLanguageService_1.getLanguageService)(ts, document);
|
|
22
|
+
const offset = document.offsetAt(position);
|
|
23
|
+
const docCommentTemplate = languageService.getDocCommentTemplateAtPosition(fileName, offset);
|
|
24
|
+
if (!docCommentTemplate)
|
|
25
|
+
return;
|
|
26
|
+
let insertText;
|
|
27
|
+
// Workaround for #43619
|
|
28
|
+
// docCommentTemplate previously returned undefined for empty jsdoc templates.
|
|
29
|
+
// TS 2.7 now returns a single line doc comment, which breaks indentation.
|
|
30
|
+
if (docCommentTemplate.newText === '/** */') {
|
|
31
|
+
insertText = defaultJsDoc;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
insertText = templateToSnippet(docCommentTemplate.newText);
|
|
35
|
+
}
|
|
36
|
+
const item = createCompletionItem(document, position, insertText);
|
|
37
|
+
return {
|
|
38
|
+
isIncomplete: false,
|
|
39
|
+
items: [item],
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
32
44
|
};
|
|
33
45
|
}
|
|
34
|
-
exports.
|
|
46
|
+
exports.create = create;
|
|
35
47
|
function createCompletionItem(document, position, insertText) {
|
|
36
48
|
const item = { label: '/** */' };
|
|
37
49
|
item.kind = 1;
|
|
38
50
|
item.detail = localize('typescript.jsDocCompletionItem.documentation', 'JSDoc comment');
|
|
39
51
|
item.sortText = '\0';
|
|
40
52
|
item.insertTextFormat = 2;
|
|
41
|
-
const line = (0,
|
|
53
|
+
const line = (0, lspConverters_1.getLineText)(document, position.line);
|
|
42
54
|
const prefix = line.slice(0, position.character).match(/\/\**\s*$/);
|
|
43
55
|
const suffix = line.slice(position.character).match(/^\s*\**\//);
|
|
44
56
|
const start = { line: position.line, character: position.character + (prefix ? -prefix[0].length : 0) };
|
|
@@ -50,7 +62,7 @@ function createCompletionItem(document, position, insertText) {
|
|
|
50
62
|
function isPotentiallyValidDocCompletionPosition(document, position) {
|
|
51
63
|
// Only show the JSdoc completion when the everything before the cursor is whitespace
|
|
52
64
|
// or could be the opening of a comment
|
|
53
|
-
const line = (0,
|
|
65
|
+
const line = (0, lspConverters_1.getLineText)(document, position.line);
|
|
54
66
|
const prefix = line.slice(0, position.character);
|
|
55
67
|
if (!/^\s*$|\/\*\*\s*$|^\s*\/\*\*+\s*$/.test(prefix)) {
|
|
56
68
|
return false;
|
|
@@ -79,4 +91,4 @@ function templateToSnippet(template) {
|
|
|
79
91
|
template = template.replace(/\* @returns[ \t]*$/gm, `* @returns \${${snippetIndex++}}`);
|
|
80
92
|
return template;
|
|
81
93
|
}
|
|
82
|
-
//# sourceMappingURL=
|
|
94
|
+
//# sourceMappingURL=docCommentTemplate.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Result, ServiceContext, ServicePlugin } from '@volar/language-service';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
export interface Provide {
|
|
5
|
+
'typescript/languageService': () => ts.LanguageService;
|
|
6
|
+
'typescript/languageServiceHost': () => ts.LanguageServiceHost;
|
|
7
|
+
}
|
|
8
|
+
export interface CompletionItemData {
|
|
9
|
+
uri: string;
|
|
10
|
+
fileName: string;
|
|
11
|
+
offset: number;
|
|
12
|
+
originalItem: {
|
|
13
|
+
name: ts.CompletionEntry['name'];
|
|
14
|
+
source: ts.CompletionEntry['source'];
|
|
15
|
+
data: ts.CompletionEntry['data'];
|
|
16
|
+
labelDetails: ts.CompletionEntry['labelDetails'];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare function create(ts: typeof import('typescript'), { isValidationEnabled, isSuggestionsEnabled, }?: {
|
|
20
|
+
isValidationEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>;
|
|
21
|
+
isSuggestionsEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>;
|
|
22
|
+
}): ServicePlugin;
|
|
23
|
+
//# sourceMappingURL=semantic.d.ts.map
|