volar-service-typescript 0.0.0
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/out/configs/getFormatCodeSettings.d.ts +5 -0
- package/out/configs/getFormatCodeSettings.js +34 -0
- package/out/configs/getUserPreferences.d.ts +4 -0
- package/out/configs/getUserPreferences.js +97 -0
- package/out/index.d.ts +3 -0
- package/out/index.js +421 -0
- package/out/protocol.const.d.ts +72 -0
- package/out/protocol.const.js +92 -0
- package/out/services/callHierarchy.d.ts +7 -0
- package/out/services/callHierarchy.js +126 -0
- package/out/services/codeAction.d.ts +26 -0
- package/out/services/codeAction.js +242 -0
- package/out/services/codeActionResolve.d.ts +9 -0
- package/out/services/codeActionResolve.js +51 -0
- package/out/services/completions/basic.d.ts +16 -0
- package/out/services/completions/basic.js +322 -0
- package/out/services/completions/directiveComment.d.ts +3 -0
- package/out/services/completions/directiveComment.js +69 -0
- package/out/services/completions/jsDoc.d.ts +3 -0
- package/out/services/completions/jsDoc.js +106 -0
- package/out/services/completions/resolve.d.ts +5 -0
- package/out/services/completions/resolve.js +170 -0
- package/out/services/definition.d.ts +3 -0
- package/out/services/definition.js +20 -0
- package/out/services/diagnostics.d.ts +10 -0
- package/out/services/diagnostics.js +144 -0
- package/out/services/documentHighlight.d.ts +3 -0
- package/out/services/documentHighlight.js +56 -0
- package/out/services/documentSymbol.d.ts +3 -0
- package/out/services/documentSymbol.js +106 -0
- package/out/services/fileReferences.d.ts +3 -0
- package/out/services/fileReferences.js +19 -0
- package/out/services/fileRename.d.ts +3 -0
- package/out/services/fileRename.js +25 -0
- package/out/services/foldingRanges.d.ts +3 -0
- package/out/services/foldingRanges.js +73 -0
- package/out/services/formatting.d.ts +6 -0
- package/out/services/formatting.js +58 -0
- package/out/services/hover.d.ts +3 -0
- package/out/services/hover.js +64 -0
- package/out/services/implementation.d.ts +3 -0
- package/out/services/implementation.js +20 -0
- package/out/services/inlayHints.d.ts +3 -0
- package/out/services/inlayHints.js +54 -0
- package/out/services/prepareRename.d.ts +6 -0
- package/out/services/prepareRename.js +51 -0
- package/out/services/references.d.ts +3 -0
- package/out/services/references.js +20 -0
- package/out/services/rename.d.ts +5 -0
- package/out/services/rename.js +135 -0
- package/out/services/selectionRanges.d.ts +3 -0
- package/out/services/selectionRanges.js +53 -0
- package/out/services/semanticTokens.d.ts +3 -0
- package/out/services/semanticTokens.js +128 -0
- package/out/services/signatureHelp.d.ts +3 -0
- package/out/services/signatureHelp.js +87 -0
- package/out/services/tsconfig.d.ts +6 -0
- package/out/services/tsconfig.js +199 -0
- package/out/services/typeDefinition.d.ts +3 -0
- package/out/services/typeDefinition.js +20 -0
- package/out/services/workspaceSymbol.d.ts +3 -0
- package/out/services/workspaceSymbol.js +80 -0
- package/out/shared.d.ts +5 -0
- package/out/shared.js +33 -0
- package/out/types.d.ts +5 -0
- package/out/types.js +3 -0
- package/out/utils/errorCodes.d.ts +11 -0
- package/out/utils/errorCodes.js +19 -0
- package/out/utils/fixNames.d.ts +13 -0
- package/out/utils/fixNames.js +21 -0
- package/out/utils/modifiers.d.ts +1 -0
- package/out/utils/modifiers.js +12 -0
- package/out/utils/previewer.d.ts +13 -0
- package/out/utils/previewer.js +182 -0
- package/out/utils/snippetForFunctionCall.d.ts +8 -0
- package/out/utils/snippetForFunctionCall.js +112 -0
- package/out/utils/transforms.d.ts +10 -0
- package/out/utils/transforms.js +76 -0
- package/out/utils/typeConverters.d.ts +4 -0
- package/out/utils/typeConverters.js +67 -0
- package/package.json +32 -0
- package/rules.d.ts +13 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getLineText = exports.register = void 0;
|
|
27
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
28
|
+
const getFormatCodeSettings_1 = require("../../configs/getFormatCodeSettings");
|
|
29
|
+
const getUserPreferences_1 = require("../../configs/getUserPreferences");
|
|
30
|
+
const shared_1 = require("../../shared");
|
|
31
|
+
const previewer = __importStar(require("../../utils/previewer"));
|
|
32
|
+
const snippetForFunctionCall_1 = require("../../utils/snippetForFunctionCall");
|
|
33
|
+
const transforms_1 = require("../../utils/transforms");
|
|
34
|
+
const basic_1 = require("./basic");
|
|
35
|
+
function register(ctx) {
|
|
36
|
+
const { ts } = ctx;
|
|
37
|
+
return async (item, newPosition) => {
|
|
38
|
+
const data = item.data;
|
|
39
|
+
if (!data)
|
|
40
|
+
return item;
|
|
41
|
+
const fileName = data.fileName;
|
|
42
|
+
let offset = data.offset;
|
|
43
|
+
const document = ctx.getTextDocument(data.uri);
|
|
44
|
+
if (newPosition && document) {
|
|
45
|
+
offset = document.offsetAt(newPosition);
|
|
46
|
+
}
|
|
47
|
+
const [formatOptions, preferences] = document ? await Promise.all([
|
|
48
|
+
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
|
|
49
|
+
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
50
|
+
]) : [{}, {}];
|
|
51
|
+
let details;
|
|
52
|
+
try {
|
|
53
|
+
details = ctx.typescript.languageService.getCompletionEntryDetails(fileName, offset, data.originalItem.name, formatOptions, data.originalItem.source, preferences, data.originalItem.data);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
item.detail = `[TS Error]\n${err}\n${JSON.stringify(err, undefined, 2)}`;
|
|
57
|
+
}
|
|
58
|
+
if (!details)
|
|
59
|
+
return item;
|
|
60
|
+
if (data.originalItem.labelDetails) {
|
|
61
|
+
item.labelDetails ??= {};
|
|
62
|
+
Object.assign(item.labelDetails, data.originalItem.labelDetails);
|
|
63
|
+
}
|
|
64
|
+
const { sourceDisplay } = details;
|
|
65
|
+
if (sourceDisplay) {
|
|
66
|
+
item.labelDetails ??= {};
|
|
67
|
+
item.labelDetails.description = ts.displayPartsToString(sourceDisplay);
|
|
68
|
+
}
|
|
69
|
+
const detailTexts = [];
|
|
70
|
+
if (details.codeActions) {
|
|
71
|
+
if (!item.additionalTextEdits)
|
|
72
|
+
item.additionalTextEdits = [];
|
|
73
|
+
for (const action of details.codeActions) {
|
|
74
|
+
detailTexts.push(action.description);
|
|
75
|
+
for (const changes of action.changes) {
|
|
76
|
+
const entries = changes.textChanges.map(textChange => {
|
|
77
|
+
return { fileName, textSpan: textChange.span };
|
|
78
|
+
});
|
|
79
|
+
const locs = (0, transforms_1.entriesToLocations)(entries, ctx);
|
|
80
|
+
locs.forEach((loc, index) => {
|
|
81
|
+
item.additionalTextEdits?.push(vscode.TextEdit.replace(loc.range, changes.textChanges[index].newText));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (details.displayParts) {
|
|
87
|
+
detailTexts.push(previewer.plainWithLinks(details.displayParts, { toResource }, ctx));
|
|
88
|
+
}
|
|
89
|
+
if (detailTexts.length) {
|
|
90
|
+
item.detail = detailTexts.join('\n');
|
|
91
|
+
}
|
|
92
|
+
item.documentation = {
|
|
93
|
+
kind: 'markdown',
|
|
94
|
+
value: previewer.markdownDocumentation(details.documentation, details.tags, { toResource }, ctx),
|
|
95
|
+
};
|
|
96
|
+
if (details) {
|
|
97
|
+
(0, basic_1.handleKindModifiers)(item, details);
|
|
98
|
+
}
|
|
99
|
+
if (document) {
|
|
100
|
+
const useCodeSnippetsOnMethodSuggest = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.suggest.completeFunctionCalls') ?? false;
|
|
101
|
+
const useCodeSnippet = useCodeSnippetsOnMethodSuggest && (item.kind === vscode.CompletionItemKind.Function || item.kind === vscode.CompletionItemKind.Method);
|
|
102
|
+
if (useCodeSnippet) {
|
|
103
|
+
const shouldCompleteFunction = isValidFunctionCompletionContext(ctx.typescript.languageService, fileName, offset, document);
|
|
104
|
+
if (shouldCompleteFunction) {
|
|
105
|
+
const { snippet, parameterCount } = (0, snippetForFunctionCall_1.snippetForFunctionCall)({
|
|
106
|
+
insertText: item.insertText ?? item.textEdit?.newText,
|
|
107
|
+
label: item.label,
|
|
108
|
+
}, details.displayParts);
|
|
109
|
+
if (item.textEdit) {
|
|
110
|
+
item.textEdit.newText = snippet;
|
|
111
|
+
}
|
|
112
|
+
if (item.insertText) {
|
|
113
|
+
item.insertText = snippet;
|
|
114
|
+
}
|
|
115
|
+
item.insertTextFormat = vscode.InsertTextFormat.Snippet;
|
|
116
|
+
if (parameterCount > 0) {
|
|
117
|
+
//Fix for https://github.com/microsoft/vscode/issues/104059
|
|
118
|
+
//Don't show parameter hints if "editor.parameterHints.enabled": false
|
|
119
|
+
// if (await getConfiguration('editor.parameterHints.enabled', document.uri)) {
|
|
120
|
+
// item.command = {
|
|
121
|
+
// title: 'triggerParameterHints',
|
|
122
|
+
// command: 'editor.action.triggerParameterHints',
|
|
123
|
+
// };
|
|
124
|
+
// }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return item;
|
|
130
|
+
function toResource(path) {
|
|
131
|
+
return ctx.env.fileNameToUri(path);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
exports.register = register;
|
|
136
|
+
function isValidFunctionCompletionContext(client, filepath, offset, document) {
|
|
137
|
+
// Workaround for https://github.com/microsoft/TypeScript/issues/12677
|
|
138
|
+
// Don't complete function calls inside of destructive assignments or imports
|
|
139
|
+
try {
|
|
140
|
+
const response = client.getQuickInfoAtPosition(filepath, offset);
|
|
141
|
+
if (response) {
|
|
142
|
+
switch (response.kind) {
|
|
143
|
+
case 'var':
|
|
144
|
+
case 'let':
|
|
145
|
+
case 'const':
|
|
146
|
+
case 'alias':
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// Noop
|
|
153
|
+
}
|
|
154
|
+
// Don't complete function call if there is already something that looks like a function call
|
|
155
|
+
// https://github.com/microsoft/vscode/issues/18131
|
|
156
|
+
const position = document.positionAt(offset);
|
|
157
|
+
const after = getLineText(document, position.line).slice(position.character);
|
|
158
|
+
return after.match(/^[a-z_$0-9]*\s*\(/gi) === null;
|
|
159
|
+
}
|
|
160
|
+
function getLineText(document, line) {
|
|
161
|
+
const endOffset = document.offsetAt({ line: line + 1, character: 0 });
|
|
162
|
+
const end = document.positionAt(endOffset);
|
|
163
|
+
const text = document.getText({
|
|
164
|
+
start: { line: line, character: 0 },
|
|
165
|
+
end: end.line === line ? end : document.positionAt(endOffset - 1),
|
|
166
|
+
});
|
|
167
|
+
return text;
|
|
168
|
+
}
|
|
169
|
+
exports.getLineText = getLineText;
|
|
170
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const transforms_1 = require("../utils/transforms");
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
function register(ctx) {
|
|
7
|
+
return (uri, position) => {
|
|
8
|
+
const document = ctx.getTextDocument(uri);
|
|
9
|
+
if (!document)
|
|
10
|
+
return [];
|
|
11
|
+
const fileName = ctx.env.uriToFileName(document.uri);
|
|
12
|
+
const offset = document.offsetAt(position);
|
|
13
|
+
const info = (0, shared_1.safeCall)(() => ctx.typescript.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
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
+
import { 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;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getEmitDeclarations = exports.register = void 0;
|
|
27
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
28
|
+
const shared_1 = require("../shared");
|
|
29
|
+
function register(ctx) {
|
|
30
|
+
const { ts } = ctx;
|
|
31
|
+
return (uri, options) => {
|
|
32
|
+
const document = ctx.getTextDocument(uri);
|
|
33
|
+
if (!document)
|
|
34
|
+
return [];
|
|
35
|
+
const fileName = ctx.env.uriToFileName(document.uri);
|
|
36
|
+
const program = ctx.typescript.languageService.getProgram();
|
|
37
|
+
const sourceFile = program?.getSourceFile(fileName);
|
|
38
|
+
if (!program || !sourceFile)
|
|
39
|
+
return [];
|
|
40
|
+
const token = {
|
|
41
|
+
isCancellationRequested() {
|
|
42
|
+
return ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;
|
|
43
|
+
},
|
|
44
|
+
throwIfCancellationRequested() { },
|
|
45
|
+
};
|
|
46
|
+
let errors = (0, shared_1.safeCall)(() => [
|
|
47
|
+
...options.semantic ? program.getSemanticDiagnostics(sourceFile, token) : [],
|
|
48
|
+
...options.syntactic ? program.getSyntacticDiagnostics(sourceFile, token) : [],
|
|
49
|
+
...options.suggestion ? ctx.typescript.languageService.getSuggestionDiagnostics(fileName) : [],
|
|
50
|
+
]) ?? [];
|
|
51
|
+
if (options.declaration && getEmitDeclarations(program.getCompilerOptions())) {
|
|
52
|
+
errors = errors.concat(program.getDeclarationDiagnostics(sourceFile, token));
|
|
53
|
+
}
|
|
54
|
+
return translateDiagnostics(document, errors);
|
|
55
|
+
function translateDiagnostics(document, input) {
|
|
56
|
+
return input.map(diag => translateDiagnostic(diag, document)).filter((v) => !!v);
|
|
57
|
+
}
|
|
58
|
+
function translateDiagnostic(diag, document) {
|
|
59
|
+
if (diag.start === undefined)
|
|
60
|
+
return;
|
|
61
|
+
if (diag.length === undefined)
|
|
62
|
+
return;
|
|
63
|
+
const diagnostic = {
|
|
64
|
+
range: {
|
|
65
|
+
start: document.positionAt(diag.start),
|
|
66
|
+
end: document.positionAt(diag.start + diag.length),
|
|
67
|
+
},
|
|
68
|
+
severity: translateErrorType(diag.category),
|
|
69
|
+
source: 'ts',
|
|
70
|
+
code: diag.code,
|
|
71
|
+
message: getMessageText(diag),
|
|
72
|
+
};
|
|
73
|
+
if (diag.relatedInformation) {
|
|
74
|
+
diagnostic.relatedInformation = diag.relatedInformation
|
|
75
|
+
.map(rErr => translateDiagnosticRelated(rErr))
|
|
76
|
+
.filter((v) => !!v);
|
|
77
|
+
}
|
|
78
|
+
if (diag.reportsUnnecessary) {
|
|
79
|
+
if (diagnostic.tags === undefined)
|
|
80
|
+
diagnostic.tags = [];
|
|
81
|
+
diagnostic.tags.push(vscode.DiagnosticTag.Unnecessary);
|
|
82
|
+
}
|
|
83
|
+
if (diag.reportsDeprecated) {
|
|
84
|
+
if (diagnostic.tags === undefined)
|
|
85
|
+
diagnostic.tags = [];
|
|
86
|
+
diagnostic.tags.push(vscode.DiagnosticTag.Deprecated);
|
|
87
|
+
}
|
|
88
|
+
return diagnostic;
|
|
89
|
+
}
|
|
90
|
+
function translateDiagnosticRelated(diag) {
|
|
91
|
+
if (diag.start === undefined)
|
|
92
|
+
return;
|
|
93
|
+
if (diag.length === undefined)
|
|
94
|
+
return;
|
|
95
|
+
let document;
|
|
96
|
+
if (diag.file) {
|
|
97
|
+
document = ctx.getTextDocument(ctx.env.fileNameToUri(diag.file.fileName));
|
|
98
|
+
}
|
|
99
|
+
if (!document)
|
|
100
|
+
return;
|
|
101
|
+
const diagnostic = {
|
|
102
|
+
location: {
|
|
103
|
+
uri: document.uri,
|
|
104
|
+
range: {
|
|
105
|
+
start: document.positionAt(diag.start),
|
|
106
|
+
end: document.positionAt(diag.start + diag.length),
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
message: getMessageText(diag),
|
|
110
|
+
};
|
|
111
|
+
return diagnostic;
|
|
112
|
+
}
|
|
113
|
+
function translateErrorType(input) {
|
|
114
|
+
switch (input) {
|
|
115
|
+
case ts.DiagnosticCategory.Warning: return vscode.DiagnosticSeverity.Warning;
|
|
116
|
+
case ts.DiagnosticCategory.Error: return vscode.DiagnosticSeverity.Error;
|
|
117
|
+
case ts.DiagnosticCategory.Suggestion: return vscode.DiagnosticSeverity.Hint;
|
|
118
|
+
case ts.DiagnosticCategory.Message: return vscode.DiagnosticSeverity.Information;
|
|
119
|
+
}
|
|
120
|
+
return vscode.DiagnosticSeverity.Error;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
exports.register = register;
|
|
125
|
+
function getMessageText(diag, level = 0) {
|
|
126
|
+
let messageText = ' '.repeat(level);
|
|
127
|
+
if (typeof diag.messageText === 'string') {
|
|
128
|
+
messageText += diag.messageText;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
messageText += diag.messageText.messageText;
|
|
132
|
+
if (diag.messageText.next) {
|
|
133
|
+
for (const info of diag.messageText.next) {
|
|
134
|
+
messageText += '\n' + getMessageText(info, level + 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return messageText;
|
|
139
|
+
}
|
|
140
|
+
function getEmitDeclarations(compilerOptions) {
|
|
141
|
+
return !!(compilerOptions.declaration || compilerOptions.composite);
|
|
142
|
+
}
|
|
143
|
+
exports.getEmitDeclarations = getEmitDeclarations;
|
|
144
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.register = void 0;
|
|
27
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
28
|
+
const shared_1 = require("../shared");
|
|
29
|
+
function register(ctx) {
|
|
30
|
+
const { ts } = ctx;
|
|
31
|
+
return (uri, position) => {
|
|
32
|
+
const document = ctx.getTextDocument(uri);
|
|
33
|
+
if (!document)
|
|
34
|
+
return [];
|
|
35
|
+
const fileName = ctx.env.uriToFileName(document.uri);
|
|
36
|
+
const offset = document.offsetAt(position);
|
|
37
|
+
const highlights = (0, shared_1.safeCall)(() => ctx.typescript.languageService.getDocumentHighlights(fileName, offset, [fileName]));
|
|
38
|
+
if (!highlights)
|
|
39
|
+
return [];
|
|
40
|
+
const results = [];
|
|
41
|
+
for (const highlight of highlights) {
|
|
42
|
+
for (const span of highlight.highlightSpans) {
|
|
43
|
+
results.push({
|
|
44
|
+
kind: span.kind === ts.HighlightSpanKind.writtenReference ? vscode.DocumentHighlightKind.Write : vscode.DocumentHighlightKind.Read,
|
|
45
|
+
range: {
|
|
46
|
+
start: document.positionAt(span.textSpan.start),
|
|
47
|
+
end: document.positionAt(span.textSpan.start + span.textSpan.length),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.register = register;
|
|
56
|
+
//# sourceMappingURL=documentHighlight.js.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.register = void 0;
|
|
27
|
+
const PConst = __importStar(require("../protocol.const"));
|
|
28
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
29
|
+
const modifiers_1 = require("../utils/modifiers");
|
|
30
|
+
const shared_1 = require("../shared");
|
|
31
|
+
const getSymbolKind = (kind) => {
|
|
32
|
+
switch (kind) {
|
|
33
|
+
case PConst.Kind.module: return vscode.SymbolKind.Module;
|
|
34
|
+
case PConst.Kind.class: return vscode.SymbolKind.Class;
|
|
35
|
+
case PConst.Kind.enum: return vscode.SymbolKind.Enum;
|
|
36
|
+
case PConst.Kind.interface: return vscode.SymbolKind.Interface;
|
|
37
|
+
case PConst.Kind.method: return vscode.SymbolKind.Method;
|
|
38
|
+
case PConst.Kind.memberVariable: return vscode.SymbolKind.Property;
|
|
39
|
+
case PConst.Kind.memberGetAccessor: return vscode.SymbolKind.Property;
|
|
40
|
+
case PConst.Kind.memberSetAccessor: return vscode.SymbolKind.Property;
|
|
41
|
+
case PConst.Kind.variable: return vscode.SymbolKind.Variable;
|
|
42
|
+
case PConst.Kind.const: return vscode.SymbolKind.Variable;
|
|
43
|
+
case PConst.Kind.localVariable: return vscode.SymbolKind.Variable;
|
|
44
|
+
case PConst.Kind.function: return vscode.SymbolKind.Function;
|
|
45
|
+
case PConst.Kind.localFunction: return vscode.SymbolKind.Function;
|
|
46
|
+
case PConst.Kind.constructSignature: return vscode.SymbolKind.Constructor;
|
|
47
|
+
case PConst.Kind.constructorImplementation: return vscode.SymbolKind.Constructor;
|
|
48
|
+
}
|
|
49
|
+
return vscode.SymbolKind.Variable;
|
|
50
|
+
};
|
|
51
|
+
function register(ctx) {
|
|
52
|
+
return (uri) => {
|
|
53
|
+
const document = ctx.getTextDocument(uri);
|
|
54
|
+
if (!document)
|
|
55
|
+
return [];
|
|
56
|
+
const fileName = ctx.env.uriToFileName(document.uri);
|
|
57
|
+
const barItems = (0, shared_1.safeCall)(() => ctx.typescript.languageService.getNavigationTree(fileName));
|
|
58
|
+
if (!barItems)
|
|
59
|
+
return [];
|
|
60
|
+
// The root represents the file. Ignore this when showing in the UI
|
|
61
|
+
const result = barItems.childItems
|
|
62
|
+
?.map(function convertNavTree(item) {
|
|
63
|
+
if (!shouldIncludeEntry(item)) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
let remain = item.childItems ?? [];
|
|
67
|
+
return item.spans.map(span => {
|
|
68
|
+
const childItems = [];
|
|
69
|
+
remain = remain.filter(child => {
|
|
70
|
+
const childStart = child.spans[0].start;
|
|
71
|
+
const childEnd = child.spans[child.spans.length - 1].start + child.spans[child.spans.length - 1].length;
|
|
72
|
+
if (childStart >= span.start && childEnd <= span.start + span.length) {
|
|
73
|
+
childItems.push(child);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
});
|
|
78
|
+
const nameSpan = item.spans.length === 1
|
|
79
|
+
? (item.nameSpan ?? span)
|
|
80
|
+
: span;
|
|
81
|
+
const fullRange = {
|
|
82
|
+
start: Math.min(span.start, nameSpan.start),
|
|
83
|
+
end: Math.max(span.start + span.length, nameSpan.start + nameSpan.length),
|
|
84
|
+
};
|
|
85
|
+
const symbol = vscode.DocumentSymbol.create(item.text, undefined, getSymbolKind(item.kind), vscode.Range.create(document.positionAt(fullRange.start), document.positionAt(fullRange.end)), vscode.Range.create(document.positionAt(nameSpan.start), document.positionAt(nameSpan.start + nameSpan.length)), childItems.map(convertNavTree).flat());
|
|
86
|
+
const kindModifiers = (0, modifiers_1.parseKindModifier)(item.kindModifiers);
|
|
87
|
+
if (kindModifiers.has(PConst.KindModifiers.deprecated)) {
|
|
88
|
+
symbol.deprecated = true;
|
|
89
|
+
symbol.tags ??= [];
|
|
90
|
+
symbol.tags.push(vscode.SymbolTag.Deprecated);
|
|
91
|
+
}
|
|
92
|
+
return symbol;
|
|
93
|
+
});
|
|
94
|
+
})
|
|
95
|
+
.flat();
|
|
96
|
+
return result ?? [];
|
|
97
|
+
function shouldIncludeEntry(item) {
|
|
98
|
+
if (item.kind === PConst.Kind.alias) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return !!(item.text && item.text !== '<function>' && item.text !== '<class>');
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
exports.register = register;
|
|
106
|
+
//# sourceMappingURL=documentSymbol.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const transforms_1 = require("../utils/transforms");
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
function register(ctx) {
|
|
7
|
+
return (uri) => {
|
|
8
|
+
const document = ctx.getTextDocument(uri);
|
|
9
|
+
if (!document)
|
|
10
|
+
return [];
|
|
11
|
+
const fileName = ctx.env.uriToFileName(document.uri);
|
|
12
|
+
const entries = (0, shared_1.safeCall)(() => ctx.typescript.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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const rename_1 = require("./rename");
|
|
5
|
+
const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
|
|
6
|
+
const getUserPreferences_1 = require("../configs/getUserPreferences");
|
|
7
|
+
const shared_1 = require("../shared");
|
|
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.env.uriToFileName(oldUri);
|
|
16
|
+
const newFilePath = ctx.env.uriToFileName(newUri);
|
|
17
|
+
const response = (0, shared_1.safeCall)(() => ctx.typescript.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
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.register = void 0;
|
|
27
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
28
|
+
const shared_1 = require("../shared");
|
|
29
|
+
function register(ctx) {
|
|
30
|
+
const { ts } = ctx;
|
|
31
|
+
return (uri) => {
|
|
32
|
+
const document = ctx.getTextDocument(uri);
|
|
33
|
+
if (!document)
|
|
34
|
+
return [];
|
|
35
|
+
const fileName = ctx.env.uriToFileName(document.uri);
|
|
36
|
+
const outliningSpans = (0, shared_1.safeCall)(() => ctx.typescript.languageService.getOutliningSpans(fileName));
|
|
37
|
+
if (!outliningSpans)
|
|
38
|
+
return [];
|
|
39
|
+
const foldingRanges = [];
|
|
40
|
+
for (const outliningSpan of outliningSpans) {
|
|
41
|
+
const start = document.positionAt(outliningSpan.textSpan.start);
|
|
42
|
+
const end = adjustFoldingEnd(start, document.positionAt(outliningSpan.textSpan.start + outliningSpan.textSpan.length), document);
|
|
43
|
+
const foldingRange = vscode.FoldingRange.create(start.line, end.line, start.character, end.character, transformFoldingRangeKind(outliningSpan.kind));
|
|
44
|
+
foldingRanges.push(foldingRange);
|
|
45
|
+
}
|
|
46
|
+
return foldingRanges;
|
|
47
|
+
};
|
|
48
|
+
function transformFoldingRangeKind(tsKind) {
|
|
49
|
+
switch (tsKind) {
|
|
50
|
+
case ts.OutliningSpanKind.Comment: return vscode.FoldingRangeKind.Comment;
|
|
51
|
+
case ts.OutliningSpanKind.Imports: return vscode.FoldingRangeKind.Imports;
|
|
52
|
+
case ts.OutliningSpanKind.Region: return vscode.FoldingRangeKind.Region;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.register = register;
|
|
57
|
+
const foldEndPairCharacters = ['}', ']', ')', '`'];
|
|
58
|
+
// https://github.com/microsoft/vscode/blob/bed61166fb604e519e82e4d1d1ed839bc45d65f8/extensions/typescript-language-features/src/languageFeatures/folding.ts#L61-L73
|
|
59
|
+
function adjustFoldingEnd(start, end, document) {
|
|
60
|
+
// workaround for #47240
|
|
61
|
+
if (end.character > 0) {
|
|
62
|
+
const foldEndCharacter = document.getText({
|
|
63
|
+
start: { line: end.line, character: end.character - 1 },
|
|
64
|
+
end,
|
|
65
|
+
});
|
|
66
|
+
if (foldEndPairCharacters.includes(foldEndCharacter)) {
|
|
67
|
+
const endOffset = Math.max(document.offsetAt({ line: end.line, character: 0 }) - 1, document.offsetAt(start));
|
|
68
|
+
return document.positionAt(endOffset);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return end;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=foldingRanges.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import { SharedContext } from '../types';
|
|
3
|
+
export declare function register(ctx: SharedContext): {
|
|
4
|
+
onRange: (uri: string, range: vscode.Range | undefined, options: vscode.FormattingOptions) => Promise<vscode.TextEdit[]>;
|
|
5
|
+
onType: (uri: string, options: vscode.FormattingOptions, position: vscode.Position, key: string) => Promise<vscode.TextEdit[]>;
|
|
6
|
+
};
|