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.
Files changed (77) hide show
  1. package/index.d.ts +4 -17
  2. package/index.js +12 -545
  3. package/lib/configs/getFormatCodeSettings.d.ts +2 -3
  4. package/lib/configs/getUserPreferences.d.ts +1 -1
  5. package/lib/plugins/directiveComment.d.ts +3 -0
  6. package/lib/plugins/directiveComment.js +65 -0
  7. package/lib/plugins/docCommentTemplate.d.ts +3 -0
  8. package/lib/{features/completions/jsDoc.js → plugins/docCommentTemplate.js} +42 -30
  9. package/lib/plugins/semantic.d.ts +23 -0
  10. package/lib/plugins/semantic.js +706 -0
  11. package/lib/plugins/syntactic.d.ts +7 -0
  12. package/lib/plugins/syntactic.js +92 -0
  13. package/lib/{features → semanticFeatures}/codeAction.d.ts +3 -2
  14. package/lib/{features → semanticFeatures}/codeAction.js +14 -17
  15. package/lib/{features → semanticFeatures}/codeActionResolve.d.ts +1 -1
  16. package/lib/{features → semanticFeatures}/codeActionResolve.js +7 -7
  17. package/lib/semanticFeatures/semanticTokens.d.ts +5 -0
  18. package/lib/{features → semanticFeatures}/semanticTokens.js +4 -8
  19. package/lib/{types.d.ts → semanticFeatures/types.d.ts} +1 -2
  20. package/lib/shared.d.ts +1 -0
  21. package/lib/shared.js +5 -1
  22. package/lib/syntacticLanguageService.d.ts +7 -0
  23. package/lib/syntacticLanguageService.js +38 -0
  24. package/lib/utils/lspConverters.d.ts +27 -0
  25. package/lib/utils/lspConverters.js +782 -0
  26. package/lib/utils/previewer.d.ts +5 -11
  27. package/lib/utils/previewer.js +30 -35
  28. package/package.json +5 -6
  29. package/lib/features/callHierarchy.d.ts +0 -8
  30. package/lib/features/callHierarchy.js +0 -102
  31. package/lib/features/completions/basic.d.ts +0 -17
  32. package/lib/features/completions/basic.js +0 -326
  33. package/lib/features/completions/directiveComment.d.ts +0 -4
  34. package/lib/features/completions/directiveComment.js +0 -54
  35. package/lib/features/completions/jsDoc.d.ts +0 -4
  36. package/lib/features/completions/resolve.d.ts +0 -6
  37. package/lib/features/completions/resolve.js +0 -146
  38. package/lib/features/definition.d.ts +0 -4
  39. package/lib/features/definition.js +0 -20
  40. package/lib/features/diagnostics.d.ts +0 -11
  41. package/lib/features/diagnostics.js +0 -120
  42. package/lib/features/documentHighlight.d.ts +0 -4
  43. package/lib/features/documentHighlight.js +0 -32
  44. package/lib/features/documentSymbol.d.ts +0 -4
  45. package/lib/features/documentSymbol.js +0 -94
  46. package/lib/features/fileReferences.d.ts +0 -4
  47. package/lib/features/fileReferences.js +0 -19
  48. package/lib/features/fileRename.d.ts +0 -4
  49. package/lib/features/fileRename.js +0 -25
  50. package/lib/features/foldingRanges.d.ts +0 -4
  51. package/lib/features/foldingRanges.js +0 -55
  52. package/lib/features/formatting.d.ts +0 -8
  53. package/lib/features/formatting.js +0 -55
  54. package/lib/features/hover.d.ts +0 -4
  55. package/lib/features/hover.js +0 -43
  56. package/lib/features/implementation.d.ts +0 -4
  57. package/lib/features/implementation.js +0 -20
  58. package/lib/features/inlayHints.d.ts +0 -4
  59. package/lib/features/inlayHints.js +0 -34
  60. package/lib/features/prepareRename.d.ts +0 -9
  61. package/lib/features/prepareRename.js +0 -27
  62. package/lib/features/references.d.ts +0 -4
  63. package/lib/features/references.js +0 -35
  64. package/lib/features/rename.d.ts +0 -6
  65. package/lib/features/rename.js +0 -116
  66. package/lib/features/selectionRanges.d.ts +0 -4
  67. package/lib/features/selectionRanges.js +0 -32
  68. package/lib/features/semanticTokens.d.ts +0 -4
  69. package/lib/features/signatureHelp.d.ts +0 -4
  70. package/lib/features/signatureHelp.js +0 -63
  71. package/lib/features/typeDefinition.d.ts +0 -4
  72. package/lib/features/typeDefinition.js +0 -20
  73. package/lib/features/workspaceSymbol.d.ts +0 -4
  74. package/lib/features/workspaceSymbol.js +0 -63
  75. package/lib/utils/transforms.d.ts +0 -15
  76. package/lib/utils/transforms.js +0 -85
  77. /package/lib/{types.js → semanticFeatures/types.js} +0 -0
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const nls = require("vscode-nls");
5
- const localize = nls.loadMessageBundle(); // TODO: not working
6
- const directives = [
7
- {
8
- value: '@ts-check',
9
- description: localize('ts-check', "Enables semantic checking in a JavaScript file. Must be at the top of a file.")
10
- }, {
11
- value: '@ts-nocheck',
12
- description: localize('ts-nocheck', "Disables semantic checking in a JavaScript file. Must be at the top of a file.")
13
- }, {
14
- value: '@ts-ignore',
15
- description: localize('ts-ignore', "Suppresses @ts-check errors on the next line of a file.")
16
- }, {
17
- value: '@ts-expect-error',
18
- description: localize('ts-expect-error', "Suppresses @ts-check errors on the next line of a file, expecting at least one to exist.")
19
- }
20
- ];
21
- function register(ctx) {
22
- return (uri, position) => {
23
- const document = ctx.getTextDocument(uri);
24
- if (!document)
25
- return;
26
- const prefix = document.getText({
27
- start: { line: position.line, character: 0 },
28
- end: position,
29
- });
30
- const match = prefix.match(/^\s*\/\/+\s?(@[a-zA-Z\-]*)?$/);
31
- if (match) {
32
- return directives.map(directive => {
33
- const item = { label: directive.value };
34
- item.insertTextFormat = 2;
35
- item.detail = directive.description;
36
- const range = {
37
- start: {
38
- line: position.line,
39
- character: Math.max(0, position.character - (match[1] ? match[1].length : 0)),
40
- },
41
- end: position,
42
- };
43
- item.textEdit = {
44
- range,
45
- newText: directive.value,
46
- };
47
- return item;
48
- });
49
- }
50
- return [];
51
- };
52
- }
53
- exports.register = register;
54
- //# sourceMappingURL=directiveComment.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { SharedContext } from '../../types';
3
- export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.CompletionItem | undefined;
4
- //# sourceMappingURL=jsDoc.d.ts.map
@@ -1,6 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { TextDocument } from 'vscode-languageserver-textdocument';
3
- import type { SharedContext } from '../../types';
4
- export declare function register(ctx: SharedContext): (item: vscode.CompletionItem, newPosition?: vscode.Position) => Promise<vscode.CompletionItem>;
5
- export declare function getLineText(document: TextDocument, line: number): string;
6
- //# sourceMappingURL=resolve.d.ts.map
@@ -1,146 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLineText = exports.register = void 0;
4
- const getFormatCodeSettings_1 = require("../../configs/getFormatCodeSettings");
5
- const getUserPreferences_1 = require("../../configs/getUserPreferences");
6
- const shared_1 = require("../../shared");
7
- const previewer = require("../../utils/previewer");
8
- const snippetForFunctionCall_1 = require("../../utils/snippetForFunctionCall");
9
- const transforms_1 = require("../../utils/transforms");
10
- const basic_1 = require("./basic");
11
- function register(ctx) {
12
- const { ts } = ctx;
13
- return async (item, newPosition) => {
14
- const data = item.data;
15
- if (!data)
16
- return item;
17
- const fileName = data.fileName;
18
- let offset = data.offset;
19
- const document = ctx.getTextDocument(data.uri);
20
- if (newPosition && document) {
21
- offset = document.offsetAt(newPosition);
22
- }
23
- const [formatOptions, preferences] = document ? await Promise.all([
24
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
25
- (0, getUserPreferences_1.getUserPreferences)(ctx, document),
26
- ]) : [{}, {}];
27
- let details;
28
- try {
29
- details = ctx.languageService.getCompletionEntryDetails(fileName, offset, data.originalItem.name, formatOptions, data.originalItem.source, preferences, data.originalItem.data);
30
- }
31
- catch (err) {
32
- item.detail = `[TS Error]\n${err}\n${JSON.stringify(err, undefined, 2)}`;
33
- }
34
- if (!details)
35
- return item;
36
- if (data.originalItem.labelDetails) {
37
- item.labelDetails ??= {};
38
- Object.assign(item.labelDetails, data.originalItem.labelDetails);
39
- }
40
- const { sourceDisplay } = details;
41
- if (sourceDisplay) {
42
- item.labelDetails ??= {};
43
- item.labelDetails.description = ts.displayPartsToString(sourceDisplay);
44
- }
45
- const detailTexts = [];
46
- if (details.codeActions) {
47
- if (!item.additionalTextEdits)
48
- item.additionalTextEdits = [];
49
- for (const action of details.codeActions) {
50
- detailTexts.push(action.description);
51
- for (const changes of action.changes) {
52
- const entries = changes.textChanges.map(textChange => {
53
- return { fileName, textSpan: textChange.span };
54
- });
55
- const locs = (0, transforms_1.entriesToLocations)(entries, ctx);
56
- locs.forEach((loc, index) => {
57
- item.additionalTextEdits?.push({ range: loc.range, newText: changes.textChanges[index].newText });
58
- });
59
- }
60
- }
61
- }
62
- if (details.displayParts) {
63
- detailTexts.push(previewer.plainWithLinks(details.displayParts, { toResource }, ctx));
64
- }
65
- if (detailTexts.length) {
66
- item.detail = detailTexts.join('\n');
67
- }
68
- item.documentation = {
69
- kind: 'markdown',
70
- value: previewer.markdownDocumentation(details.documentation, details.tags, { toResource }, ctx),
71
- };
72
- if (details) {
73
- (0, basic_1.handleKindModifiers)(item, details);
74
- }
75
- if (document) {
76
- const useCodeSnippetsOnMethodSuggest = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.suggest.completeFunctionCalls') ?? false;
77
- const useCodeSnippet = useCodeSnippetsOnMethodSuggest && (item.kind === 3 || item.kind === 2);
78
- if (useCodeSnippet) {
79
- const shouldCompleteFunction = isValidFunctionCompletionContext(ctx.languageService, fileName, offset, document);
80
- if (shouldCompleteFunction) {
81
- const { snippet, parameterCount } = (0, snippetForFunctionCall_1.snippetForFunctionCall)({
82
- insertText: item.insertText ?? item.textEdit?.newText, // insertText is dropped by LSP in some case: https://github.com/microsoft/vscode-languageserver-node/blob/9b742021fb04ad081aa3676a9eecf4fa612084b4/client/src/common/codeConverter.ts#L659-L664
83
- label: item.label,
84
- }, details.displayParts);
85
- if (item.textEdit) {
86
- item.textEdit.newText = snippet;
87
- }
88
- if (item.insertText) {
89
- item.insertText = snippet;
90
- }
91
- item.insertTextFormat = 2;
92
- if (parameterCount > 0) {
93
- //Fix for https://github.com/microsoft/vscode/issues/104059
94
- //Don't show parameter hints if "editor.parameterHints.enabled": false
95
- // if (await getConfiguration('editor.parameterHints.enabled', document.uri)) {
96
- // item.command = {
97
- // title: 'triggerParameterHints',
98
- // command: 'editor.action.triggerParameterHints',
99
- // };
100
- // }
101
- }
102
- }
103
- }
104
- }
105
- return item;
106
- function toResource(path) {
107
- return ctx.fileNameToUri(path);
108
- }
109
- };
110
- }
111
- exports.register = register;
112
- function isValidFunctionCompletionContext(client, filepath, offset, document) {
113
- // Workaround for https://github.com/microsoft/TypeScript/issues/12677
114
- // Don't complete function calls inside of destructive assignments or imports
115
- try {
116
- const response = client.getQuickInfoAtPosition(filepath, offset);
117
- if (response) {
118
- switch (response.kind) {
119
- case 'var':
120
- case 'let':
121
- case 'const':
122
- case 'alias':
123
- return false;
124
- }
125
- }
126
- }
127
- catch {
128
- // Noop
129
- }
130
- // Don't complete function call if there is already something that looks like a function call
131
- // https://github.com/microsoft/vscode/issues/18131
132
- const position = document.positionAt(offset);
133
- const after = getLineText(document, position.line).slice(position.character);
134
- return after.match(/^[a-z_$0-9]*\s*\(/gi) === null;
135
- }
136
- function getLineText(document, line) {
137
- const endOffset = document.offsetAt({ line: line + 1, character: 0 });
138
- const end = document.positionAt(endOffset);
139
- const text = document.getText({
140
- start: { line: line, character: 0 },
141
- end: end.line === line ? end : document.positionAt(endOffset - 1),
142
- });
143
- return text;
144
- }
145
- exports.getLineText = getLineText;
146
- //# sourceMappingURL=resolve.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { SharedContext } from '../types';
3
- export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.LocationLink[];
4
- //# sourceMappingURL=definition.d.ts.map
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const shared_1 = require("../shared");
5
- const transforms_1 = require("../utils/transforms");
6
- function register(ctx) {
7
- return (uri, position) => {
8
- const document = ctx.getTextDocument(uri);
9
- if (!document)
10
- return [];
11
- const fileName = ctx.uriToFileName(document.uri);
12
- const offset = document.offsetAt(position);
13
- const info = (0, shared_1.safeCall)(() => ctx.languageService.getDefinitionAndBoundSpan(fileName, offset));
14
- if (!info)
15
- return [];
16
- return (0, transforms_1.boundSpanToLocationLinks)(info, document, ctx);
17
- };
18
- }
19
- exports.register = register;
20
- //# sourceMappingURL=definition.js.map
@@ -1,11 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type * as ts from 'typescript';
3
- import type { SharedContext } from '../types';
4
- export declare function register(ctx: SharedContext): (uri: string, options: {
5
- semantic?: boolean;
6
- syntactic?: boolean;
7
- suggestion?: boolean;
8
- declaration?: boolean;
9
- }) => vscode.Diagnostic[];
10
- export declare function getEmitDeclarations(compilerOptions: ts.CompilerOptions): boolean;
11
- //# sourceMappingURL=diagnostics.d.ts.map
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEmitDeclarations = exports.register = void 0;
4
- const shared_1 = require("../shared");
5
- function register(ctx) {
6
- const { ts } = ctx;
7
- return (uri, options) => {
8
- const document = ctx.getTextDocument(uri);
9
- if (!document)
10
- return [];
11
- const fileName = ctx.uriToFileName(document.uri);
12
- const program = ctx.languageService.getProgram();
13
- const sourceFile = program?.getSourceFile(fileName);
14
- if (!program || !sourceFile)
15
- return [];
16
- const token = {
17
- isCancellationRequested() {
18
- return ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;
19
- },
20
- throwIfCancellationRequested() { },
21
- };
22
- let errors = (0, shared_1.safeCall)(() => [
23
- ...options.semantic ? program.getSemanticDiagnostics(sourceFile, token) : [],
24
- ...options.syntactic ? program.getSyntacticDiagnostics(sourceFile, token) : [],
25
- ...options.suggestion ? ctx.languageService.getSuggestionDiagnostics(fileName) : [],
26
- ]) ?? [];
27
- if (options.declaration && getEmitDeclarations(program.getCompilerOptions())) {
28
- errors = errors.concat(program.getDeclarationDiagnostics(sourceFile, token));
29
- }
30
- return translateDiagnostics(document, errors);
31
- function translateDiagnostics(document, input) {
32
- return input.map(diag => translateDiagnostic(diag, document)).filter((v) => !!v);
33
- }
34
- function translateDiagnostic(diag, document) {
35
- if (diag.start === undefined)
36
- return;
37
- if (diag.length === undefined)
38
- return;
39
- const diagnostic = {
40
- range: {
41
- start: document.positionAt(diag.start),
42
- end: document.positionAt(diag.start + diag.length),
43
- },
44
- severity: translateErrorType(diag.category),
45
- source: 'ts',
46
- code: diag.code,
47
- message: getMessageText(diag),
48
- };
49
- if (diag.relatedInformation) {
50
- diagnostic.relatedInformation = diag.relatedInformation
51
- .map(rErr => translateDiagnosticRelated(rErr))
52
- .filter((v) => !!v);
53
- }
54
- if (diag.reportsUnnecessary) {
55
- if (diagnostic.tags === undefined)
56
- diagnostic.tags = [];
57
- diagnostic.tags.push(1);
58
- }
59
- if (diag.reportsDeprecated) {
60
- if (diagnostic.tags === undefined)
61
- diagnostic.tags = [];
62
- diagnostic.tags.push(2);
63
- }
64
- return diagnostic;
65
- }
66
- function translateDiagnosticRelated(diag) {
67
- if (diag.start === undefined)
68
- return;
69
- if (diag.length === undefined)
70
- return;
71
- let document;
72
- if (diag.file) {
73
- document = ctx.getTextDocument(ctx.fileNameToUri(diag.file.fileName));
74
- }
75
- if (!document)
76
- return;
77
- const diagnostic = {
78
- location: {
79
- uri: document.uri,
80
- range: {
81
- start: document.positionAt(diag.start),
82
- end: document.positionAt(diag.start + diag.length),
83
- },
84
- },
85
- message: getMessageText(diag),
86
- };
87
- return diagnostic;
88
- }
89
- function translateErrorType(input) {
90
- switch (input) {
91
- case ts.DiagnosticCategory.Warning: return 2;
92
- case ts.DiagnosticCategory.Error: return 1;
93
- case ts.DiagnosticCategory.Suggestion: return 4;
94
- case ts.DiagnosticCategory.Message: return 3;
95
- }
96
- return 1;
97
- }
98
- };
99
- }
100
- exports.register = register;
101
- function getMessageText(diag, level = 0) {
102
- let messageText = ' '.repeat(level);
103
- if (typeof diag.messageText === 'string') {
104
- messageText += diag.messageText;
105
- }
106
- else {
107
- messageText += diag.messageText.messageText;
108
- if (diag.messageText.next) {
109
- for (const info of diag.messageText.next) {
110
- messageText += '\n' + getMessageText(info, level + 1);
111
- }
112
- }
113
- }
114
- return messageText;
115
- }
116
- function getEmitDeclarations(compilerOptions) {
117
- return !!(compilerOptions.declaration || compilerOptions.composite);
118
- }
119
- exports.getEmitDeclarations = getEmitDeclarations;
120
- //# sourceMappingURL=diagnostics.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { SharedContext } from '../types';
3
- export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.DocumentHighlight[];
4
- //# sourceMappingURL=documentHighlight.d.ts.map
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const shared_1 = require("../shared");
5
- function register(ctx) {
6
- const { ts } = ctx;
7
- return (uri, position) => {
8
- const document = ctx.getTextDocument(uri);
9
- if (!document)
10
- return [];
11
- const fileName = ctx.uriToFileName(document.uri);
12
- const offset = document.offsetAt(position);
13
- const highlights = (0, shared_1.safeCall)(() => ctx.languageService.getDocumentHighlights(fileName, offset, [fileName]));
14
- if (!highlights)
15
- return [];
16
- const results = [];
17
- for (const highlight of highlights) {
18
- for (const span of highlight.highlightSpans) {
19
- results.push({
20
- kind: span.kind === ts.HighlightSpanKind.writtenReference ? 3 : 2,
21
- range: {
22
- start: document.positionAt(span.textSpan.start),
23
- end: document.positionAt(span.textSpan.start + span.textSpan.length),
24
- },
25
- });
26
- }
27
- }
28
- return results;
29
- };
30
- }
31
- exports.register = register;
32
- //# sourceMappingURL=documentHighlight.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { SharedContext } from '../types';
3
- export declare function register(ctx: SharedContext): (uri: string) => vscode.DocumentSymbol[];
4
- //# sourceMappingURL=documentSymbol.d.ts.map
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const PConst = require("../protocol.const");
5
- const shared_1 = require("../shared");
6
- const modifiers_1 = require("../utils/modifiers");
7
- const getSymbolKind = (kind) => {
8
- switch (kind) {
9
- case PConst.Kind.module: return 2;
10
- case PConst.Kind.class: return 5;
11
- case PConst.Kind.enum: return 10;
12
- case PConst.Kind.interface: return 11;
13
- case PConst.Kind.method: return 6;
14
- case PConst.Kind.memberVariable: return 7;
15
- case PConst.Kind.memberGetAccessor: return 7;
16
- case PConst.Kind.memberSetAccessor: return 7;
17
- case PConst.Kind.variable: return 13;
18
- case PConst.Kind.const: return 13;
19
- case PConst.Kind.localVariable: return 13;
20
- case PConst.Kind.function: return 12;
21
- case PConst.Kind.localFunction: return 12;
22
- case PConst.Kind.constructSignature: return 9;
23
- case PConst.Kind.constructorImplementation: return 9;
24
- }
25
- return 13;
26
- };
27
- function register(ctx) {
28
- return (uri) => {
29
- const document = ctx.getTextDocument(uri);
30
- if (!document)
31
- return [];
32
- const fileName = ctx.uriToFileName(document.uri);
33
- const barItems = (0, shared_1.safeCall)(() => ctx.languageService.getNavigationTree(fileName));
34
- if (!barItems)
35
- return [];
36
- // The root represents the file. Ignore this when showing in the UI
37
- const result = barItems.childItems
38
- ?.map(function convertNavTree(item) {
39
- if (!shouldIncludeEntry(item)) {
40
- return [];
41
- }
42
- let remain = item.childItems ?? [];
43
- return item.spans.map(span => {
44
- const childItems = [];
45
- remain = remain.filter(child => {
46
- const childStart = child.spans[0].start;
47
- const childEnd = child.spans[child.spans.length - 1].start + child.spans[child.spans.length - 1].length;
48
- if (childStart >= span.start && childEnd <= span.start + span.length) {
49
- childItems.push(child);
50
- return false;
51
- }
52
- return true;
53
- });
54
- const nameSpan = item.spans.length === 1
55
- ? (item.nameSpan ?? span)
56
- : span;
57
- const fullRange = {
58
- start: Math.min(span.start, nameSpan.start),
59
- end: Math.max(span.start + span.length, nameSpan.start + nameSpan.length),
60
- };
61
- const symbol = {
62
- name: item.text,
63
- kind: getSymbolKind(item.kind),
64
- range: {
65
- start: document.positionAt(fullRange.start),
66
- end: document.positionAt(fullRange.end),
67
- },
68
- selectionRange: {
69
- start: document.positionAt(nameSpan.start),
70
- end: document.positionAt(nameSpan.start + nameSpan.length),
71
- },
72
- children: childItems.map(convertNavTree).flat(),
73
- };
74
- const kindModifiers = (0, modifiers_1.parseKindModifier)(item.kindModifiers);
75
- if (kindModifiers.has(PConst.KindModifiers.deprecated)) {
76
- symbol.deprecated = true;
77
- symbol.tags ??= [];
78
- symbol.tags.push(1);
79
- }
80
- return symbol;
81
- });
82
- })
83
- .flat();
84
- return result ?? [];
85
- function shouldIncludeEntry(item) {
86
- if (item.kind === PConst.Kind.alias) {
87
- return false;
88
- }
89
- return !!(item.text && item.text !== '<function>' && item.text !== '<class>');
90
- }
91
- };
92
- }
93
- exports.register = register;
94
- //# sourceMappingURL=documentSymbol.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { SharedContext } from '../types';
3
- export declare function register(ctx: SharedContext): (uri: string) => vscode.Location[];
4
- //# sourceMappingURL=fileReferences.d.ts.map
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const shared_1 = require("../shared");
5
- const transforms_1 = require("../utils/transforms");
6
- function register(ctx) {
7
- return (uri) => {
8
- const document = ctx.getTextDocument(uri);
9
- if (!document)
10
- return [];
11
- const fileName = ctx.uriToFileName(document.uri);
12
- const entries = (0, shared_1.safeCall)(() => ctx.languageService.getFileReferences(fileName));
13
- if (!entries)
14
- return [];
15
- return (0, transforms_1.entriesToLocations)([...entries], ctx);
16
- };
17
- }
18
- exports.register = register;
19
- //# sourceMappingURL=fileReferences.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from 'vscode-languageserver-protocol';
2
- import type { SharedContext } from '../types';
3
- export declare function register(ctx: SharedContext): (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
4
- //# sourceMappingURL=fileRename.d.ts.map
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
5
- const getUserPreferences_1 = require("../configs/getUserPreferences");
6
- const shared_1 = require("../shared");
7
- const rename_1 = require("./rename");
8
- function register(ctx) {
9
- return async (oldUri, newUri) => {
10
- const document = ctx.getTextDocument(oldUri);
11
- const [formatOptions, preferences] = document ? await Promise.all([
12
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
13
- (0, getUserPreferences_1.getUserPreferences)(ctx, document),
14
- ]) : [{}, {}];
15
- const fileToRename = ctx.uriToFileName(oldUri);
16
- const newFilePath = ctx.uriToFileName(newUri);
17
- const response = (0, shared_1.safeCall)(() => ctx.languageService.getEditsForFileRename(fileToRename, newFilePath, formatOptions, preferences));
18
- if (!response?.length)
19
- return;
20
- const edits = (0, rename_1.fileTextChangesToWorkspaceEdit)(response, ctx);
21
- return edits;
22
- };
23
- }
24
- exports.register = register;
25
- //# sourceMappingURL=fileRename.js.map
@@ -1,4 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { SharedContext } from '../types';
3
- export declare function register(ctx: SharedContext): (uri: string) => vscode.FoldingRange[];
4
- //# sourceMappingURL=foldingRanges.d.ts.map
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const shared_1 = require("../shared");
5
- function register(ctx) {
6
- const { ts } = ctx;
7
- return (uri) => {
8
- const document = ctx.getTextDocument(uri);
9
- if (!document)
10
- return [];
11
- const fileName = ctx.uriToFileName(document.uri);
12
- const outliningSpans = (0, shared_1.safeCall)(() => ctx.languageService.getOutliningSpans(fileName));
13
- if (!outliningSpans)
14
- return [];
15
- const foldingRanges = [];
16
- for (const outliningSpan of outliningSpans) {
17
- const start = document.positionAt(outliningSpan.textSpan.start);
18
- const end = adjustFoldingEnd(start, document.positionAt(outliningSpan.textSpan.start + outliningSpan.textSpan.length), document);
19
- const foldingRange = {
20
- startLine: start.line,
21
- endLine: end.line,
22
- startCharacter: start.character,
23
- endCharacter: end.character,
24
- kind: transformFoldingRangeKind(outliningSpan.kind),
25
- };
26
- foldingRanges.push(foldingRange);
27
- }
28
- return foldingRanges;
29
- };
30
- function transformFoldingRangeKind(tsKind) {
31
- switch (tsKind) {
32
- case ts.OutliningSpanKind.Comment: return 'comment';
33
- case ts.OutliningSpanKind.Imports: return 'imports';
34
- case ts.OutliningSpanKind.Region: return 'region';
35
- }
36
- }
37
- }
38
- exports.register = register;
39
- const foldEndPairCharacters = ['}', ']', ')', '`'];
40
- // https://github.com/microsoft/vscode/blob/bed61166fb604e519e82e4d1d1ed839bc45d65f8/extensions/typescript-language-features/src/languageFeatures/folding.ts#L61-L73
41
- function adjustFoldingEnd(start, end, document) {
42
- // workaround for #47240
43
- if (end.character > 0) {
44
- const foldEndCharacter = document.getText({
45
- start: { line: end.line, character: end.character - 1 },
46
- end,
47
- });
48
- if (foldEndPairCharacters.includes(foldEndCharacter)) {
49
- const endOffset = Math.max(document.offsetAt({ line: end.line, character: 0 }) - 1, document.offsetAt(start));
50
- return document.positionAt(endOffset);
51
- }
52
- }
53
- return end;
54
- }
55
- //# sourceMappingURL=foldingRanges.js.map
@@ -1,8 +0,0 @@
1
- import type * as vscode from '@volar/language-service';
2
- import type { TextDocument } from 'vscode-languageserver-textdocument';
3
- import type { SharedContext } from '../types';
4
- export declare function register(ctx: SharedContext): {
5
- onRange: (document: TextDocument, range: vscode.Range | undefined, options: vscode.FormattingOptions, codeOptions: vscode.EmbeddedCodeFormattingOptions | undefined) => Promise<vscode.TextEdit[]>;
6
- onType: (document: TextDocument, options: vscode.FormattingOptions, codeOptions: vscode.EmbeddedCodeFormattingOptions | undefined, position: vscode.Position, key: string) => Promise<vscode.TextEdit[]>;
7
- };
8
- //# sourceMappingURL=formatting.d.ts.map