volar-service-typescript 0.0.6 → 0.0.8
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/index.js +1 -1
- package/out/protocol.const.js +5 -5
- package/out/utils/typeConverters.js +1 -1
- package/package.json +9 -3
- package/out/languageServiceHost.d.ts +0 -3
- package/out/languageServiceHost.js +0 -199
- package/out/services/callHierarchy.d.ts +0 -7
- package/out/services/callHierarchy.js +0 -125
- package/out/services/codeAction.d.ts +0 -26
- package/out/services/codeAction.js +0 -263
- package/out/services/codeActionResolve.d.ts +0 -9
- package/out/services/codeActionResolve.js +0 -51
- package/out/services/completions/basic.d.ts +0 -16
- package/out/services/completions/basic.js +0 -349
- package/out/services/completions/directiveComment.d.ts +0 -3
- package/out/services/completions/directiveComment.js +0 -77
- package/out/services/completions/jsDoc.d.ts +0 -3
- package/out/services/completions/jsDoc.js +0 -105
- package/out/services/completions/resolve.d.ts +0 -5
- package/out/services/completions/resolve.js +0 -169
- package/out/services/definition.d.ts +0 -3
- package/out/services/definition.js +0 -20
- package/out/services/diagnostics.d.ts +0 -10
- package/out/services/diagnostics.js +0 -120
- package/out/services/documentHighlight.d.ts +0 -3
- package/out/services/documentHighlight.js +0 -32
- package/out/services/documentSymbol.d.ts +0 -3
- package/out/services/documentSymbol.js +0 -117
- package/out/services/fileReferences.d.ts +0 -3
- package/out/services/fileReferences.js +0 -19
- package/out/services/fileRename.d.ts +0 -3
- package/out/services/fileRename.js +0 -25
- package/out/services/foldingRanges.d.ts +0 -3
- package/out/services/foldingRanges.js +0 -55
- package/out/services/formatting.d.ts +0 -6
- package/out/services/formatting.js +0 -58
- package/out/services/hover.d.ts +0 -3
- package/out/services/hover.js +0 -66
- package/out/services/implementation.d.ts +0 -3
- package/out/services/implementation.js +0 -20
- package/out/services/inlayHints.d.ts +0 -3
- package/out/services/inlayHints.js +0 -34
- package/out/services/prepareRename.d.ts +0 -8
- package/out/services/prepareRename.js +0 -27
- package/out/services/references.d.ts +0 -3
- package/out/services/references.js +0 -20
- package/out/services/rename.d.ts +0 -5
- package/out/services/rename.js +0 -116
- package/out/services/selectionRanges.d.ts +0 -3
- package/out/services/selectionRanges.js +0 -32
- package/out/services/semanticTokens.d.ts +0 -3
- package/out/services/semanticTokens.js +0 -128
- package/out/services/signatureHelp.d.ts +0 -3
- package/out/services/signatureHelp.js +0 -63
- package/out/services/tsconfig.d.ts +0 -6
- package/out/services/tsconfig.js +0 -205
- package/out/services/typeDefinition.d.ts +0 -3
- package/out/services/typeDefinition.js +0 -20
- package/out/services/workspaceSymbol.d.ts +0 -3
- package/out/services/workspaceSymbol.js +0 -86
package/out/index.js
CHANGED
|
@@ -82,7 +82,7 @@ exports.default = (options) => (contextOrNull, modules) => {
|
|
|
82
82
|
return {};
|
|
83
83
|
}
|
|
84
84
|
const ts = modules.typescript;
|
|
85
|
-
const sys = (0, typescript_1.createSys)(
|
|
85
|
+
const sys = (0, typescript_1.createSys)(ts, context.env, options?.dtsHost);
|
|
86
86
|
const languageServiceHost = (0, typescript_1.createLanguageServiceHost)(context, ts, sys);
|
|
87
87
|
const created = tsFaster.createLanguageService(ts, sys, languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, (0, typescript_1.getDocumentRegistry)(ts, sys.useCaseSensitiveFileNames, context.host.getCurrentDirectory())));
|
|
88
88
|
const { languageService } = created;
|
package/out/protocol.const.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.EventName = exports.DisplayPartKind = exports.KindModifiers = exports.DiagnosticCategory = exports.Kind = void 0;
|
|
8
8
|
class Kind {
|
|
9
9
|
}
|
|
10
|
+
exports.Kind = Kind;
|
|
10
11
|
Kind.alias = 'alias';
|
|
11
12
|
Kind.callSignature = 'call';
|
|
12
13
|
Kind.class = 'class';
|
|
@@ -37,15 +38,15 @@ Kind.warning = 'warning';
|
|
|
37
38
|
Kind.string = 'string';
|
|
38
39
|
Kind.parameter = 'parameter';
|
|
39
40
|
Kind.typeParameter = 'type parameter';
|
|
40
|
-
exports.Kind = Kind;
|
|
41
41
|
class DiagnosticCategory {
|
|
42
42
|
}
|
|
43
|
+
exports.DiagnosticCategory = DiagnosticCategory;
|
|
43
44
|
DiagnosticCategory.error = 'error';
|
|
44
45
|
DiagnosticCategory.warning = 'warning';
|
|
45
46
|
DiagnosticCategory.suggestion = 'suggestion';
|
|
46
|
-
exports.DiagnosticCategory = DiagnosticCategory;
|
|
47
47
|
class KindModifiers {
|
|
48
48
|
}
|
|
49
|
+
exports.KindModifiers = KindModifiers;
|
|
49
50
|
KindModifiers.optional = 'optional';
|
|
50
51
|
KindModifiers.deprecated = 'deprecated';
|
|
51
52
|
KindModifiers.color = 'color';
|
|
@@ -63,16 +64,15 @@ KindModifiers.fileExtensionKindModifiers = [
|
|
|
63
64
|
KindModifiers.jsxFile,
|
|
64
65
|
KindModifiers.jsonFile,
|
|
65
66
|
];
|
|
66
|
-
exports.KindModifiers = KindModifiers;
|
|
67
67
|
class DisplayPartKind {
|
|
68
68
|
}
|
|
69
|
+
exports.DisplayPartKind = DisplayPartKind;
|
|
69
70
|
DisplayPartKind.functionName = 'functionName';
|
|
70
71
|
DisplayPartKind.methodName = 'methodName';
|
|
71
72
|
DisplayPartKind.parameterName = 'parameterName';
|
|
72
73
|
DisplayPartKind.propertyName = 'propertyName';
|
|
73
74
|
DisplayPartKind.punctuation = 'punctuation';
|
|
74
75
|
DisplayPartKind.text = 'text';
|
|
75
|
-
exports.DisplayPartKind = DisplayPartKind;
|
|
76
76
|
var EventName;
|
|
77
77
|
(function (EventName) {
|
|
78
78
|
EventName["syntaxDiag"] = "syntaxDiag";
|
|
@@ -88,5 +88,5 @@ var EventName;
|
|
|
88
88
|
EventName["surveyReady"] = "surveyReady";
|
|
89
89
|
EventName["projectLoadingStart"] = "projectLoadingStart";
|
|
90
90
|
EventName["projectLoadingFinish"] = "projectLoadingFinish";
|
|
91
|
-
})(EventName
|
|
91
|
+
})(EventName || (exports.EventName = EventName = {}));
|
|
92
92
|
//# sourceMappingURL=protocol.const.js.map
|
|
@@ -59,5 +59,5 @@ var SymbolKind;
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
SymbolKind.fromProtocolScriptElementKind = fromProtocolScriptElementKind;
|
|
62
|
-
})(SymbolKind
|
|
62
|
+
})(SymbolKind || (exports.SymbolKind = SymbolKind = {}));
|
|
63
63
|
//# sourceMappingURL=typeConverters.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/semver": "^7.3.13",
|
|
17
|
-
"@volar/typescript": "1.7.
|
|
17
|
+
"@volar/typescript": "1.7.7"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"semver": "^7.3.8",
|
|
@@ -24,7 +24,13 @@
|
|
|
24
24
|
"vscode-uri": "^3.0.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
+
"@volar/language-service": "*",
|
|
27
28
|
"@volar/typescript": "*"
|
|
28
29
|
},
|
|
29
|
-
"
|
|
30
|
+
"peerDependenciesMeta": {
|
|
31
|
+
"@volar/language-service": {
|
|
32
|
+
"optional": true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "b3a5b5642bd39d0542a113cd06743f968b053458"
|
|
30
36
|
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ServiceContext } from '@volar/language-service';
|
|
2
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
export declare function createLanguageServiceHost(context: ServiceContext, ts: typeof import('typescript/lib/tsserverlibrary')): ts.LanguageServiceHost;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLanguageServiceHost = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
function createLanguageServiceHost(context, ts) {
|
|
6
|
-
let lastProjectVersion;
|
|
7
|
-
let tsProjectVersion = 0;
|
|
8
|
-
const host = context.host;
|
|
9
|
-
const virtualFiles = context.core.virtualFiles;
|
|
10
|
-
const _tsHost = {
|
|
11
|
-
fileExists: host.fileExists
|
|
12
|
-
? fileName => {
|
|
13
|
-
const ext = fileName.substring(fileName.lastIndexOf('.'));
|
|
14
|
-
if (ext === '.js'
|
|
15
|
-
|| ext === '.ts'
|
|
16
|
-
|| ext === '.jsx'
|
|
17
|
-
|| ext === '.tsx') {
|
|
18
|
-
/**
|
|
19
|
-
* If try to access a external .vue file that outside of the project,
|
|
20
|
-
* the file will not process by language service host,
|
|
21
|
-
* so virtual file will not be created.
|
|
22
|
-
*
|
|
23
|
-
* We try to create virtual file here.
|
|
24
|
-
*/
|
|
25
|
-
const sourceFileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
|
26
|
-
if (!virtualFiles.hasSource(sourceFileName)) {
|
|
27
|
-
const scriptSnapshot = host.getScriptSnapshot(sourceFileName);
|
|
28
|
-
if (scriptSnapshot) {
|
|
29
|
-
virtualFiles.updateSource(sourceFileName, scriptSnapshot, host.getScriptLanguageId?.(sourceFileName));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (virtualFiles.hasVirtualFile(fileName)) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
return !!host.fileExists?.(fileName);
|
|
37
|
-
}
|
|
38
|
-
: undefined,
|
|
39
|
-
getProjectVersion: () => {
|
|
40
|
-
return host.getTypeRootsVersion?.() + ':' + tsProjectVersion.toString();
|
|
41
|
-
},
|
|
42
|
-
getTypeRootsVersion: host.getTypeRootsVersion,
|
|
43
|
-
getScriptFileNames,
|
|
44
|
-
getScriptVersion,
|
|
45
|
-
getScriptSnapshot,
|
|
46
|
-
readDirectory: (_path, extensions, exclude, include, depth) => {
|
|
47
|
-
const result = host.readDirectory?.(_path, extensions, exclude, include, depth) ?? [];
|
|
48
|
-
for (const { fileName } of virtualFiles.allSources()) {
|
|
49
|
-
const vuePath2 = path_1.posix.join(_path, path_1.posix.basename(fileName));
|
|
50
|
-
if (path_1.posix.relative(_path.toLowerCase(), fileName.toLowerCase()).startsWith('..')) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (!depth && fileName.toLowerCase() === vuePath2.toLowerCase()) {
|
|
54
|
-
result.push(vuePath2);
|
|
55
|
-
}
|
|
56
|
-
else if (depth) {
|
|
57
|
-
result.push(vuePath2); // TODO: depth num
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
},
|
|
62
|
-
getScriptKind(fileName) {
|
|
63
|
-
if (ts) {
|
|
64
|
-
if (virtualFiles.hasSource(fileName))
|
|
65
|
-
return ts.ScriptKind.Deferred;
|
|
66
|
-
switch (path_1.posix.extname(fileName)) {
|
|
67
|
-
case '.js': return ts.ScriptKind.JS;
|
|
68
|
-
case '.jsx': return ts.ScriptKind.JSX;
|
|
69
|
-
case '.ts': return ts.ScriptKind.TS;
|
|
70
|
-
case '.tsx': return ts.ScriptKind.TSX;
|
|
71
|
-
case '.json': return ts.ScriptKind.JSON;
|
|
72
|
-
default: return ts.ScriptKind.Unknown;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return 0;
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
const scriptSnapshots = new Map();
|
|
79
|
-
const virtualFileVersions = new Map();
|
|
80
|
-
return new Proxy(_tsHost, {
|
|
81
|
-
get: (target, property) => {
|
|
82
|
-
update();
|
|
83
|
-
return target[property] || host[property];
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
function update() {
|
|
87
|
-
const newProjectVersion = host.getProjectVersion?.();
|
|
88
|
-
const shouldUpdate = newProjectVersion === undefined || newProjectVersion !== lastProjectVersion;
|
|
89
|
-
if (!shouldUpdate)
|
|
90
|
-
return;
|
|
91
|
-
lastProjectVersion = newProjectVersion;
|
|
92
|
-
const oldTsVirtualFileSnapshots = new Set();
|
|
93
|
-
const oldOtherVirtualFileSnapshots = new Set();
|
|
94
|
-
const newTsVirtualFileSnapshots = new Set();
|
|
95
|
-
const newOtherVirtualFileSnapshots = new Set();
|
|
96
|
-
for (const { root } of virtualFiles.allSources()) {
|
|
97
|
-
forEachEmbeddedFile(root, embedded => {
|
|
98
|
-
if (embedded.kind === 1) {
|
|
99
|
-
oldTsVirtualFileSnapshots.add(embedded.snapshot);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
oldOtherVirtualFileSnapshots.add(embedded.snapshot);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
context.core.update();
|
|
107
|
-
for (const { root } of virtualFiles.allSources()) {
|
|
108
|
-
forEachEmbeddedFile(root, embedded => {
|
|
109
|
-
if (embedded.kind === 1) {
|
|
110
|
-
newTsVirtualFileSnapshots.add(embedded.snapshot);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
newOtherVirtualFileSnapshots.add(embedded.snapshot);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (!setEquals(oldTsVirtualFileSnapshots, newTsVirtualFileSnapshots)) {
|
|
118
|
-
tsProjectVersion++;
|
|
119
|
-
}
|
|
120
|
-
else if (setEquals(oldOtherVirtualFileSnapshots, newOtherVirtualFileSnapshots)) {
|
|
121
|
-
// no any meta language files update, it mean project version was update by source files this time
|
|
122
|
-
tsProjectVersion++;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function getScriptFileNames() {
|
|
126
|
-
const tsFileNames = new Set();
|
|
127
|
-
for (const { root: rootVirtualFile } of virtualFiles.allSources()) {
|
|
128
|
-
forEachEmbeddedFile(rootVirtualFile, embedded => {
|
|
129
|
-
if (embedded.kind === 1) {
|
|
130
|
-
tsFileNames.add(embedded.fileName); // virtual .ts
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
for (const fileName of host.getScriptFileNames()) {
|
|
135
|
-
if (!virtualFiles.hasSource(fileName)) {
|
|
136
|
-
tsFileNames.add(fileName); // .ts
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return [...tsFileNames];
|
|
140
|
-
}
|
|
141
|
-
function getScriptSnapshot(fileName) {
|
|
142
|
-
const version = getScriptVersion(fileName);
|
|
143
|
-
const cache = scriptSnapshots.get(fileName.toLowerCase());
|
|
144
|
-
if (cache && cache[0] === version) {
|
|
145
|
-
return cache[1];
|
|
146
|
-
}
|
|
147
|
-
const [virtualFile] = virtualFiles.getVirtualFile(fileName);
|
|
148
|
-
if (virtualFile) {
|
|
149
|
-
const snapshot = virtualFile.snapshot;
|
|
150
|
-
scriptSnapshots.set(fileName.toLowerCase(), [version, snapshot]);
|
|
151
|
-
return snapshot;
|
|
152
|
-
}
|
|
153
|
-
let tsScript = host.getScriptSnapshot(fileName);
|
|
154
|
-
if (tsScript) {
|
|
155
|
-
scriptSnapshots.set(fileName.toLowerCase(), [version, tsScript]);
|
|
156
|
-
return tsScript;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function getScriptVersion(fileName) {
|
|
160
|
-
let [virtualFile, source] = virtualFiles.getVirtualFile(fileName);
|
|
161
|
-
if (virtualFile && source) {
|
|
162
|
-
let version = virtualFileVersions.get(virtualFile.fileName);
|
|
163
|
-
if (!version) {
|
|
164
|
-
version = {
|
|
165
|
-
value: 0,
|
|
166
|
-
virtualFileSnapshot: virtualFile.snapshot,
|
|
167
|
-
sourceFileSnapshot: source.snapshot,
|
|
168
|
-
};
|
|
169
|
-
virtualFileVersions.set(virtualFile.fileName, version);
|
|
170
|
-
}
|
|
171
|
-
else if (version.virtualFileSnapshot !== virtualFile.snapshot
|
|
172
|
-
|| (host.isTsc && version.sourceFileSnapshot !== source.snapshot) // fix https://github.com/johnsoncodehk/volar/issues/1082
|
|
173
|
-
) {
|
|
174
|
-
version.value++;
|
|
175
|
-
version.virtualFileSnapshot = virtualFile.snapshot;
|
|
176
|
-
version.sourceFileSnapshot = source.snapshot;
|
|
177
|
-
}
|
|
178
|
-
return version.value.toString();
|
|
179
|
-
}
|
|
180
|
-
return host.getScriptVersion(fileName);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
exports.createLanguageServiceHost = createLanguageServiceHost;
|
|
184
|
-
function setEquals(a, b) {
|
|
185
|
-
if (a.size !== b.size)
|
|
186
|
-
return false;
|
|
187
|
-
for (const item of a) {
|
|
188
|
-
if (!b.has(item))
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
function forEachEmbeddedFile(file, cb) {
|
|
194
|
-
cb(file);
|
|
195
|
-
for (const embeddedFile of file.embeddedFiles) {
|
|
196
|
-
forEachEmbeddedFile(embeddedFile, cb);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
//# sourceMappingURL=languageServiceHost.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type * as vscode from '@volar/language-service';
|
|
2
|
-
import { SharedContext } from '../types';
|
|
3
|
-
export declare function register(ctx: SharedContext): {
|
|
4
|
-
doPrepare: (uri: string, position: vscode.Position) => vscode.CallHierarchyItem[];
|
|
5
|
-
getIncomingCalls: (item: vscode.CallHierarchyItem) => vscode.CallHierarchyIncomingCall[];
|
|
6
|
-
getOutgoingCalls: (item: vscode.CallHierarchyItem) => vscode.CallHierarchyOutgoingCall[];
|
|
7
|
-
};
|
|
@@ -1,125 +0,0 @@
|
|
|
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 modifiers_1 = require("../utils/modifiers");
|
|
29
|
-
const typeConverters = __importStar(require("../utils/typeConverters"));
|
|
30
|
-
const path_1 = require("path");
|
|
31
|
-
const shared_1 = require("../shared");
|
|
32
|
-
function register(ctx) {
|
|
33
|
-
function doPrepare(uri, position) {
|
|
34
|
-
const document = ctx.getTextDocument(uri);
|
|
35
|
-
if (!document)
|
|
36
|
-
return [];
|
|
37
|
-
const fileName = ctx.env.uriToFileName(document.uri);
|
|
38
|
-
const offset = document.offsetAt(position);
|
|
39
|
-
const calls = (0, shared_1.safeCall)(() => ctx.typescript.languageService.prepareCallHierarchy(fileName, offset));
|
|
40
|
-
if (!calls)
|
|
41
|
-
return [];
|
|
42
|
-
const items = Array.isArray(calls) ? calls : [calls];
|
|
43
|
-
return items.map(item => fromProtocolCallHierarchyItem(item));
|
|
44
|
-
}
|
|
45
|
-
function getIncomingCalls(item) {
|
|
46
|
-
const document = ctx.getTextDocument(item.uri);
|
|
47
|
-
if (!document)
|
|
48
|
-
return [];
|
|
49
|
-
const fileName = ctx.env.uriToFileName(item.uri);
|
|
50
|
-
const offset = document.offsetAt(item.selectionRange.start);
|
|
51
|
-
const calls = (0, shared_1.safeCall)(() => ctx.typescript.languageService.provideCallHierarchyIncomingCalls(fileName, offset));
|
|
52
|
-
if (!calls)
|
|
53
|
-
return [];
|
|
54
|
-
const items = Array.isArray(calls) ? calls : [calls];
|
|
55
|
-
return items.map(item => fromProtocolCallHierarchyIncomingCall(item));
|
|
56
|
-
}
|
|
57
|
-
function getOutgoingCalls(item) {
|
|
58
|
-
const document = ctx.getTextDocument(item.uri);
|
|
59
|
-
if (!document)
|
|
60
|
-
return [];
|
|
61
|
-
const fileName = ctx.env.uriToFileName(item.uri);
|
|
62
|
-
const offset = document.offsetAt(item.selectionRange.start);
|
|
63
|
-
const calls = (0, shared_1.safeCall)(() => ctx.typescript.languageService.provideCallHierarchyOutgoingCalls(fileName, offset));
|
|
64
|
-
if (!calls)
|
|
65
|
-
return [];
|
|
66
|
-
const items = Array.isArray(calls) ? calls : [calls];
|
|
67
|
-
return items.map(item => fromProtocolCallHierarchyOutgoingCall(item, document));
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
doPrepare,
|
|
71
|
-
getIncomingCalls,
|
|
72
|
-
getOutgoingCalls,
|
|
73
|
-
};
|
|
74
|
-
function isSourceFileItem(item) {
|
|
75
|
-
return item.kind === PConst.Kind.script || item.kind === PConst.Kind.module && item.selectionSpan.start === 0;
|
|
76
|
-
}
|
|
77
|
-
function fromProtocolCallHierarchyItem(item) {
|
|
78
|
-
const rootPath = ctx.typescript.languageService.getProgram()?.getCompilerOptions().rootDir ?? '';
|
|
79
|
-
const document = ctx.getTextDocument(ctx.env.fileNameToUri(item.file)); // TODO
|
|
80
|
-
const useFileName = isSourceFileItem(item);
|
|
81
|
-
const name = useFileName ? path_1.posix.basename(item.file) : item.name;
|
|
82
|
-
const detail = useFileName ? path_1.posix.relative(rootPath, path_1.posix.dirname(item.file)) : item.containerName ?? '';
|
|
83
|
-
const result = {
|
|
84
|
-
kind: typeConverters.SymbolKind.fromProtocolScriptElementKind(item.kind),
|
|
85
|
-
name,
|
|
86
|
-
detail,
|
|
87
|
-
uri: ctx.env.fileNameToUri(item.file),
|
|
88
|
-
range: {
|
|
89
|
-
start: document.positionAt(item.span.start),
|
|
90
|
-
end: document.positionAt(item.span.start + item.span.length),
|
|
91
|
-
},
|
|
92
|
-
selectionRange: {
|
|
93
|
-
start: document.positionAt(item.selectionSpan.start),
|
|
94
|
-
end: document.positionAt(item.selectionSpan.start + item.selectionSpan.length),
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
const kindModifiers = item.kindModifiers ? (0, modifiers_1.parseKindModifier)(item.kindModifiers) : undefined;
|
|
98
|
-
if (kindModifiers?.has(PConst.KindModifiers.deprecated)) {
|
|
99
|
-
result.tags = [1];
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
function fromProtocolCallHierarchyIncomingCall(item) {
|
|
104
|
-
const document = ctx.getTextDocument(ctx.env.fileNameToUri(item.from.file));
|
|
105
|
-
return {
|
|
106
|
-
from: fromProtocolCallHierarchyItem(item.from),
|
|
107
|
-
fromRanges: item.fromSpans.map(fromSpan => ({
|
|
108
|
-
start: document.positionAt(fromSpan.start),
|
|
109
|
-
end: document.positionAt(fromSpan.start + fromSpan.length),
|
|
110
|
-
})),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function fromProtocolCallHierarchyOutgoingCall(item, document) {
|
|
114
|
-
return {
|
|
115
|
-
to: fromProtocolCallHierarchyItem(item.to),
|
|
116
|
-
fromRanges: item.fromSpans.map(fromSpan => ({
|
|
117
|
-
start: document.positionAt(fromSpan.start),
|
|
118
|
-
end: document.positionAt(fromSpan.start + fromSpan.length),
|
|
119
|
-
})),
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.register = register;
|
|
124
|
-
;
|
|
125
|
-
//# sourceMappingURL=callHierarchy.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type * as vscode from '@volar/language-service';
|
|
2
|
-
import { SharedContext } from '../types';
|
|
3
|
-
export interface FixAllData {
|
|
4
|
-
type: 'fixAll';
|
|
5
|
-
uri: string;
|
|
6
|
-
fileName: string;
|
|
7
|
-
fixIds: {}[];
|
|
8
|
-
}
|
|
9
|
-
export interface RefactorData {
|
|
10
|
-
type: 'refactor';
|
|
11
|
-
uri: string;
|
|
12
|
-
fileName: string;
|
|
13
|
-
refactorName: string;
|
|
14
|
-
actionName: string;
|
|
15
|
-
range: {
|
|
16
|
-
pos: number;
|
|
17
|
-
end: number;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export interface OrganizeImportsData {
|
|
21
|
-
type: 'organizeImports';
|
|
22
|
-
uri: string;
|
|
23
|
-
fileName: string;
|
|
24
|
-
}
|
|
25
|
-
export type Data = FixAllData | RefactorData | OrganizeImportsData;
|
|
26
|
-
export declare function register(ctx: SharedContext): (uri: string, range: vscode.Range, context: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|