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
|
@@ -1,55 +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 shared_1 = require("../shared");
|
|
6
|
-
function register(ctx) {
|
|
7
|
-
return {
|
|
8
|
-
onRange: async (document, range, options, codeOptions) => {
|
|
9
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
10
|
-
const tsOptions = await (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, options);
|
|
11
|
-
if (codeOptions) {
|
|
12
|
-
tsOptions.baseIndentSize = codeOptions.initialIndentLevel * options.tabSize;
|
|
13
|
-
}
|
|
14
|
-
const scriptEdits = range
|
|
15
|
-
? (0, shared_1.safeCall)(() => ctx.languageService.getFormattingEditsForRange(fileName, document.offsetAt(range.start), document.offsetAt(range.end), tsOptions))
|
|
16
|
-
: (0, shared_1.safeCall)(() => ctx.languageService.getFormattingEditsForDocument(fileName, tsOptions));
|
|
17
|
-
if (!scriptEdits)
|
|
18
|
-
return [];
|
|
19
|
-
const result = [];
|
|
20
|
-
for (const textEdit of scriptEdits) {
|
|
21
|
-
result.push({
|
|
22
|
-
range: {
|
|
23
|
-
start: document.positionAt(textEdit.span.start),
|
|
24
|
-
end: document.positionAt(textEdit.span.start + textEdit.span.length),
|
|
25
|
-
},
|
|
26
|
-
newText: textEdit.newText,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
},
|
|
31
|
-
onType: async (document, options, codeOptions, position, key) => {
|
|
32
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
33
|
-
const tsOptions = await (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, options);
|
|
34
|
-
if (codeOptions) {
|
|
35
|
-
tsOptions.baseIndentSize = codeOptions.initialIndentLevel * options.tabSize;
|
|
36
|
-
}
|
|
37
|
-
const scriptEdits = (0, shared_1.safeCall)(() => ctx.languageService.getFormattingEditsAfterKeystroke(fileName, document.offsetAt(position), key, tsOptions));
|
|
38
|
-
if (!scriptEdits)
|
|
39
|
-
return [];
|
|
40
|
-
const result = [];
|
|
41
|
-
for (const textEdit of scriptEdits) {
|
|
42
|
-
result.push({
|
|
43
|
-
range: {
|
|
44
|
-
start: document.positionAt(textEdit.span.start),
|
|
45
|
-
end: document.positionAt(textEdit.span.start + textEdit.span.length),
|
|
46
|
-
},
|
|
47
|
-
newText: textEdit.newText,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
exports.register = register;
|
|
55
|
-
//# sourceMappingURL=formatting.js.map
|
package/lib/features/hover.d.ts
DELETED
|
@@ -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, documentOnly?: boolean) => vscode.Hover | undefined;
|
|
4
|
-
//# sourceMappingURL=hover.d.ts.map
|
package/lib/features/hover.js
DELETED
|
@@ -1,43 +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 previewer = require("../utils/previewer");
|
|
6
|
-
function register(ctx) {
|
|
7
|
-
const { ts } = ctx;
|
|
8
|
-
return (uri, position, documentOnly = false) => {
|
|
9
|
-
const document = ctx.getTextDocument(uri);
|
|
10
|
-
if (!document)
|
|
11
|
-
return;
|
|
12
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
13
|
-
const offset = document.offsetAt(position);
|
|
14
|
-
const info = (0, shared_1.safeCall)(() => ctx.languageService.getQuickInfoAtPosition(fileName, offset));
|
|
15
|
-
if (!info)
|
|
16
|
-
return;
|
|
17
|
-
const parts = [];
|
|
18
|
-
const displayString = ts.displayPartsToString(info.displayParts);
|
|
19
|
-
const documentation = previewer.markdownDocumentation(info.documentation ?? [], info.tags, { toResource }, ctx);
|
|
20
|
-
if (displayString && !documentOnly) {
|
|
21
|
-
parts.push(['```typescript', displayString, '```'].join('\n'));
|
|
22
|
-
}
|
|
23
|
-
if (documentation) {
|
|
24
|
-
parts.push(documentation);
|
|
25
|
-
}
|
|
26
|
-
const markdown = {
|
|
27
|
-
kind: 'markdown',
|
|
28
|
-
value: parts.join('\n\n'),
|
|
29
|
-
};
|
|
30
|
-
return {
|
|
31
|
-
contents: markdown,
|
|
32
|
-
range: {
|
|
33
|
-
start: document.positionAt(info.textSpan.start),
|
|
34
|
-
end: document.positionAt(info.textSpan.start + info.textSpan.length),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
function toResource(path) {
|
|
38
|
-
return ctx.fileNameToUri(path);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.register = register;
|
|
43
|
-
//# sourceMappingURL=hover.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): (uri: string, position: vscode.Position) => vscode.LocationLink[];
|
|
4
|
-
//# sourceMappingURL=implementation.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 entries = (0, shared_1.safeCall)(() => ctx.languageService.getImplementationAtPosition(fileName, offset));
|
|
14
|
-
if (!entries)
|
|
15
|
-
return [];
|
|
16
|
-
return (0, transforms_1.entriesToLocationLinks)([...entries], ctx);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.register = register;
|
|
20
|
-
//# sourceMappingURL=implementation.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, range: vscode.Range) => Promise<vscode.InlayHint[] | undefined>;
|
|
4
|
-
//# sourceMappingURL=inlayHints.d.ts.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
4
|
-
const getUserPreferences_1 = require("../configs/getUserPreferences");
|
|
5
|
-
const shared_1 = require("../shared");
|
|
6
|
-
function register(ctx) {
|
|
7
|
-
const { ts } = ctx;
|
|
8
|
-
return async (uri, range) => {
|
|
9
|
-
const document = ctx.getTextDocument(uri);
|
|
10
|
-
if (!document)
|
|
11
|
-
return;
|
|
12
|
-
const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
13
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
14
|
-
const start = document.offsetAt(range.start);
|
|
15
|
-
const end = document.offsetAt(range.end);
|
|
16
|
-
const inlayHints = (0, shared_1.safeCall)(() => 'provideInlayHints' in ctx.languageService
|
|
17
|
-
? ctx.languageService.provideInlayHints(fileName, { start, length: end - start }, preferences)
|
|
18
|
-
: []) ?? [];
|
|
19
|
-
return inlayHints.map(inlayHint => {
|
|
20
|
-
const result = {
|
|
21
|
-
position: document.positionAt(inlayHint.position),
|
|
22
|
-
label: inlayHint.text,
|
|
23
|
-
kind: inlayHint.kind === ts.InlayHintKind.Type ? 1
|
|
24
|
-
: inlayHint.kind === ts.InlayHintKind.Parameter ? 2
|
|
25
|
-
: undefined,
|
|
26
|
-
};
|
|
27
|
-
result.paddingLeft = inlayHint.whitespaceBefore;
|
|
28
|
-
result.paddingRight = inlayHint.whitespaceAfter;
|
|
29
|
-
return result;
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.register = register;
|
|
34
|
-
//# sourceMappingURL=inlayHints.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type * as vscode from '@volar/language-service';
|
|
2
|
-
import type { SharedContext } from '../types';
|
|
3
|
-
export declare const renameInfoOptions: {
|
|
4
|
-
allowRenameOfImportPath: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare function register(ctx: SharedContext): (uri: string, position: vscode.Position) => vscode.Range | {
|
|
7
|
-
message: string;
|
|
8
|
-
} | undefined;
|
|
9
|
-
//# sourceMappingURL=prepareRename.d.ts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = exports.renameInfoOptions = void 0;
|
|
4
|
-
const shared_1 = require("../shared");
|
|
5
|
-
/* typescript-language-features is hardcode true */
|
|
6
|
-
exports.renameInfoOptions = { allowRenameOfImportPath: true };
|
|
7
|
-
function register(ctx) {
|
|
8
|
-
return (uri, position) => {
|
|
9
|
-
const document = ctx.getTextDocument(uri);
|
|
10
|
-
if (!document)
|
|
11
|
-
return;
|
|
12
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
13
|
-
const offset = document.offsetAt(position);
|
|
14
|
-
const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, exports.renameInfoOptions));
|
|
15
|
-
if (!renameInfo)
|
|
16
|
-
return;
|
|
17
|
-
if (!renameInfo.canRename) {
|
|
18
|
-
return { message: renameInfo.localizedErrorMessage };
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
start: document.positionAt(renameInfo.triggerSpan.start),
|
|
22
|
-
end: document.positionAt(renameInfo.triggerSpan.start + renameInfo.triggerSpan.length),
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.register = register;
|
|
27
|
-
//# sourceMappingURL=prepareRename.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, referenceContext: vscode.ReferenceContext) => vscode.Location[];
|
|
4
|
-
//# sourceMappingURL=references.d.ts.map
|
|
@@ -1,35 +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, referenceContext) => {
|
|
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 references = (0, shared_1.safeCall)(() => ctx.languageService.findReferences(fileName, offset));
|
|
14
|
-
if (!references)
|
|
15
|
-
return [];
|
|
16
|
-
const result = [];
|
|
17
|
-
for (const reference of references) {
|
|
18
|
-
if (referenceContext.includeDeclaration) {
|
|
19
|
-
const definition = (0, transforms_1.entryToLocation)(reference.definition, ctx);
|
|
20
|
-
if (definition) {
|
|
21
|
-
result.push(definition);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
for (const referenceEntry of reference.references) {
|
|
25
|
-
const reference = (0, transforms_1.entryToLocation)(referenceEntry, ctx);
|
|
26
|
-
if (reference) {
|
|
27
|
-
result.push(reference);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.register = register;
|
|
35
|
-
//# sourceMappingURL=references.js.map
|
package/lib/features/rename.d.ts
DELETED
|
@@ -1,6 +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, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
5
|
-
export declare function fileTextChangesToWorkspaceEdit(changes: readonly ts.FileTextChanges[], ctx: SharedContext): vscode.WorkspaceEdit;
|
|
6
|
-
//# sourceMappingURL=rename.d.ts.map
|
package/lib/features/rename.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileTextChangesToWorkspaceEdit = exports.register = void 0;
|
|
4
|
-
const path = require("path-browserify");
|
|
5
|
-
const getFormatCodeSettings_1 = require("../configs/getFormatCodeSettings");
|
|
6
|
-
const getUserPreferences_1 = require("../configs/getUserPreferences");
|
|
7
|
-
const shared_1 = require("../shared");
|
|
8
|
-
const prepareRename_1 = require("./prepareRename");
|
|
9
|
-
function register(ctx) {
|
|
10
|
-
return async (uri, position, newName) => {
|
|
11
|
-
const document = ctx.getTextDocument(uri);
|
|
12
|
-
if (!document)
|
|
13
|
-
return;
|
|
14
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
15
|
-
const offset = document.offsetAt(position);
|
|
16
|
-
const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, prepareRename_1.renameInfoOptions));
|
|
17
|
-
if (!renameInfo?.canRename)
|
|
18
|
-
return;
|
|
19
|
-
if (renameInfo.fileToRename) {
|
|
20
|
-
const [formatOptions, preferences] = await Promise.all([
|
|
21
|
-
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
|
|
22
|
-
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
23
|
-
]);
|
|
24
|
-
return renameFile(renameInfo.fileToRename, newName, formatOptions, preferences);
|
|
25
|
-
}
|
|
26
|
-
const { providePrefixAndSuffixTextForRename } = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
27
|
-
const entries = ctx.languageService.findRenameLocations(fileName, offset, false, false, providePrefixAndSuffixTextForRename);
|
|
28
|
-
if (!entries)
|
|
29
|
-
return;
|
|
30
|
-
const locations = locationsToWorkspaceEdit(newName, entries, ctx);
|
|
31
|
-
return locations;
|
|
32
|
-
};
|
|
33
|
-
function renameFile(fileToRename, newName, formatOptions, preferences) {
|
|
34
|
-
// Make sure we preserve file extension if none provided
|
|
35
|
-
if (!path.extname(newName)) {
|
|
36
|
-
newName += path.extname(fileToRename);
|
|
37
|
-
}
|
|
38
|
-
const dirname = path.dirname(fileToRename);
|
|
39
|
-
const newFilePath = path.join(dirname, newName);
|
|
40
|
-
const response = ctx.languageService.getEditsForFileRename(fileToRename, newFilePath, formatOptions, preferences);
|
|
41
|
-
const edits = fileTextChangesToWorkspaceEdit(response, ctx);
|
|
42
|
-
if (!edits.documentChanges) {
|
|
43
|
-
edits.documentChanges = [];
|
|
44
|
-
}
|
|
45
|
-
edits.documentChanges.push({
|
|
46
|
-
kind: 'rename',
|
|
47
|
-
oldUri: ctx.fileNameToUri(fileToRename),
|
|
48
|
-
newUri: ctx.fileNameToUri(newFilePath),
|
|
49
|
-
});
|
|
50
|
-
return edits;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.register = register;
|
|
54
|
-
function fileTextChangesToWorkspaceEdit(changes, ctx) {
|
|
55
|
-
const workspaceEdit = {};
|
|
56
|
-
for (const change of changes) {
|
|
57
|
-
if (!workspaceEdit.documentChanges) {
|
|
58
|
-
workspaceEdit.documentChanges = [];
|
|
59
|
-
}
|
|
60
|
-
const uri = ctx.fileNameToUri(change.fileName);
|
|
61
|
-
let doc = ctx.getTextDocument(uri);
|
|
62
|
-
if (change.isNewFile) {
|
|
63
|
-
workspaceEdit.documentChanges.push({ kind: 'create', uri });
|
|
64
|
-
}
|
|
65
|
-
if (!doc && !change.isNewFile)
|
|
66
|
-
continue;
|
|
67
|
-
const docEdit = {
|
|
68
|
-
textDocument: {
|
|
69
|
-
uri,
|
|
70
|
-
version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
|
|
71
|
-
},
|
|
72
|
-
edits: [],
|
|
73
|
-
};
|
|
74
|
-
for (const textChange of change.textChanges) {
|
|
75
|
-
docEdit.edits.push({
|
|
76
|
-
newText: textChange.newText,
|
|
77
|
-
range: {
|
|
78
|
-
start: doc?.positionAt(textChange.span.start) ?? { line: 0, character: 0 },
|
|
79
|
-
end: doc?.positionAt(textChange.span.start + textChange.span.length) ?? { line: 0, character: 0 },
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
workspaceEdit.documentChanges.push(docEdit);
|
|
84
|
-
}
|
|
85
|
-
return workspaceEdit;
|
|
86
|
-
}
|
|
87
|
-
exports.fileTextChangesToWorkspaceEdit = fileTextChangesToWorkspaceEdit;
|
|
88
|
-
function locationsToWorkspaceEdit(newText, locations, ctx) {
|
|
89
|
-
const workspaceEdit = {};
|
|
90
|
-
for (const location of locations) {
|
|
91
|
-
if (!workspaceEdit.changes) {
|
|
92
|
-
workspaceEdit.changes = {};
|
|
93
|
-
}
|
|
94
|
-
const uri = ctx.fileNameToUri(location.fileName);
|
|
95
|
-
const doc = ctx.getTextDocument(uri);
|
|
96
|
-
if (!doc)
|
|
97
|
-
continue;
|
|
98
|
-
if (!workspaceEdit.changes[uri]) {
|
|
99
|
-
workspaceEdit.changes[uri] = [];
|
|
100
|
-
}
|
|
101
|
-
let _newText = newText;
|
|
102
|
-
if (location.prefixText)
|
|
103
|
-
_newText = location.prefixText + _newText;
|
|
104
|
-
if (location.suffixText)
|
|
105
|
-
_newText = _newText + location.suffixText;
|
|
106
|
-
workspaceEdit.changes[uri].push({
|
|
107
|
-
newText: _newText,
|
|
108
|
-
range: {
|
|
109
|
-
start: doc.positionAt(location.textSpan.start),
|
|
110
|
-
end: doc.positionAt(location.textSpan.start + location.textSpan.length),
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return workspaceEdit;
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=rename.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, positions: vscode.Position[]) => vscode.SelectionRange[];
|
|
4
|
-
//# sourceMappingURL=selectionRanges.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
|
-
return (uri, positions) => {
|
|
7
|
-
const document = ctx.getTextDocument(uri);
|
|
8
|
-
if (!document)
|
|
9
|
-
return [];
|
|
10
|
-
const result = [];
|
|
11
|
-
for (const position of positions) {
|
|
12
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
13
|
-
const offset = document.offsetAt(position);
|
|
14
|
-
const range = (0, shared_1.safeCall)(() => ctx.languageService.getSmartSelectionRange(fileName, offset));
|
|
15
|
-
if (!range)
|
|
16
|
-
continue;
|
|
17
|
-
result.push(transformSelectionRange(range, document));
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
exports.register = register;
|
|
23
|
-
function transformSelectionRange(range, document) {
|
|
24
|
-
return {
|
|
25
|
-
range: {
|
|
26
|
-
start: document.positionAt(range.textSpan.start),
|
|
27
|
-
end: document.positionAt(range.textSpan.start + range.textSpan.length),
|
|
28
|
-
},
|
|
29
|
-
parent: range.parent ? transformSelectionRange(range.parent, document) : undefined,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=selectionRanges.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, range: vscode.Range, legend: vscode.SemanticTokensLegend) => [number, number, number, number, number][] | undefined;
|
|
4
|
-
//# sourceMappingURL=semanticTokens.d.ts.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, context?: vscode.SignatureHelpContext) => vscode.SignatureHelp | undefined;
|
|
4
|
-
//# sourceMappingURL=signatureHelp.d.ts.map
|
|
@@ -1,63 +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, context) => {
|
|
8
|
-
const document = ctx.getTextDocument(uri);
|
|
9
|
-
if (!document)
|
|
10
|
-
return;
|
|
11
|
-
const options = {};
|
|
12
|
-
if (context?.triggerKind === 1) {
|
|
13
|
-
options.triggerReason = {
|
|
14
|
-
kind: 'invoked'
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
else if (context?.triggerKind === 2) {
|
|
18
|
-
options.triggerReason = {
|
|
19
|
-
kind: 'characterTyped',
|
|
20
|
-
triggerCharacter: context.triggerCharacter,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
else if (context?.triggerKind === 3) {
|
|
24
|
-
options.triggerReason = {
|
|
25
|
-
kind: 'retrigger',
|
|
26
|
-
triggerCharacter: context.triggerCharacter,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const fileName = ctx.uriToFileName(document.uri);
|
|
30
|
-
const offset = document.offsetAt(position);
|
|
31
|
-
const helpItems = (0, shared_1.safeCall)(() => ctx.languageService.getSignatureHelpItems(fileName, offset, options));
|
|
32
|
-
if (!helpItems)
|
|
33
|
-
return;
|
|
34
|
-
return {
|
|
35
|
-
activeSignature: helpItems.selectedItemIndex,
|
|
36
|
-
activeParameter: helpItems.argumentIndex,
|
|
37
|
-
signatures: helpItems.items.map(item => {
|
|
38
|
-
const signature = {
|
|
39
|
-
label: '',
|
|
40
|
-
documentation: undefined,
|
|
41
|
-
parameters: []
|
|
42
|
-
};
|
|
43
|
-
signature.label += ts.displayPartsToString(item.prefixDisplayParts);
|
|
44
|
-
item.parameters.forEach((p, i, a) => {
|
|
45
|
-
const label = ts.displayPartsToString(p.displayParts);
|
|
46
|
-
const parameter = {
|
|
47
|
-
label,
|
|
48
|
-
documentation: ts.displayPartsToString(p.documentation)
|
|
49
|
-
};
|
|
50
|
-
signature.label += label;
|
|
51
|
-
signature.parameters.push(parameter);
|
|
52
|
-
if (i < a.length - 1) {
|
|
53
|
-
signature.label += ts.displayPartsToString(item.separatorDisplayParts);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
signature.label += ts.displayPartsToString(item.suffixDisplayParts);
|
|
57
|
-
return signature;
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
exports.register = register;
|
|
63
|
-
//# sourceMappingURL=signatureHelp.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): (uri: string, position: vscode.Position) => vscode.LocationLink[];
|
|
4
|
-
//# sourceMappingURL=typeDefinition.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 entries = (0, shared_1.safeCall)(() => ctx.languageService.getTypeDefinitionAtPosition(fileName, offset));
|
|
14
|
-
if (!entries)
|
|
15
|
-
return [];
|
|
16
|
-
return (0, transforms_1.entriesToLocationLinks)([...entries], ctx);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.register = register;
|
|
20
|
-
//# sourceMappingURL=typeDefinition.js.map
|
|
@@ -1,63 +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
|
-
function getSymbolKind(item) {
|
|
8
|
-
switch (item.kind) {
|
|
9
|
-
case PConst.Kind.method: return 6;
|
|
10
|
-
case PConst.Kind.enum: return 10;
|
|
11
|
-
case PConst.Kind.enumMember: return 22;
|
|
12
|
-
case PConst.Kind.function: return 12;
|
|
13
|
-
case PConst.Kind.class: return 5;
|
|
14
|
-
case PConst.Kind.interface: return 11;
|
|
15
|
-
case PConst.Kind.type: return 5;
|
|
16
|
-
case PConst.Kind.memberVariable: return 8;
|
|
17
|
-
case PConst.Kind.memberGetAccessor: return 8;
|
|
18
|
-
case PConst.Kind.memberSetAccessor: return 8;
|
|
19
|
-
case PConst.Kind.variable: return 13;
|
|
20
|
-
default: return 13;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function register(ctx) {
|
|
24
|
-
return (query) => {
|
|
25
|
-
const items = (0, shared_1.safeCall)(() => ctx.languageService.getNavigateToItems(query));
|
|
26
|
-
if (!items)
|
|
27
|
-
return [];
|
|
28
|
-
return items
|
|
29
|
-
.filter(item => item.containerName || item.kind !== 'alias')
|
|
30
|
-
.map(toWorkspaceSymbol)
|
|
31
|
-
.filter((v) => !!v);
|
|
32
|
-
function toWorkspaceSymbol(item) {
|
|
33
|
-
const label = getLabel(item);
|
|
34
|
-
const uri = ctx.fileNameToUri(item.fileName);
|
|
35
|
-
const document = ctx.getTextDocument(uri);
|
|
36
|
-
if (document) {
|
|
37
|
-
const range = {
|
|
38
|
-
start: document.positionAt(item.textSpan.start),
|
|
39
|
-
end: document.positionAt(item.textSpan.start + item.textSpan.length),
|
|
40
|
-
};
|
|
41
|
-
const info = {
|
|
42
|
-
name: label,
|
|
43
|
-
kind: getSymbolKind(item),
|
|
44
|
-
location: { uri, range },
|
|
45
|
-
};
|
|
46
|
-
const kindModifiers = item.kindModifiers ? (0, modifiers_1.parseKindModifier)(item.kindModifiers) : undefined;
|
|
47
|
-
if (kindModifiers?.has(PConst.KindModifiers.deprecated)) {
|
|
48
|
-
info.tags = [1];
|
|
49
|
-
}
|
|
50
|
-
return info;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function getLabel(item) {
|
|
54
|
-
const label = item.name;
|
|
55
|
-
if (item.kind === 'method' || item.kind === 'function') {
|
|
56
|
-
return label + '()';
|
|
57
|
-
}
|
|
58
|
-
return label;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
exports.register = register;
|
|
63
|
-
//# sourceMappingURL=workspaceSymbol.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type * as vscode from '@volar/language-service';
|
|
2
|
-
import type * as ts from 'typescript';
|
|
3
|
-
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
import type { SharedContext } from '../types';
|
|
5
|
-
export declare function entriesToLocations(entries: {
|
|
6
|
-
fileName: string;
|
|
7
|
-
textSpan: ts.TextSpan;
|
|
8
|
-
}[], ctx: SharedContext): vscode.Location[];
|
|
9
|
-
export declare function entryToLocation(entry: {
|
|
10
|
-
fileName: string;
|
|
11
|
-
textSpan: ts.TextSpan;
|
|
12
|
-
}, ctx: SharedContext): vscode.Location | undefined;
|
|
13
|
-
export declare function entriesToLocationLinks<T extends ts.DocumentSpan>(entries: T[], ctx: SharedContext): vscode.LocationLink[];
|
|
14
|
-
export declare function boundSpanToLocationLinks(info: ts.DefinitionInfoAndBoundSpan, originalDoc: TextDocument, ctx: SharedContext): vscode.LocationLink[];
|
|
15
|
-
//# sourceMappingURL=transforms.d.ts.map
|