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,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.addMarkdownDocumentation = exports.markdownDocumentation = exports.tagsMarkdownPreview = exports.plainWithLinks = void 0;
|
|
8
|
+
function replaceLinks(text) {
|
|
9
|
+
return text
|
|
10
|
+
// Http(s) links
|
|
11
|
+
.replace(/\{@(link|linkplain|linkcode) (https?:\/\/[^ |}]+?)(?:[| ]([^{}\n]+?))?\}/gi, (_, tag, link, text) => {
|
|
12
|
+
switch (tag) {
|
|
13
|
+
case 'linkcode':
|
|
14
|
+
return `[\`${text ? text.trim() : link}\`](${link})`;
|
|
15
|
+
default:
|
|
16
|
+
return `[${text ? text.trim() : link}](${link})`;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function processInlineTags(text) {
|
|
21
|
+
return replaceLinks(text);
|
|
22
|
+
}
|
|
23
|
+
function getTagBodyText(tag, filePathConverter, ctx) {
|
|
24
|
+
if (!tag.text) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
// Convert to markdown code block if it is not already one
|
|
28
|
+
function makeCodeblock(text) {
|
|
29
|
+
if (text.match(/^\s*[~`]{3}/g)) {
|
|
30
|
+
return text;
|
|
31
|
+
}
|
|
32
|
+
return '```\n' + text + '\n```';
|
|
33
|
+
}
|
|
34
|
+
const text = convertLinkTags(tag.text, filePathConverter, ctx);
|
|
35
|
+
switch (tag.name) {
|
|
36
|
+
case 'example':
|
|
37
|
+
// check for caption tags, fix for #79704
|
|
38
|
+
const captionTagMatches = text.match(/<caption>(.*?)<\/caption>\s*(\r\n|\n)/);
|
|
39
|
+
if (captionTagMatches && captionTagMatches.index === 0) {
|
|
40
|
+
return captionTagMatches[1] + '\n\n' + makeCodeblock(text.slice(captionTagMatches[0].length));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return makeCodeblock(text);
|
|
44
|
+
}
|
|
45
|
+
case 'author':
|
|
46
|
+
// fix obfuscated email address, #80898
|
|
47
|
+
const emailMatch = text.match(/(.+)\s<([-.\w]+@[-.\w]+)>/);
|
|
48
|
+
if (emailMatch === null) {
|
|
49
|
+
return text;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return `${emailMatch[1]} ${emailMatch[2]}`;
|
|
53
|
+
}
|
|
54
|
+
case 'default':
|
|
55
|
+
return makeCodeblock(text);
|
|
56
|
+
}
|
|
57
|
+
return processInlineTags(text);
|
|
58
|
+
}
|
|
59
|
+
function getTagDocumentation(tag, filePathConverter, ctx) {
|
|
60
|
+
switch (tag.name) {
|
|
61
|
+
case 'augments':
|
|
62
|
+
case 'extends':
|
|
63
|
+
case 'param':
|
|
64
|
+
case 'template':
|
|
65
|
+
const body = (convertLinkTags(tag.text, filePathConverter, ctx)).split(/^(\S+)\s*-?\s*/);
|
|
66
|
+
if (body?.length === 3) {
|
|
67
|
+
const param = body[1];
|
|
68
|
+
const doc = body[2];
|
|
69
|
+
const label = `*@${tag.name}* \`${param}\``;
|
|
70
|
+
if (!doc) {
|
|
71
|
+
return label;
|
|
72
|
+
}
|
|
73
|
+
return label + (doc.match(/\r\n|\n/g) ? ' \n' + processInlineTags(doc) : ` — ${processInlineTags(doc)}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Generic tag
|
|
77
|
+
const label = `*@${tag.name}*`;
|
|
78
|
+
const text = getTagBodyText(tag, filePathConverter, ctx);
|
|
79
|
+
if (!text) {
|
|
80
|
+
return label;
|
|
81
|
+
}
|
|
82
|
+
return label + (text.match(/\r\n|\n/g) ? ' \n' + text : ` — ${text}`);
|
|
83
|
+
}
|
|
84
|
+
function plainWithLinks(parts, filePathConverter, ctx) {
|
|
85
|
+
return processInlineTags(convertLinkTags(parts, filePathConverter, ctx));
|
|
86
|
+
}
|
|
87
|
+
exports.plainWithLinks = plainWithLinks;
|
|
88
|
+
/**
|
|
89
|
+
* Convert `@link` inline tags to markdown links
|
|
90
|
+
*/
|
|
91
|
+
function convertLinkTags(parts, filePathConverter, ctx) {
|
|
92
|
+
if (!parts) {
|
|
93
|
+
return '';
|
|
94
|
+
}
|
|
95
|
+
if (typeof parts === 'string') {
|
|
96
|
+
return parts;
|
|
97
|
+
}
|
|
98
|
+
const out = [];
|
|
99
|
+
let currentLink;
|
|
100
|
+
for (const part of parts) {
|
|
101
|
+
switch (part.kind) {
|
|
102
|
+
case 'link':
|
|
103
|
+
if (currentLink) {
|
|
104
|
+
const text = currentLink.text ?? currentLink.name;
|
|
105
|
+
let target = currentLink.target;
|
|
106
|
+
if (typeof currentLink.target === 'object' && 'fileName' in currentLink.target) {
|
|
107
|
+
const _target = currentLink.target;
|
|
108
|
+
const fileDoc = ctx.getTextDocument(ctx.env.uriToFileName(_target.fileName));
|
|
109
|
+
if (fileDoc) {
|
|
110
|
+
const start = fileDoc.positionAt(_target.textSpan.start);
|
|
111
|
+
const end = fileDoc.positionAt(_target.textSpan.start + _target.textSpan.length);
|
|
112
|
+
target = {
|
|
113
|
+
file: _target.fileName,
|
|
114
|
+
start: {
|
|
115
|
+
line: start.line + 1,
|
|
116
|
+
offset: start.character + 1,
|
|
117
|
+
},
|
|
118
|
+
end: {
|
|
119
|
+
line: end.line + 1,
|
|
120
|
+
offset: end.character + 1,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
target = undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (target) {
|
|
129
|
+
const link = filePathConverter.toResource(target.file) + '#' + `L${target.start.line},${target.start.offset}`;
|
|
130
|
+
out.push(`[${text}](${link})`);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
if (text) {
|
|
134
|
+
out.push(text);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
currentLink = undefined;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
currentLink = {};
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case 'linkName':
|
|
144
|
+
if (currentLink) {
|
|
145
|
+
currentLink.name = part.text;
|
|
146
|
+
currentLink.target = part.target;
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
case 'linkText':
|
|
150
|
+
if (currentLink) {
|
|
151
|
+
currentLink.text = part.text;
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
out.push(part.text);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return processInlineTags(out.join(''));
|
|
160
|
+
}
|
|
161
|
+
function tagsMarkdownPreview(tags, filePathConverter, ctx) {
|
|
162
|
+
return tags.map(tag => getTagDocumentation(tag, filePathConverter, ctx)).join(' \n\n');
|
|
163
|
+
}
|
|
164
|
+
exports.tagsMarkdownPreview = tagsMarkdownPreview;
|
|
165
|
+
function markdownDocumentation(documentation, tags, filePathConverter, ctx) {
|
|
166
|
+
return addMarkdownDocumentation('', documentation, tags, filePathConverter, ctx);
|
|
167
|
+
}
|
|
168
|
+
exports.markdownDocumentation = markdownDocumentation;
|
|
169
|
+
function addMarkdownDocumentation(out, documentation, tags, converter, ctx) {
|
|
170
|
+
if (documentation) {
|
|
171
|
+
out += plainWithLinks(documentation, converter, ctx);
|
|
172
|
+
}
|
|
173
|
+
if (tags) {
|
|
174
|
+
const tagsPreview = tagsMarkdownPreview(tags, converter, ctx);
|
|
175
|
+
if (tagsPreview) {
|
|
176
|
+
out += '\n\n' + tagsPreview;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
exports.addMarkdownDocumentation = addMarkdownDocumentation;
|
|
182
|
+
//# sourceMappingURL=previewer.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
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.snippetForFunctionCall = void 0;
|
|
27
|
+
const PConst = __importStar(require("../protocol.const"));
|
|
28
|
+
function snippetForFunctionCall(item, displayParts) {
|
|
29
|
+
if (item.insertText && typeof item.insertText !== 'string') {
|
|
30
|
+
return { snippet: item.insertText, parameterCount: 0 };
|
|
31
|
+
}
|
|
32
|
+
let _tabstop = 1;
|
|
33
|
+
const parameterListParts = getParameterListParts(displayParts);
|
|
34
|
+
let snippet = '';
|
|
35
|
+
snippet += `${item.insertText || item.label}(`;
|
|
36
|
+
snippet = appendJoinedPlaceholders(snippet, parameterListParts.parts, ', ');
|
|
37
|
+
if (parameterListParts.hasOptionalParameters) {
|
|
38
|
+
snippet += '$' + _tabstop++;
|
|
39
|
+
}
|
|
40
|
+
snippet += ')';
|
|
41
|
+
snippet += '$' + _tabstop++;
|
|
42
|
+
return { snippet, parameterCount: parameterListParts.parts.length + (parameterListParts.hasOptionalParameters ? 1 : 0) };
|
|
43
|
+
function appendJoinedPlaceholders(snippet, parts, joiner) {
|
|
44
|
+
for (let i = 0; i < parts.length; ++i) {
|
|
45
|
+
const paramterPart = parts[i];
|
|
46
|
+
snippet += '${' + _tabstop++ + ':' + paramterPart.text + '}';
|
|
47
|
+
if (i !== parts.length - 1) {
|
|
48
|
+
snippet += joiner;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return snippet;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.snippetForFunctionCall = snippetForFunctionCall;
|
|
55
|
+
function getParameterListParts(displayParts) {
|
|
56
|
+
const parts = [];
|
|
57
|
+
let isInMethod = false;
|
|
58
|
+
let hasOptionalParameters = false;
|
|
59
|
+
let parenCount = 0;
|
|
60
|
+
let braceCount = 0;
|
|
61
|
+
outer: for (let i = 0; i < displayParts.length; ++i) {
|
|
62
|
+
const part = displayParts[i];
|
|
63
|
+
switch (part.kind) {
|
|
64
|
+
case PConst.DisplayPartKind.methodName:
|
|
65
|
+
case PConst.DisplayPartKind.functionName:
|
|
66
|
+
case PConst.DisplayPartKind.text:
|
|
67
|
+
case PConst.DisplayPartKind.propertyName:
|
|
68
|
+
if (parenCount === 0 && braceCount === 0) {
|
|
69
|
+
isInMethod = true;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case PConst.DisplayPartKind.parameterName:
|
|
73
|
+
if (parenCount === 1 && braceCount === 0 && isInMethod) {
|
|
74
|
+
// Only take top level paren names
|
|
75
|
+
const next = displayParts[i + 1];
|
|
76
|
+
// Skip optional parameters
|
|
77
|
+
const nameIsFollowedByOptionalIndicator = next && next.text === '?';
|
|
78
|
+
// Skip this parameter
|
|
79
|
+
const nameIsThis = part.text === 'this';
|
|
80
|
+
if (!nameIsFollowedByOptionalIndicator && !nameIsThis) {
|
|
81
|
+
parts.push(part);
|
|
82
|
+
}
|
|
83
|
+
hasOptionalParameters = hasOptionalParameters || nameIsFollowedByOptionalIndicator;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case PConst.DisplayPartKind.punctuation:
|
|
87
|
+
if (part.text === '(') {
|
|
88
|
+
++parenCount;
|
|
89
|
+
}
|
|
90
|
+
else if (part.text === ')') {
|
|
91
|
+
--parenCount;
|
|
92
|
+
if (parenCount <= 0 && isInMethod) {
|
|
93
|
+
break outer;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (part.text === '...' && parenCount === 1) {
|
|
97
|
+
// Found rest parmeter. Do not fill in any further arguments
|
|
98
|
+
hasOptionalParameters = true;
|
|
99
|
+
break outer;
|
|
100
|
+
}
|
|
101
|
+
else if (part.text === '{') {
|
|
102
|
+
++braceCount;
|
|
103
|
+
}
|
|
104
|
+
else if (part.text === '}') {
|
|
105
|
+
--braceCount;
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { hasOptionalParameters, parts };
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=snippetForFunctionCall.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SharedContext } from '../types';
|
|
2
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
+
export declare function entriesToLocations(entries: {
|
|
6
|
+
fileName: string;
|
|
7
|
+
textSpan: ts.TextSpan;
|
|
8
|
+
}[], ctx: SharedContext): vscode.Location[];
|
|
9
|
+
export declare function entriesToLocationLinks<T extends ts.DocumentSpan>(entries: T[], ctx: SharedContext): vscode.LocationLink[];
|
|
10
|
+
export declare function boundSpanToLocationLinks(info: ts.DefinitionInfoAndBoundSpan, originalDoc: TextDocument, ctx: SharedContext): vscode.LocationLink[];
|
|
@@ -0,0 +1,76 @@
|
|
|
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.boundSpanToLocationLinks = exports.entriesToLocationLinks = exports.entriesToLocations = void 0;
|
|
27
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
28
|
+
function entriesToLocations(entries, ctx) {
|
|
29
|
+
const locations = [];
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
const entryUri = ctx.env.fileNameToUri(entry.fileName);
|
|
32
|
+
const doc = ctx.getTextDocument(entryUri);
|
|
33
|
+
if (!doc)
|
|
34
|
+
continue;
|
|
35
|
+
const range = vscode.Range.create(doc.positionAt(entry.textSpan.start), doc.positionAt(entry.textSpan.start + entry.textSpan.length));
|
|
36
|
+
const location = vscode.Location.create(entryUri, range);
|
|
37
|
+
locations.push(location);
|
|
38
|
+
}
|
|
39
|
+
return locations;
|
|
40
|
+
}
|
|
41
|
+
exports.entriesToLocations = entriesToLocations;
|
|
42
|
+
function entriesToLocationLinks(entries, ctx) {
|
|
43
|
+
const locations = [];
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
const entryUri = ctx.env.fileNameToUri(entry.fileName);
|
|
46
|
+
const doc = ctx.getTextDocument(entryUri);
|
|
47
|
+
if (!doc)
|
|
48
|
+
continue;
|
|
49
|
+
const targetSelectionRange = vscode.Range.create(doc.positionAt(entry.textSpan.start), doc.positionAt(entry.textSpan.start + entry.textSpan.length));
|
|
50
|
+
const targetRange = entry.contextSpan ? vscode.Range.create(doc.positionAt(entry.contextSpan.start), doc.positionAt(entry.contextSpan.start + entry.contextSpan.length)) : targetSelectionRange;
|
|
51
|
+
const originSelectionRange = entry.originalTextSpan ? vscode.Range.create(doc.positionAt(entry.originalTextSpan.start), doc.positionAt(entry.originalTextSpan.start + entry.originalTextSpan.length)) : undefined;
|
|
52
|
+
const location = vscode.LocationLink.create(entryUri, targetRange, targetSelectionRange, originSelectionRange);
|
|
53
|
+
locations.push(location);
|
|
54
|
+
}
|
|
55
|
+
return locations;
|
|
56
|
+
}
|
|
57
|
+
exports.entriesToLocationLinks = entriesToLocationLinks;
|
|
58
|
+
function boundSpanToLocationLinks(info, originalDoc, ctx) {
|
|
59
|
+
const locations = [];
|
|
60
|
+
if (!info.definitions)
|
|
61
|
+
return locations;
|
|
62
|
+
const originSelectionRange = vscode.Range.create(originalDoc.positionAt(info.textSpan.start), originalDoc.positionAt(info.textSpan.start + info.textSpan.length));
|
|
63
|
+
for (const entry of info.definitions) {
|
|
64
|
+
const entryUri = ctx.env.fileNameToUri(entry.fileName);
|
|
65
|
+
const doc = ctx.getTextDocument(entryUri);
|
|
66
|
+
if (!doc)
|
|
67
|
+
continue;
|
|
68
|
+
const targetSelectionRange = vscode.Range.create(doc.positionAt(entry.textSpan.start), doc.positionAt(entry.textSpan.start + entry.textSpan.length));
|
|
69
|
+
const targetRange = entry.contextSpan ? vscode.Range.create(doc.positionAt(entry.contextSpan.start), doc.positionAt(entry.contextSpan.start + entry.contextSpan.length)) : targetSelectionRange;
|
|
70
|
+
const location = vscode.LocationLink.create(entryUri, targetRange, targetSelectionRange, originSelectionRange);
|
|
71
|
+
locations.push(location);
|
|
72
|
+
}
|
|
73
|
+
return locations;
|
|
74
|
+
}
|
|
75
|
+
exports.boundSpanToLocationLinks = boundSpanToLocationLinks;
|
|
76
|
+
//# sourceMappingURL=transforms.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.SymbolKind = void 0;
|
|
31
|
+
/**
|
|
32
|
+
* Helpers for converting FROM vscode types TO ts types
|
|
33
|
+
*/
|
|
34
|
+
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
35
|
+
const PConst = __importStar(require("../protocol.const"));
|
|
36
|
+
var SymbolKind;
|
|
37
|
+
(function (SymbolKind) {
|
|
38
|
+
function fromProtocolScriptElementKind(kind) {
|
|
39
|
+
switch (kind) {
|
|
40
|
+
case PConst.Kind.module: return vscode.SymbolKind.Module;
|
|
41
|
+
case PConst.Kind.class: return vscode.SymbolKind.Class;
|
|
42
|
+
case PConst.Kind.enum: return vscode.SymbolKind.Enum;
|
|
43
|
+
case PConst.Kind.enumMember: return vscode.SymbolKind.EnumMember;
|
|
44
|
+
case PConst.Kind.interface: return vscode.SymbolKind.Interface;
|
|
45
|
+
case PConst.Kind.indexSignature: return vscode.SymbolKind.Method;
|
|
46
|
+
case PConst.Kind.callSignature: return vscode.SymbolKind.Method;
|
|
47
|
+
case PConst.Kind.method: return vscode.SymbolKind.Method;
|
|
48
|
+
case PConst.Kind.memberVariable: return vscode.SymbolKind.Property;
|
|
49
|
+
case PConst.Kind.memberGetAccessor: return vscode.SymbolKind.Property;
|
|
50
|
+
case PConst.Kind.memberSetAccessor: return vscode.SymbolKind.Property;
|
|
51
|
+
case PConst.Kind.variable: return vscode.SymbolKind.Variable;
|
|
52
|
+
case PConst.Kind.let: return vscode.SymbolKind.Variable;
|
|
53
|
+
case PConst.Kind.const: return vscode.SymbolKind.Variable;
|
|
54
|
+
case PConst.Kind.localVariable: return vscode.SymbolKind.Variable;
|
|
55
|
+
case PConst.Kind.alias: return vscode.SymbolKind.Variable;
|
|
56
|
+
case PConst.Kind.function: return vscode.SymbolKind.Function;
|
|
57
|
+
case PConst.Kind.localFunction: return vscode.SymbolKind.Function;
|
|
58
|
+
case PConst.Kind.constructSignature: return vscode.SymbolKind.Constructor;
|
|
59
|
+
case PConst.Kind.constructorImplementation: return vscode.SymbolKind.Constructor;
|
|
60
|
+
case PConst.Kind.typeParameter: return vscode.SymbolKind.TypeParameter;
|
|
61
|
+
case PConst.Kind.string: return vscode.SymbolKind.String;
|
|
62
|
+
default: return vscode.SymbolKind.Variable;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
SymbolKind.fromProtocolScriptElementKind = fromProtocolScriptElementKind;
|
|
66
|
+
})(SymbolKind = exports.SymbolKind || (exports.SymbolKind = {}));
|
|
67
|
+
//# sourceMappingURL=typeConverters.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "volar-service-typescript",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"main": "out/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"rules.d.ts",
|
|
8
|
+
"out/**/*.js",
|
|
9
|
+
"out/**/*.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/volarjs/services.git",
|
|
14
|
+
"directory": "packages/typescript"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/semver": "^7.3.13"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"jsonc-parser": "^3.2.0",
|
|
21
|
+
"minimatch": "^9.0.0",
|
|
22
|
+
"semver": "^7.3.8",
|
|
23
|
+
"vscode-languageserver-protocol": "^3.17.3",
|
|
24
|
+
"vscode-languageserver-textdocument": "^1.0.8",
|
|
25
|
+
"vscode-nls": "^5.2.0",
|
|
26
|
+
"vscode-uri": "^3.0.7"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@volar/language-service": "*"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "1011561ac4bbf79c53c3b80c27692569bf861519"
|
|
32
|
+
}
|
package/rules.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
+
|
|
4
|
+
declare module '@volar/language-service' {
|
|
5
|
+
interface RuleContext {
|
|
6
|
+
typescript?: {
|
|
7
|
+
sourceFile: ts.SourceFile;
|
|
8
|
+
getTextDocument(uri: string): TextDocument | undefined;
|
|
9
|
+
languageService: ts.LanguageService;
|
|
10
|
+
languageServiceHost: ts.LanguageServiceHost;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|