@typescript/native-preview 7.0.0-dev.20260422.1 → 7.0.0-dev.20260423.1
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/dist/api/async/api.d.ts +241 -0
- package/dist/api/async/api.d.ts.map +1 -0
- package/dist/api/async/api.js +810 -0
- package/dist/api/async/api.js.map +1 -0
- package/dist/api/async/client.d.ts +22 -0
- package/dist/api/async/client.d.ts.map +1 -0
- package/dist/api/async/client.js +140 -0
- package/dist/api/async/client.js.map +1 -0
- package/dist/api/async/types.d.ts +179 -0
- package/dist/api/async/types.d.ts.map +1 -0
- package/dist/api/async/types.js +2 -0
- package/dist/api/async/types.js.map +1 -0
- package/dist/api/fs.d.ts +23 -0
- package/dist/api/fs.d.ts.map +1 -0
- package/dist/api/fs.js +109 -0
- package/dist/api/fs.js.map +1 -0
- package/dist/api/node/encoder.d.ts +15 -0
- package/dist/api/node/encoder.d.ts.map +1 -0
- package/dist/api/node/encoder.generated.d.ts +5 -0
- package/dist/api/node/encoder.generated.d.ts.map +1 -0
- package/dist/api/node/encoder.generated.js +74 -0
- package/dist/api/node/encoder.generated.js.map +1 -0
- package/dist/api/node/encoder.js +304 -0
- package/dist/api/node/encoder.js.map +1 -0
- package/dist/api/node/msgpack.d.ts +32 -0
- package/dist/api/node/msgpack.d.ts.map +1 -0
- package/dist/api/node/msgpack.js +212 -0
- package/dist/api/node/msgpack.js.map +1 -0
- package/dist/api/node/node.d.ts +63 -0
- package/dist/api/node/node.d.ts.map +1 -0
- package/dist/api/node/node.generated.d.ts +172 -0
- package/dist/api/node/node.generated.d.ts.map +1 -0
- package/dist/api/node/node.generated.js +817 -0
- package/dist/api/node/node.generated.js.map +1 -0
- package/dist/api/node/node.infrastructure.d.ts +51 -0
- package/dist/api/node/node.infrastructure.d.ts.map +1 -0
- package/dist/api/node/node.infrastructure.js +122 -0
- package/dist/api/node/node.infrastructure.js.map +1 -0
- package/dist/api/node/node.js +201 -0
- package/dist/api/node/node.js.map +1 -0
- package/dist/api/node/protocol.d.ts +29 -0
- package/dist/api/node/protocol.d.ts.map +1 -0
- package/dist/api/node/protocol.generated.d.ts +4 -0
- package/dist/api/node/protocol.generated.d.ts.map +1 -0
- package/dist/api/node/protocol.generated.js +241 -0
- package/dist/api/node/protocol.generated.js.map +1 -0
- package/dist/api/node/protocol.js +30 -0
- package/dist/api/node/protocol.js.map +1 -0
- package/dist/api/objectRegistry.d.ts +38 -0
- package/dist/api/objectRegistry.d.ts.map +1 -0
- package/dist/api/objectRegistry.js +55 -0
- package/dist/api/objectRegistry.js.map +1 -0
- package/dist/api/options.d.ts +24 -0
- package/dist/api/options.d.ts.map +1 -0
- package/dist/api/options.js +11 -0
- package/dist/api/options.js.map +1 -0
- package/dist/api/path.d.ts +110 -0
- package/dist/api/path.d.ts.map +1 -0
- package/dist/api/path.js +508 -0
- package/dist/api/path.js.map +1 -0
- package/dist/api/proto.d.ts +152 -0
- package/dist/api/proto.d.ts.map +1 -0
- package/dist/api/proto.js +22 -0
- package/dist/api/proto.js.map +1 -0
- package/dist/api/sourceFileCache.d.ts +79 -0
- package/dist/api/sourceFileCache.d.ts.map +1 -0
- package/dist/api/sourceFileCache.js +169 -0
- package/dist/api/sourceFileCache.js.map +1 -0
- package/dist/api/sync/api.d.ts +241 -0
- package/dist/api/sync/api.d.ts.map +1 -0
- package/dist/api/sync/api.js +818 -0
- package/dist/api/sync/api.js.map +1 -0
- package/dist/api/sync/client.d.ts +13 -0
- package/dist/api/sync/client.d.ts.map +1 -0
- package/dist/api/sync/client.js +72 -0
- package/dist/api/sync/client.js.map +1 -0
- package/dist/api/sync/types.d.ts +179 -0
- package/dist/api/sync/types.d.ts.map +1 -0
- package/dist/api/sync/types.js +2 -0
- package/dist/api/sync/types.js.map +1 -0
- package/dist/api/syncChannel.d.ts +111 -0
- package/dist/api/syncChannel.d.ts.map +1 -0
- package/dist/api/syncChannel.js +488 -0
- package/dist/api/syncChannel.js.map +1 -0
- package/dist/ast/ast.d.ts +66 -0
- package/dist/ast/ast.d.ts.map +1 -0
- package/dist/ast/ast.generated.d.ts +1160 -0
- package/dist/ast/ast.generated.d.ts.map +1 -0
- package/dist/ast/ast.generated.js +4 -0
- package/dist/ast/ast.generated.js.map +1 -0
- package/dist/ast/ast.js +7 -0
- package/dist/ast/ast.js.map +1 -0
- package/dist/ast/astnav.d.ts +19 -0
- package/dist/ast/astnav.d.ts.map +1 -0
- package/dist/ast/astnav.js +596 -0
- package/dist/ast/astnav.js.map +1 -0
- package/dist/ast/clone.d.ts +16 -0
- package/dist/ast/clone.d.ts.map +1 -0
- package/dist/ast/clone.js +104 -0
- package/dist/ast/clone.js.map +1 -0
- package/dist/ast/factory.generated.d.ts +513 -0
- package/dist/ast/factory.generated.d.ts.map +1 -0
- package/dist/ast/factory.generated.js +3026 -0
- package/dist/ast/factory.generated.js.map +1 -0
- package/dist/ast/index.d.ts +18 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +18 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/ast/is.d.ts +34 -0
- package/dist/ast/is.d.ts.map +1 -0
- package/dist/ast/is.generated.d.ts +328 -0
- package/dist/ast/is.generated.d.ts.map +1 -0
- package/dist/ast/is.generated.js +1101 -0
- package/dist/ast/is.generated.js.map +1 -0
- package/dist/ast/is.js +226 -0
- package/dist/ast/is.js.map +1 -0
- package/dist/ast/scanner.d.ts +97 -0
- package/dist/ast/scanner.d.ts.map +1 -0
- package/dist/ast/scanner.js +2230 -0
- package/dist/ast/scanner.js.map +1 -0
- package/dist/ast/utils.d.ts +5 -0
- package/dist/ast/utils.d.ts.map +1 -0
- package/dist/ast/utils.js +27 -0
- package/dist/ast/utils.js.map +1 -0
- package/dist/ast/visitor.d.ts +14 -0
- package/dist/ast/visitor.d.ts.map +1 -0
- package/dist/ast/visitor.generated.d.ts +50 -0
- package/dist/ast/visitor.generated.d.ts.map +1 -0
- package/dist/ast/visitor.generated.js +978 -0
- package/dist/ast/visitor.generated.js.map +1 -0
- package/dist/ast/visitor.js +47 -0
- package/dist/ast/visitor.js.map +1 -0
- package/dist/enums/characterCodes.d.ts +2 -0
- package/dist/enums/characterCodes.d.ts.map +1 -0
- package/dist/enums/characterCodes.enum.d.ts +129 -0
- package/dist/enums/characterCodes.enum.d.ts.map +1 -0
- package/dist/enums/characterCodes.enum.js +132 -0
- package/dist/enums/characterCodes.enum.js.map +1 -0
- package/dist/enums/characterCodes.js +130 -0
- package/dist/enums/characterCodes.js.map +1 -0
- package/dist/enums/commentDirectiveType.d.ts +2 -0
- package/dist/enums/commentDirectiveType.d.ts.map +1 -0
- package/dist/enums/commentDirectiveType.enum.d.ts +5 -0
- package/dist/enums/commentDirectiveType.enum.d.ts.map +1 -0
- package/dist/enums/commentDirectiveType.enum.js +6 -0
- package/dist/enums/commentDirectiveType.enum.js.map +1 -0
- package/dist/enums/commentDirectiveType.js +6 -0
- package/dist/enums/commentDirectiveType.js.map +1 -0
- package/dist/enums/diagnosticCategory.d.ts +2 -0
- package/dist/enums/diagnosticCategory.d.ts.map +1 -0
- package/dist/enums/diagnosticCategory.enum.d.ts +7 -0
- package/dist/enums/diagnosticCategory.enum.d.ts.map +1 -0
- package/dist/enums/diagnosticCategory.enum.js +9 -0
- package/dist/enums/diagnosticCategory.enum.js.map +1 -0
- package/dist/enums/diagnosticCategory.js +9 -0
- package/dist/enums/diagnosticCategory.js.map +1 -0
- package/dist/enums/elementFlags.d.ts +2 -0
- package/dist/enums/elementFlags.d.ts.map +1 -0
- package/dist/enums/elementFlags.enum.d.ts +12 -0
- package/dist/enums/elementFlags.enum.d.ts.map +1 -0
- package/dist/enums/elementFlags.enum.js +14 -0
- package/dist/enums/elementFlags.enum.js.map +1 -0
- package/dist/enums/elementFlags.js +14 -0
- package/dist/enums/elementFlags.js.map +1 -0
- package/dist/enums/languageVariant.d.ts +2 -0
- package/dist/enums/languageVariant.d.ts.map +1 -0
- package/dist/enums/languageVariant.enum.d.ts +5 -0
- package/dist/enums/languageVariant.enum.d.ts.map +1 -0
- package/dist/enums/languageVariant.enum.js +6 -0
- package/dist/enums/languageVariant.enum.js.map +1 -0
- package/dist/enums/languageVariant.js +6 -0
- package/dist/enums/languageVariant.js.map +1 -0
- package/dist/enums/modifierFlags.d.ts +2 -0
- package/dist/enums/modifierFlags.d.ts.map +1 -0
- package/dist/enums/modifierFlags.enum.d.ts +42 -0
- package/dist/enums/modifierFlags.enum.d.ts.map +1 -0
- package/dist/enums/modifierFlags.enum.js +44 -0
- package/dist/enums/modifierFlags.enum.js.map +1 -0
- package/dist/enums/modifierFlags.js +44 -0
- package/dist/enums/modifierFlags.js.map +1 -0
- package/dist/enums/nodeFlags.d.ts +2 -0
- package/dist/enums/nodeFlags.d.ts.map +1 -0
- package/dist/enums/nodeFlags.enum.d.ts +41 -0
- package/dist/enums/nodeFlags.enum.d.ts.map +1 -0
- package/dist/enums/nodeFlags.enum.js +43 -0
- package/dist/enums/nodeFlags.enum.js.map +1 -0
- package/dist/enums/nodeFlags.js +43 -0
- package/dist/enums/nodeFlags.js.map +1 -0
- package/dist/enums/objectFlags.d.ts +2 -0
- package/dist/enums/objectFlags.d.ts.map +1 -0
- package/dist/enums/objectFlags.enum.d.ts +50 -0
- package/dist/enums/objectFlags.enum.d.ts.map +1 -0
- package/dist/enums/objectFlags.enum.js +52 -0
- package/dist/enums/objectFlags.enum.js.map +1 -0
- package/dist/enums/objectFlags.js +52 -0
- package/dist/enums/objectFlags.js.map +1 -0
- package/dist/enums/outerExpressionKinds.d.ts +2 -0
- package/dist/enums/outerExpressionKinds.d.ts.map +1 -0
- package/dist/enums/outerExpressionKinds.enum.d.ts +12 -0
- package/dist/enums/outerExpressionKinds.enum.d.ts.map +1 -0
- package/dist/enums/outerExpressionKinds.enum.js +14 -0
- package/dist/enums/outerExpressionKinds.enum.js.map +1 -0
- package/dist/enums/outerExpressionKinds.js +14 -0
- package/dist/enums/outerExpressionKinds.js.map +1 -0
- package/dist/enums/regularExpressionFlags.d.ts +2 -0
- package/dist/enums/regularExpressionFlags.d.ts.map +1 -0
- package/dist/enums/regularExpressionFlags.enum.d.ts +13 -0
- package/dist/enums/regularExpressionFlags.enum.d.ts.map +1 -0
- package/dist/enums/regularExpressionFlags.enum.js +14 -0
- package/dist/enums/regularExpressionFlags.enum.js.map +1 -0
- package/dist/enums/regularExpressionFlags.js +14 -0
- package/dist/enums/regularExpressionFlags.js.map +1 -0
- package/dist/enums/scriptKind.d.ts +2 -0
- package/dist/enums/scriptKind.d.ts.map +1 -0
- package/dist/enums/scriptKind.enum.d.ts +11 -0
- package/dist/enums/scriptKind.enum.d.ts.map +1 -0
- package/dist/enums/scriptKind.enum.js +12 -0
- package/dist/enums/scriptKind.enum.js.map +1 -0
- package/dist/enums/scriptKind.js +12 -0
- package/dist/enums/scriptKind.js.map +1 -0
- package/dist/enums/scriptTarget.d.ts +2 -0
- package/dist/enums/scriptTarget.d.ts.map +1 -0
- package/dist/enums/scriptTarget.enum.d.ts +17 -0
- package/dist/enums/scriptTarget.enum.d.ts.map +1 -0
- package/dist/enums/scriptTarget.enum.js +18 -0
- package/dist/enums/scriptTarget.enum.js.map +1 -0
- package/dist/enums/scriptTarget.js +18 -0
- package/dist/enums/scriptTarget.js.map +1 -0
- package/dist/enums/signatureFlags.d.ts +2 -0
- package/dist/enums/signatureFlags.d.ts.map +1 -0
- package/dist/enums/signatureFlags.enum.d.ts +15 -0
- package/dist/enums/signatureFlags.enum.d.ts.map +1 -0
- package/dist/enums/signatureFlags.enum.js +17 -0
- package/dist/enums/signatureFlags.enum.js.map +1 -0
- package/dist/enums/signatureFlags.js +17 -0
- package/dist/enums/signatureFlags.js.map +1 -0
- package/dist/enums/signatureKind.d.ts +2 -0
- package/dist/enums/signatureKind.d.ts.map +1 -0
- package/dist/enums/signatureKind.enum.d.ts +5 -0
- package/dist/enums/signatureKind.enum.d.ts.map +1 -0
- package/dist/enums/signatureKind.enum.js +7 -0
- package/dist/enums/signatureKind.enum.js.map +1 -0
- package/dist/enums/signatureKind.js +7 -0
- package/dist/enums/signatureKind.js.map +1 -0
- package/dist/enums/symbolFlags.d.ts +2 -0
- package/dist/enums/symbolFlags.d.ts.map +1 -0
- package/dist/enums/symbolFlags.enum.d.ts +71 -0
- package/dist/enums/symbolFlags.enum.d.ts.map +1 -0
- package/dist/enums/symbolFlags.enum.js +73 -0
- package/dist/enums/symbolFlags.enum.js.map +1 -0
- package/dist/enums/symbolFlags.js +73 -0
- package/dist/enums/symbolFlags.js.map +1 -0
- package/dist/enums/syntaxKind.d.ts +2 -0
- package/dist/enums/syntaxKind.d.ts.map +1 -0
- package/dist/enums/syntaxKind.enum.d.ts +389 -0
- package/dist/enums/syntaxKind.enum.d.ts.map +1 -0
- package/dist/enums/syntaxKind.enum.js +391 -0
- package/dist/enums/syntaxKind.enum.js.map +1 -0
- package/dist/enums/syntaxKind.js +391 -0
- package/dist/enums/syntaxKind.js.map +1 -0
- package/dist/enums/tokenFlags.d.ts +2 -0
- package/dist/enums/tokenFlags.d.ts.map +1 -0
- package/dist/enums/tokenFlags.enum.d.ts +30 -0
- package/dist/enums/tokenFlags.enum.d.ts.map +1 -0
- package/dist/enums/tokenFlags.enum.js +32 -0
- package/dist/enums/tokenFlags.enum.js.map +1 -0
- package/dist/enums/tokenFlags.js +32 -0
- package/dist/enums/tokenFlags.js.map +1 -0
- package/dist/enums/typeFlags.d.ts +2 -0
- package/dist/enums/typeFlags.d.ts.map +1 -0
- package/dist/enums/typeFlags.enum.d.ts +76 -0
- package/dist/enums/typeFlags.enum.d.ts.map +1 -0
- package/dist/enums/typeFlags.enum.js +78 -0
- package/dist/enums/typeFlags.enum.js.map +1 -0
- package/dist/enums/typeFlags.js +78 -0
- package/dist/enums/typeFlags.js.map +1 -0
- package/dist/enums/typePredicateKind.d.ts +2 -0
- package/dist/enums/typePredicateKind.d.ts.map +1 -0
- package/dist/enums/typePredicateKind.enum.d.ts +7 -0
- package/dist/enums/typePredicateKind.enum.d.ts.map +1 -0
- package/dist/enums/typePredicateKind.enum.js +9 -0
- package/dist/enums/typePredicateKind.enum.js.map +1 -0
- package/dist/enums/typePredicateKind.js +9 -0
- package/dist/enums/typePredicateKind.js.map +1 -0
- package/lib/getExePath.d.ts +2 -0
- package/package.json +57 -12
- package/vendor/vscode-jsonrpc/README.md +69 -0
- package/vendor/vscode-jsonrpc/lib/browser/main.d.ts +17 -0
- package/vendor/vscode-jsonrpc/lib/browser/main.js +83 -0
- package/vendor/vscode-jsonrpc/lib/browser/ril.d.ts +22 -0
- package/vendor/vscode-jsonrpc/lib/browser/ril.js +203 -0
- package/vendor/vscode-jsonrpc/lib/common/api.d.ts +14 -0
- package/vendor/vscode-jsonrpc/lib/common/api.js +87 -0
- package/vendor/vscode-jsonrpc/lib/common/cancellation.d.ts +32 -0
- package/vendor/vscode-jsonrpc/lib/common/cancellation.js +132 -0
- package/vendor/vscode-jsonrpc/lib/common/connection.d.ts +367 -0
- package/vendor/vscode-jsonrpc/lib/common/connection.js +1272 -0
- package/vendor/vscode-jsonrpc/lib/common/disposable.d.ts +9 -0
- package/vendor/vscode-jsonrpc/lib/common/disposable.js +16 -0
- package/vendor/vscode-jsonrpc/lib/common/encoding.d.ts +52 -0
- package/vendor/vscode-jsonrpc/lib/common/encoding.js +70 -0
- package/vendor/vscode-jsonrpc/lib/common/events.d.ts +39 -0
- package/vendor/vscode-jsonrpc/lib/common/events.js +136 -0
- package/vendor/vscode-jsonrpc/lib/common/is.d.ts +7 -0
- package/vendor/vscode-jsonrpc/lib/common/is.js +34 -0
- package/vendor/vscode-jsonrpc/lib/common/linkedMap.d.ts +55 -0
- package/vendor/vscode-jsonrpc/lib/common/linkedMap.js +412 -0
- package/vendor/vscode-jsonrpc/lib/common/messageBuffer.d.ts +18 -0
- package/vendor/vscode-jsonrpc/lib/common/messageBuffer.js +155 -0
- package/vendor/vscode-jsonrpc/lib/common/messageReader.d.ts +77 -0
- package/vendor/vscode-jsonrpc/lib/common/messageReader.js +246 -0
- package/vendor/vscode-jsonrpc/lib/common/messageWriter.d.ts +60 -0
- package/vendor/vscode-jsonrpc/lib/common/messageWriter.js +157 -0
- package/vendor/vscode-jsonrpc/lib/common/messages.d.ts +369 -0
- package/vendor/vscode-jsonrpc/lib/common/messages.js +436 -0
- package/vendor/vscode-jsonrpc/lib/common/ral.d.ts +74 -0
- package/vendor/vscode-jsonrpc/lib/common/ral.js +23 -0
- package/vendor/vscode-jsonrpc/lib/common/semaphore.d.ts +10 -0
- package/vendor/vscode-jsonrpc/lib/common/semaphore.js +74 -0
- package/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.d.ts +15 -0
- package/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +77 -0
- package/vendor/vscode-jsonrpc/lib/node/main.d.ts +58 -0
- package/vendor/vscode-jsonrpc/lib/node/main.js +289 -0
- package/vendor/vscode-jsonrpc/lib/node/ril.d.ts +12 -0
- package/vendor/vscode-jsonrpc/lib/node/ril.js +163 -0
- package/vendor/vscode-jsonrpc/package.json +54 -0
- package/vendor/vscode-jsonrpc/typings/thenable.d.ts +5 -0
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
/// <reference path="../node/node.ts" preserve="true" />
|
|
2
|
+
import { DiagnosticCategory } from "#enums/diagnosticCategory";
|
|
3
|
+
import { ElementFlags } from "#enums/elementFlags";
|
|
4
|
+
import { ObjectFlags } from "#enums/objectFlags";
|
|
5
|
+
import { SignatureFlags } from "#enums/signatureFlags";
|
|
6
|
+
import { SignatureKind } from "#enums/signatureKind";
|
|
7
|
+
import { SymbolFlags } from "#enums/symbolFlags";
|
|
8
|
+
import { TypeFlags } from "#enums/typeFlags";
|
|
9
|
+
import { TypePredicateKind } from "#enums/typePredicateKind";
|
|
10
|
+
import { ModifierFlags, } from "../../ast/index.js";
|
|
11
|
+
import { encodeNode, uint8ArrayToBase64, } from "../node/encoder.js";
|
|
12
|
+
import { decodeNode, findDescendant, getNodeId, parseNodeHandle, readParseOptionsKey, readSourceFileHash, RemoteSourceFile, } from "../node/node.js";
|
|
13
|
+
import { ObjectRegistry } from "../objectRegistry.js";
|
|
14
|
+
import { createGetCanonicalFileName, toPath, } from "../path.js";
|
|
15
|
+
import { resolveFileName } from "../proto.js";
|
|
16
|
+
import { SourceFileCache } from "../sourceFileCache.js";
|
|
17
|
+
import { Client, } from "./client.js";
|
|
18
|
+
export { DiagnosticCategory, ElementFlags, ModifierFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind };
|
|
19
|
+
export { documentURIToFileName, fileNameToDocumentURI } from "../path.js";
|
|
20
|
+
export class API {
|
|
21
|
+
client;
|
|
22
|
+
sourceFileCache;
|
|
23
|
+
toPath;
|
|
24
|
+
initialized = false;
|
|
25
|
+
activeSnapshots = new Set();
|
|
26
|
+
latestSnapshot;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.client = new Client(options);
|
|
29
|
+
this.sourceFileCache = new SourceFileCache();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create an API instance from an existing LSP connection's API session.
|
|
33
|
+
* Use this when connecting to an API pipe provided by an LSP server via custom/initializeAPISession.
|
|
34
|
+
*/
|
|
35
|
+
static async fromLSPConnection(options) {
|
|
36
|
+
const api = new API(options);
|
|
37
|
+
await api.ensureInitialized();
|
|
38
|
+
return api;
|
|
39
|
+
}
|
|
40
|
+
async ensureInitialized() {
|
|
41
|
+
if (!this.initialized) {
|
|
42
|
+
const response = await this.client.apiRequest("initialize", null);
|
|
43
|
+
const getCanonicalFileName = createGetCanonicalFileName(response.useCaseSensitiveFileNames);
|
|
44
|
+
const currentDirectory = response.currentDirectory;
|
|
45
|
+
this.toPath = (fileName) => toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
46
|
+
this.initialized = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async parseConfigFile(file) {
|
|
50
|
+
await this.ensureInitialized();
|
|
51
|
+
return this.client.apiRequest("parseConfigFile", { file });
|
|
52
|
+
}
|
|
53
|
+
async updateSnapshot(params) {
|
|
54
|
+
await this.ensureInitialized();
|
|
55
|
+
const requestParams = params ?? {};
|
|
56
|
+
if (requestParams.openProject) {
|
|
57
|
+
requestParams.openProject = resolveFileName(requestParams.openProject);
|
|
58
|
+
}
|
|
59
|
+
const data = await this.client.apiRequest("updateSnapshot", requestParams);
|
|
60
|
+
// Retain cached source files from previous snapshot for unchanged files
|
|
61
|
+
if (this.latestSnapshot) {
|
|
62
|
+
this.sourceFileCache.retainForSnapshot(data.snapshot, this.latestSnapshot.id, data.changes);
|
|
63
|
+
if (this.latestSnapshot.isDisposed()) {
|
|
64
|
+
this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const snapshot = new Snapshot(data, this.client, this.sourceFileCache, this.toPath, () => {
|
|
68
|
+
this.activeSnapshots.delete(snapshot);
|
|
69
|
+
if (snapshot !== this.latestSnapshot) {
|
|
70
|
+
this.sourceFileCache.releaseSnapshot(snapshot.id);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.latestSnapshot = snapshot;
|
|
74
|
+
this.activeSnapshots.add(snapshot);
|
|
75
|
+
return snapshot;
|
|
76
|
+
}
|
|
77
|
+
async close() {
|
|
78
|
+
// Dispose all active snapshots
|
|
79
|
+
for (const snapshot of [...this.activeSnapshots]) {
|
|
80
|
+
await snapshot.dispose();
|
|
81
|
+
}
|
|
82
|
+
// Release the latest snapshot's cache refs if still held
|
|
83
|
+
if (this.latestSnapshot) {
|
|
84
|
+
this.sourceFileCache.releaseSnapshot(this.latestSnapshot.id);
|
|
85
|
+
this.latestSnapshot = undefined;
|
|
86
|
+
}
|
|
87
|
+
await this.client.close();
|
|
88
|
+
this.sourceFileCache.clear();
|
|
89
|
+
}
|
|
90
|
+
clearSourceFileCache() {
|
|
91
|
+
this.sourceFileCache.clear();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export class Snapshot {
|
|
95
|
+
id;
|
|
96
|
+
projectMap;
|
|
97
|
+
toPath;
|
|
98
|
+
client;
|
|
99
|
+
objectRegistry;
|
|
100
|
+
disposed = false;
|
|
101
|
+
onDispose;
|
|
102
|
+
constructor(data, client, sourceFileCache, toPath, onDispose) {
|
|
103
|
+
this.id = data.snapshot;
|
|
104
|
+
this.client = client;
|
|
105
|
+
this.toPath = toPath;
|
|
106
|
+
this.onDispose = onDispose;
|
|
107
|
+
this.objectRegistry = new ObjectRegistry({
|
|
108
|
+
createSymbol: symbolData => new Symbol(symbolData, this.client, this.id, this.objectRegistry),
|
|
109
|
+
createType: typeData => new TypeObject(typeData, this.client, this.id, this.objectRegistry),
|
|
110
|
+
createSignature: sigData => new Signature(sigData, this.objectRegistry),
|
|
111
|
+
});
|
|
112
|
+
// Create projects
|
|
113
|
+
this.projectMap = new Map();
|
|
114
|
+
for (const projData of data.projects) {
|
|
115
|
+
const project = new Project(projData, this.id, client, this.objectRegistry, sourceFileCache, toPath);
|
|
116
|
+
this.projectMap.set(toPath(projData.configFileName), project);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getProjects() {
|
|
120
|
+
this.ensureNotDisposed();
|
|
121
|
+
return [...this.projectMap.values()];
|
|
122
|
+
}
|
|
123
|
+
getProject(configFileName) {
|
|
124
|
+
this.ensureNotDisposed();
|
|
125
|
+
return this.projectMap.get(this.toPath(configFileName));
|
|
126
|
+
}
|
|
127
|
+
async getDefaultProjectForFile(file) {
|
|
128
|
+
this.ensureNotDisposed();
|
|
129
|
+
const data = await this.client.apiRequest("getDefaultProjectForFile", {
|
|
130
|
+
snapshot: this.id,
|
|
131
|
+
file,
|
|
132
|
+
});
|
|
133
|
+
if (!data)
|
|
134
|
+
return undefined;
|
|
135
|
+
return this.projectMap.get(this.toPath(data.configFileName));
|
|
136
|
+
}
|
|
137
|
+
[globalThis.Symbol.dispose]() {
|
|
138
|
+
this.dispose();
|
|
139
|
+
}
|
|
140
|
+
async dispose() {
|
|
141
|
+
if (this.disposed)
|
|
142
|
+
return;
|
|
143
|
+
this.disposed = true;
|
|
144
|
+
this.objectRegistry.clear();
|
|
145
|
+
this.onDispose();
|
|
146
|
+
await this.client.apiRequest("release", { handle: this.id });
|
|
147
|
+
}
|
|
148
|
+
isDisposed() {
|
|
149
|
+
return this.disposed;
|
|
150
|
+
}
|
|
151
|
+
ensureNotDisposed() {
|
|
152
|
+
if (this.disposed) {
|
|
153
|
+
throw new Error("Snapshot is disposed");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export class Project {
|
|
158
|
+
id;
|
|
159
|
+
configFileName;
|
|
160
|
+
compilerOptions;
|
|
161
|
+
rootFiles;
|
|
162
|
+
program;
|
|
163
|
+
checker;
|
|
164
|
+
emitter;
|
|
165
|
+
client;
|
|
166
|
+
constructor(data, snapshotId, client, objectRegistry, sourceFileCache, toPath) {
|
|
167
|
+
this.id = data.id;
|
|
168
|
+
this.configFileName = data.configFileName;
|
|
169
|
+
this.compilerOptions = data.compilerOptions;
|
|
170
|
+
this.rootFiles = data.rootFiles;
|
|
171
|
+
this.client = client;
|
|
172
|
+
this.program = new Program(snapshotId, this.id, client, sourceFileCache, toPath);
|
|
173
|
+
this.checker = new Checker(snapshotId, this.id, client, objectRegistry);
|
|
174
|
+
this.emitter = new Emitter(client);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
export class Program {
|
|
178
|
+
snapshotId;
|
|
179
|
+
projectId;
|
|
180
|
+
client;
|
|
181
|
+
sourceFileCache;
|
|
182
|
+
toPath;
|
|
183
|
+
decoder = new TextDecoder();
|
|
184
|
+
constructor(snapshotId, projectId, client, sourceFileCache, toPath) {
|
|
185
|
+
this.snapshotId = snapshotId;
|
|
186
|
+
this.projectId = projectId;
|
|
187
|
+
this.client = client;
|
|
188
|
+
this.sourceFileCache = sourceFileCache;
|
|
189
|
+
this.toPath = toPath;
|
|
190
|
+
}
|
|
191
|
+
async getSourceFile(file) {
|
|
192
|
+
const fileName = resolveFileName(file);
|
|
193
|
+
const path = this.toPath(fileName);
|
|
194
|
+
// Check if we already have a retained cache entry for this (snapshot, project) pair
|
|
195
|
+
const retained = this.sourceFileCache.getRetained(path, this.snapshotId, this.projectId);
|
|
196
|
+
if (retained) {
|
|
197
|
+
return retained;
|
|
198
|
+
}
|
|
199
|
+
// Fetch from server
|
|
200
|
+
const binaryData = await this.client.apiRequestBinary("getSourceFile", {
|
|
201
|
+
snapshot: this.snapshotId,
|
|
202
|
+
project: this.projectId,
|
|
203
|
+
file,
|
|
204
|
+
});
|
|
205
|
+
if (!binaryData) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
const view = new DataView(binaryData.buffer, binaryData.byteOffset, binaryData.byteLength);
|
|
209
|
+
const contentHash = readSourceFileHash(view);
|
|
210
|
+
const parseOptionsKey = readParseOptionsKey(view);
|
|
211
|
+
// Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
|
|
212
|
+
const sourceFile = new RemoteSourceFile(binaryData, this.decoder);
|
|
213
|
+
return this.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.projectId);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get syntactic (parse) diagnostics for a specific file or all files.
|
|
217
|
+
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
218
|
+
*/
|
|
219
|
+
async getSyntacticDiagnostics(file) {
|
|
220
|
+
const data = await this.client.apiRequest("getSyntacticDiagnostics", {
|
|
221
|
+
snapshot: this.snapshotId,
|
|
222
|
+
project: this.projectId,
|
|
223
|
+
...(file !== undefined ? { file } : {}),
|
|
224
|
+
});
|
|
225
|
+
return data ?? [];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get semantic (type-check) diagnostics for a specific file or all files.
|
|
229
|
+
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
230
|
+
*/
|
|
231
|
+
async getSemanticDiagnostics(file) {
|
|
232
|
+
const data = await this.client.apiRequest("getSemanticDiagnostics", {
|
|
233
|
+
snapshot: this.snapshotId,
|
|
234
|
+
project: this.projectId,
|
|
235
|
+
...(file !== undefined ? { file } : {}),
|
|
236
|
+
});
|
|
237
|
+
return data ?? [];
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get suggestion diagnostics for a specific file or all files.
|
|
241
|
+
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
242
|
+
*/
|
|
243
|
+
async getSuggestionDiagnostics(file) {
|
|
244
|
+
const data = await this.client.apiRequest("getSuggestionDiagnostics", {
|
|
245
|
+
snapshot: this.snapshotId,
|
|
246
|
+
project: this.projectId,
|
|
247
|
+
...(file !== undefined ? { file } : {}),
|
|
248
|
+
});
|
|
249
|
+
return data ?? [];
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get declaration emit diagnostics for a specific file or all files.
|
|
253
|
+
* @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
|
|
254
|
+
*/
|
|
255
|
+
async getDeclarationDiagnostics(file) {
|
|
256
|
+
const data = await this.client.apiRequest("getDeclarationDiagnostics", {
|
|
257
|
+
snapshot: this.snapshotId,
|
|
258
|
+
project: this.projectId,
|
|
259
|
+
...(file !== undefined ? { file } : {}),
|
|
260
|
+
});
|
|
261
|
+
return data ?? [];
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get config file parsing diagnostics for the project.
|
|
265
|
+
*/
|
|
266
|
+
async getConfigFileParsingDiagnostics() {
|
|
267
|
+
const data = await this.client.apiRequest("getConfigFileParsingDiagnostics", {
|
|
268
|
+
snapshot: this.snapshotId,
|
|
269
|
+
project: this.projectId,
|
|
270
|
+
});
|
|
271
|
+
return data ?? [];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
export class Checker {
|
|
275
|
+
snapshotId;
|
|
276
|
+
projectId;
|
|
277
|
+
client;
|
|
278
|
+
objectRegistry;
|
|
279
|
+
constructor(snapshotId, projectId, client, objectRegistry) {
|
|
280
|
+
this.snapshotId = snapshotId;
|
|
281
|
+
this.projectId = projectId;
|
|
282
|
+
this.client = client;
|
|
283
|
+
this.objectRegistry = objectRegistry;
|
|
284
|
+
}
|
|
285
|
+
async getSymbolAtLocation(nodeOrNodes) {
|
|
286
|
+
if (Array.isArray(nodeOrNodes)) {
|
|
287
|
+
const data = await this.client.apiRequest("getSymbolsAtLocations", {
|
|
288
|
+
snapshot: this.snapshotId,
|
|
289
|
+
project: this.projectId,
|
|
290
|
+
locations: nodeOrNodes.map(node => getNodeId(node)),
|
|
291
|
+
});
|
|
292
|
+
return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
293
|
+
}
|
|
294
|
+
const data = await this.client.apiRequest("getSymbolAtLocation", {
|
|
295
|
+
snapshot: this.snapshotId,
|
|
296
|
+
project: this.projectId,
|
|
297
|
+
location: getNodeId(nodeOrNodes),
|
|
298
|
+
});
|
|
299
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
300
|
+
}
|
|
301
|
+
async getSymbolAtPosition(file, positionOrPositions) {
|
|
302
|
+
if (typeof positionOrPositions === "number") {
|
|
303
|
+
const data = await this.client.apiRequest("getSymbolAtPosition", {
|
|
304
|
+
snapshot: this.snapshotId,
|
|
305
|
+
project: this.projectId,
|
|
306
|
+
file,
|
|
307
|
+
position: positionOrPositions,
|
|
308
|
+
});
|
|
309
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
310
|
+
}
|
|
311
|
+
const data = await this.client.apiRequest("getSymbolsAtPositions", {
|
|
312
|
+
snapshot: this.snapshotId,
|
|
313
|
+
project: this.projectId,
|
|
314
|
+
file,
|
|
315
|
+
positions: positionOrPositions,
|
|
316
|
+
});
|
|
317
|
+
return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
|
|
318
|
+
}
|
|
319
|
+
async getTypeOfSymbol(symbolOrSymbols) {
|
|
320
|
+
if (Array.isArray(symbolOrSymbols)) {
|
|
321
|
+
const data = await this.client.apiRequest("getTypesOfSymbols", {
|
|
322
|
+
snapshot: this.snapshotId,
|
|
323
|
+
project: this.projectId,
|
|
324
|
+
symbols: symbolOrSymbols.map(s => s.id),
|
|
325
|
+
});
|
|
326
|
+
return data.map(d => d ? this.objectRegistry.getOrCreateType(d) : undefined);
|
|
327
|
+
}
|
|
328
|
+
const data = await this.client.apiRequest("getTypeOfSymbol", {
|
|
329
|
+
snapshot: this.snapshotId,
|
|
330
|
+
project: this.projectId,
|
|
331
|
+
symbol: symbolOrSymbols.id,
|
|
332
|
+
});
|
|
333
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
334
|
+
}
|
|
335
|
+
async getDeclaredTypeOfSymbol(symbol) {
|
|
336
|
+
const data = await this.client.apiRequest("getDeclaredTypeOfSymbol", {
|
|
337
|
+
snapshot: this.snapshotId,
|
|
338
|
+
project: this.projectId,
|
|
339
|
+
symbol: symbol.id,
|
|
340
|
+
});
|
|
341
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
342
|
+
}
|
|
343
|
+
async getTypeAtLocation(nodeOrNodes) {
|
|
344
|
+
if (Array.isArray(nodeOrNodes)) {
|
|
345
|
+
const data = await this.client.apiRequest("getTypeAtLocations", {
|
|
346
|
+
snapshot: this.snapshotId,
|
|
347
|
+
project: this.projectId,
|
|
348
|
+
locations: nodeOrNodes.map(node => getNodeId(node)),
|
|
349
|
+
});
|
|
350
|
+
return data.map(d => d ? this.objectRegistry.getOrCreateType(d) : undefined);
|
|
351
|
+
}
|
|
352
|
+
const data = await this.client.apiRequest("getTypeAtLocation", {
|
|
353
|
+
snapshot: this.snapshotId,
|
|
354
|
+
project: this.projectId,
|
|
355
|
+
location: getNodeId(nodeOrNodes),
|
|
356
|
+
});
|
|
357
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
358
|
+
}
|
|
359
|
+
async getSignaturesOfType(type, kind) {
|
|
360
|
+
const data = await this.client.apiRequest("getSignaturesOfType", {
|
|
361
|
+
snapshot: this.snapshotId,
|
|
362
|
+
project: this.projectId,
|
|
363
|
+
type: type.id,
|
|
364
|
+
kind,
|
|
365
|
+
});
|
|
366
|
+
return data.map(d => this.objectRegistry.getOrCreateSignature(d));
|
|
367
|
+
}
|
|
368
|
+
async getTypeAtPosition(file, positionOrPositions) {
|
|
369
|
+
if (typeof positionOrPositions === "number") {
|
|
370
|
+
const data = await this.client.apiRequest("getTypeAtPosition", {
|
|
371
|
+
snapshot: this.snapshotId,
|
|
372
|
+
project: this.projectId,
|
|
373
|
+
file,
|
|
374
|
+
position: positionOrPositions,
|
|
375
|
+
});
|
|
376
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
377
|
+
}
|
|
378
|
+
const data = await this.client.apiRequest("getTypesAtPositions", {
|
|
379
|
+
snapshot: this.snapshotId,
|
|
380
|
+
project: this.projectId,
|
|
381
|
+
file,
|
|
382
|
+
positions: positionOrPositions,
|
|
383
|
+
});
|
|
384
|
+
return data.map(d => d ? this.objectRegistry.getOrCreateType(d) : undefined);
|
|
385
|
+
}
|
|
386
|
+
async resolveName(name, meaning, location, excludeGlobals) {
|
|
387
|
+
// Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
|
|
388
|
+
const isNode = location && "kind" in location;
|
|
389
|
+
const data = await this.client.apiRequest("resolveName", {
|
|
390
|
+
snapshot: this.snapshotId,
|
|
391
|
+
project: this.projectId,
|
|
392
|
+
name,
|
|
393
|
+
meaning,
|
|
394
|
+
location: isNode ? getNodeId(location) : undefined,
|
|
395
|
+
file: !isNode && location ? location.document : undefined,
|
|
396
|
+
position: !isNode && location ? location.position : undefined,
|
|
397
|
+
excludeGlobals,
|
|
398
|
+
});
|
|
399
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
400
|
+
}
|
|
401
|
+
async getResolvedSymbol(node) {
|
|
402
|
+
const text = node.text;
|
|
403
|
+
if (!text)
|
|
404
|
+
return undefined;
|
|
405
|
+
return this.resolveName(text, SymbolFlags.Value | SymbolFlags.ExportValue, node);
|
|
406
|
+
}
|
|
407
|
+
async getContextualType(node) {
|
|
408
|
+
const data = await this.client.apiRequest("getContextualType", {
|
|
409
|
+
snapshot: this.snapshotId,
|
|
410
|
+
project: this.projectId,
|
|
411
|
+
location: getNodeId(node),
|
|
412
|
+
});
|
|
413
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
414
|
+
}
|
|
415
|
+
async getBaseTypeOfLiteralType(type) {
|
|
416
|
+
const data = await this.client.apiRequest("getBaseTypeOfLiteralType", {
|
|
417
|
+
snapshot: this.snapshotId,
|
|
418
|
+
project: this.projectId,
|
|
419
|
+
type: type.id,
|
|
420
|
+
});
|
|
421
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
422
|
+
}
|
|
423
|
+
async getShorthandAssignmentValueSymbol(node) {
|
|
424
|
+
const data = await this.client.apiRequest("getShorthandAssignmentValueSymbol", {
|
|
425
|
+
snapshot: this.snapshotId,
|
|
426
|
+
project: this.projectId,
|
|
427
|
+
location: getNodeId(node),
|
|
428
|
+
});
|
|
429
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
430
|
+
}
|
|
431
|
+
async getTypeOfSymbolAtLocation(symbol, location) {
|
|
432
|
+
const data = await this.client.apiRequest("getTypeOfSymbolAtLocation", {
|
|
433
|
+
snapshot: this.snapshotId,
|
|
434
|
+
project: this.projectId,
|
|
435
|
+
symbol: symbol.id,
|
|
436
|
+
location: getNodeId(location),
|
|
437
|
+
});
|
|
438
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
439
|
+
}
|
|
440
|
+
async getIntrinsicType(method) {
|
|
441
|
+
const data = await this.client.apiRequest(method, {
|
|
442
|
+
snapshot: this.snapshotId,
|
|
443
|
+
project: this.projectId,
|
|
444
|
+
});
|
|
445
|
+
return this.objectRegistry.getOrCreateType(data);
|
|
446
|
+
}
|
|
447
|
+
async getAnyType() {
|
|
448
|
+
return this.getIntrinsicType("getAnyType");
|
|
449
|
+
}
|
|
450
|
+
async getStringType() {
|
|
451
|
+
return this.getIntrinsicType("getStringType");
|
|
452
|
+
}
|
|
453
|
+
async getNumberType() {
|
|
454
|
+
return this.getIntrinsicType("getNumberType");
|
|
455
|
+
}
|
|
456
|
+
async getBooleanType() {
|
|
457
|
+
return this.getIntrinsicType("getBooleanType");
|
|
458
|
+
}
|
|
459
|
+
async getVoidType() {
|
|
460
|
+
return this.getIntrinsicType("getVoidType");
|
|
461
|
+
}
|
|
462
|
+
async getUndefinedType() {
|
|
463
|
+
return this.getIntrinsicType("getUndefinedType");
|
|
464
|
+
}
|
|
465
|
+
async getNullType() {
|
|
466
|
+
return this.getIntrinsicType("getNullType");
|
|
467
|
+
}
|
|
468
|
+
async getNeverType() {
|
|
469
|
+
return this.getIntrinsicType("getNeverType");
|
|
470
|
+
}
|
|
471
|
+
async getUnknownType() {
|
|
472
|
+
return this.getIntrinsicType("getUnknownType");
|
|
473
|
+
}
|
|
474
|
+
async getBigIntType() {
|
|
475
|
+
return this.getIntrinsicType("getBigIntType");
|
|
476
|
+
}
|
|
477
|
+
async getESSymbolType() {
|
|
478
|
+
return this.getIntrinsicType("getESSymbolType");
|
|
479
|
+
}
|
|
480
|
+
async typeToTypeNode(type, enclosingDeclaration, flags) {
|
|
481
|
+
const binaryData = await this.client.apiRequestBinary("typeToTypeNode", {
|
|
482
|
+
snapshot: this.snapshotId,
|
|
483
|
+
project: this.projectId,
|
|
484
|
+
type: type.id,
|
|
485
|
+
location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
|
|
486
|
+
flags,
|
|
487
|
+
});
|
|
488
|
+
if (!binaryData)
|
|
489
|
+
return undefined;
|
|
490
|
+
return decodeNode(binaryData);
|
|
491
|
+
}
|
|
492
|
+
async typeToString(type, enclosingDeclaration, flags) {
|
|
493
|
+
return this.client.apiRequest("typeToString", {
|
|
494
|
+
snapshot: this.snapshotId,
|
|
495
|
+
project: this.projectId,
|
|
496
|
+
type: type.id,
|
|
497
|
+
location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
|
|
498
|
+
flags,
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
async isContextSensitive(node) {
|
|
502
|
+
return this.client.apiRequest("isContextSensitive", {
|
|
503
|
+
snapshot: this.snapshotId,
|
|
504
|
+
project: this.projectId,
|
|
505
|
+
location: getNodeId(node),
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
async getReturnTypeOfSignature(signature) {
|
|
509
|
+
const data = await this.client.apiRequest("getReturnTypeOfSignature", {
|
|
510
|
+
snapshot: this.snapshotId,
|
|
511
|
+
project: this.projectId,
|
|
512
|
+
signature: signature.id,
|
|
513
|
+
});
|
|
514
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
515
|
+
}
|
|
516
|
+
async getRestTypeOfSignature(signature) {
|
|
517
|
+
const data = await this.client.apiRequest("getRestTypeOfSignature", {
|
|
518
|
+
snapshot: this.snapshotId,
|
|
519
|
+
project: this.projectId,
|
|
520
|
+
signature: signature.id,
|
|
521
|
+
});
|
|
522
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
523
|
+
}
|
|
524
|
+
async getTypePredicateOfSignature(signature) {
|
|
525
|
+
const data = await this.client.apiRequest("getTypePredicateOfSignature", {
|
|
526
|
+
snapshot: this.snapshotId,
|
|
527
|
+
project: this.projectId,
|
|
528
|
+
signature: signature.id,
|
|
529
|
+
});
|
|
530
|
+
if (!data)
|
|
531
|
+
return undefined;
|
|
532
|
+
return {
|
|
533
|
+
kind: data.kind,
|
|
534
|
+
parameterIndex: data.parameterIndex,
|
|
535
|
+
parameterName: data.parameterName,
|
|
536
|
+
type: data.type ? this.objectRegistry.getOrCreateType(data.type) : undefined,
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
async getBaseTypes(type) {
|
|
540
|
+
const data = await this.client.apiRequest("getBaseTypes", {
|
|
541
|
+
snapshot: this.snapshotId,
|
|
542
|
+
project: this.projectId,
|
|
543
|
+
type: type.id,
|
|
544
|
+
});
|
|
545
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
|
|
546
|
+
}
|
|
547
|
+
async getPropertiesOfType(type) {
|
|
548
|
+
const data = await this.client.apiRequest("getPropertiesOfType", {
|
|
549
|
+
snapshot: this.snapshotId,
|
|
550
|
+
project: this.projectId,
|
|
551
|
+
type: type.id,
|
|
552
|
+
});
|
|
553
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
554
|
+
}
|
|
555
|
+
async getIndexInfosOfType(type) {
|
|
556
|
+
const data = await this.client.apiRequest("getIndexInfosOfType", {
|
|
557
|
+
snapshot: this.snapshotId,
|
|
558
|
+
project: this.projectId,
|
|
559
|
+
type: type.id,
|
|
560
|
+
});
|
|
561
|
+
if (!data)
|
|
562
|
+
return [];
|
|
563
|
+
return data.map(d => ({
|
|
564
|
+
keyType: this.objectRegistry.getOrCreateType(d.keyType),
|
|
565
|
+
valueType: this.objectRegistry.getOrCreateType(d.valueType),
|
|
566
|
+
isReadonly: d.isReadonly ?? false,
|
|
567
|
+
}));
|
|
568
|
+
}
|
|
569
|
+
async getConstraintOfTypeParameter(type) {
|
|
570
|
+
const data = await this.client.apiRequest("getConstraintOfTypeParameter", {
|
|
571
|
+
snapshot: this.snapshotId,
|
|
572
|
+
project: this.projectId,
|
|
573
|
+
type: type.id,
|
|
574
|
+
});
|
|
575
|
+
return data ? this.objectRegistry.getOrCreateType(data) : undefined;
|
|
576
|
+
}
|
|
577
|
+
async getTypeArguments(type) {
|
|
578
|
+
const data = await this.client.apiRequest("getTypeArguments", {
|
|
579
|
+
snapshot: this.snapshotId,
|
|
580
|
+
project: this.projectId,
|
|
581
|
+
type: type.id,
|
|
582
|
+
});
|
|
583
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
export class Emitter {
|
|
587
|
+
client;
|
|
588
|
+
constructor(client) {
|
|
589
|
+
this.client = client;
|
|
590
|
+
}
|
|
591
|
+
async printNode(node, options = {}) {
|
|
592
|
+
const encoded = encodeNode(node);
|
|
593
|
+
const base64 = uint8ArrayToBase64(encoded);
|
|
594
|
+
return this.client.apiRequest("printNode", {
|
|
595
|
+
data: base64,
|
|
596
|
+
...options,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
export class NodeHandle {
|
|
601
|
+
kind;
|
|
602
|
+
pos;
|
|
603
|
+
end;
|
|
604
|
+
path;
|
|
605
|
+
constructor(handle) {
|
|
606
|
+
const parsed = parseNodeHandle(handle);
|
|
607
|
+
this.pos = parsed.pos;
|
|
608
|
+
this.end = parsed.end;
|
|
609
|
+
this.kind = parsed.kind;
|
|
610
|
+
this.path = parsed.path;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Resolve this handle to the actual AST node by fetching the source file
|
|
614
|
+
* from the given project and finding the node at the stored position.
|
|
615
|
+
*/
|
|
616
|
+
async resolve(project) {
|
|
617
|
+
const sourceFile = await project.program.getSourceFile(this.path);
|
|
618
|
+
if (!sourceFile) {
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
// Find the node at the stored position with matching kind and end
|
|
622
|
+
return findDescendant(sourceFile, this.pos, this.end, this.kind);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
export class Symbol {
|
|
626
|
+
client;
|
|
627
|
+
snapshotId;
|
|
628
|
+
objectRegistry;
|
|
629
|
+
id;
|
|
630
|
+
name;
|
|
631
|
+
flags;
|
|
632
|
+
checkFlags;
|
|
633
|
+
declarations;
|
|
634
|
+
valueDeclaration;
|
|
635
|
+
constructor(data, client, snapshotId, objectRegistry) {
|
|
636
|
+
this.client = client;
|
|
637
|
+
this.snapshotId = snapshotId;
|
|
638
|
+
this.objectRegistry = objectRegistry;
|
|
639
|
+
this.id = data.id;
|
|
640
|
+
this.name = data.name;
|
|
641
|
+
this.flags = data.flags;
|
|
642
|
+
this.checkFlags = data.checkFlags;
|
|
643
|
+
this.declarations = (data.declarations ?? []).map(d => new NodeHandle(d));
|
|
644
|
+
this.valueDeclaration = data.valueDeclaration ? new NodeHandle(data.valueDeclaration) : undefined;
|
|
645
|
+
}
|
|
646
|
+
async getParent() {
|
|
647
|
+
const data = await this.client.apiRequest("getParentOfSymbol", { snapshot: this.snapshotId, symbol: this.id });
|
|
648
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
649
|
+
}
|
|
650
|
+
async getMembers() {
|
|
651
|
+
const data = await this.client.apiRequest("getMembersOfSymbol", { snapshot: this.snapshotId, symbol: this.id });
|
|
652
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
653
|
+
}
|
|
654
|
+
async getExports() {
|
|
655
|
+
const data = await this.client.apiRequest("getExportsOfSymbol", { snapshot: this.snapshotId, symbol: this.id });
|
|
656
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
|
|
657
|
+
}
|
|
658
|
+
async getExportSymbol() {
|
|
659
|
+
const data = await this.client.apiRequest("getExportSymbolOfSymbol", { snapshot: this.snapshotId, symbol: this.id });
|
|
660
|
+
return this.objectRegistry.getOrCreateSymbol(data);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
class TypeObject {
|
|
664
|
+
client;
|
|
665
|
+
snapshotId;
|
|
666
|
+
objectRegistry;
|
|
667
|
+
id;
|
|
668
|
+
flags;
|
|
669
|
+
objectFlags;
|
|
670
|
+
value;
|
|
671
|
+
target;
|
|
672
|
+
typeParameters;
|
|
673
|
+
outerTypeParameters;
|
|
674
|
+
localTypeParameters;
|
|
675
|
+
elementFlags;
|
|
676
|
+
fixedLength;
|
|
677
|
+
readonly;
|
|
678
|
+
texts;
|
|
679
|
+
objectType;
|
|
680
|
+
indexType;
|
|
681
|
+
checkType;
|
|
682
|
+
extendsType;
|
|
683
|
+
baseType;
|
|
684
|
+
substConstraint;
|
|
685
|
+
constructor(data, client, snapshotId, objectRegistry) {
|
|
686
|
+
this.client = client;
|
|
687
|
+
this.snapshotId = snapshotId;
|
|
688
|
+
this.objectRegistry = objectRegistry;
|
|
689
|
+
this.id = data.id;
|
|
690
|
+
this.flags = data.flags;
|
|
691
|
+
if (data.objectFlags !== undefined)
|
|
692
|
+
this.objectFlags = data.objectFlags;
|
|
693
|
+
if (data.value !== undefined)
|
|
694
|
+
this.value = data.value;
|
|
695
|
+
if (data.target !== undefined)
|
|
696
|
+
this.target = data.target;
|
|
697
|
+
if (data.typeParameters !== undefined)
|
|
698
|
+
this.typeParameters = data.typeParameters;
|
|
699
|
+
if (data.outerTypeParameters !== undefined)
|
|
700
|
+
this.outerTypeParameters = data.outerTypeParameters;
|
|
701
|
+
if (data.localTypeParameters !== undefined)
|
|
702
|
+
this.localTypeParameters = data.localTypeParameters;
|
|
703
|
+
if (data.elementFlags !== undefined)
|
|
704
|
+
this.elementFlags = data.elementFlags;
|
|
705
|
+
if (data.fixedLength !== undefined)
|
|
706
|
+
this.fixedLength = data.fixedLength;
|
|
707
|
+
if (data.readonly !== undefined)
|
|
708
|
+
this.readonly = data.readonly;
|
|
709
|
+
if (data.texts !== undefined)
|
|
710
|
+
this.texts = data.texts;
|
|
711
|
+
if (data.objectType !== undefined)
|
|
712
|
+
this.objectType = data.objectType;
|
|
713
|
+
if (data.indexType !== undefined)
|
|
714
|
+
this.indexType = data.indexType;
|
|
715
|
+
if (data.checkType !== undefined)
|
|
716
|
+
this.checkType = data.checkType;
|
|
717
|
+
if (data.extendsType !== undefined)
|
|
718
|
+
this.extendsType = data.extendsType;
|
|
719
|
+
if (data.baseType !== undefined)
|
|
720
|
+
this.baseType = data.baseType;
|
|
721
|
+
if (data.substConstraint !== undefined)
|
|
722
|
+
this.substConstraint = data.substConstraint;
|
|
723
|
+
}
|
|
724
|
+
async getSymbol() {
|
|
725
|
+
const data = await this.client.apiRequest("getSymbolOfType", { snapshot: this.snapshotId, type: this.id });
|
|
726
|
+
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
|
|
727
|
+
}
|
|
728
|
+
async fetchType(handle, method) {
|
|
729
|
+
const cached = handle ? this.objectRegistry.getType(handle) : undefined;
|
|
730
|
+
if (cached)
|
|
731
|
+
return cached;
|
|
732
|
+
const data = await this.client.apiRequest(method, { snapshot: this.snapshotId, type: this.id });
|
|
733
|
+
if (!data)
|
|
734
|
+
throw new Error(`${method} returned null for type ${this.id}`);
|
|
735
|
+
return this.objectRegistry.getOrCreateType(data);
|
|
736
|
+
}
|
|
737
|
+
async fetchTypes(method) {
|
|
738
|
+
const data = await this.client.apiRequest(method, { snapshot: this.snapshotId, type: this.id });
|
|
739
|
+
return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
|
|
740
|
+
}
|
|
741
|
+
async getTarget() {
|
|
742
|
+
return this.fetchType(this.target, "getTargetOfType");
|
|
743
|
+
}
|
|
744
|
+
async getTypes() {
|
|
745
|
+
return this.fetchTypes("getTypesOfType");
|
|
746
|
+
}
|
|
747
|
+
async getTypeParameters() {
|
|
748
|
+
return this.fetchTypes("getTypeParametersOfType");
|
|
749
|
+
}
|
|
750
|
+
async getOuterTypeParameters() {
|
|
751
|
+
return this.fetchTypes("getOuterTypeParametersOfType");
|
|
752
|
+
}
|
|
753
|
+
async getLocalTypeParameters() {
|
|
754
|
+
return this.fetchTypes("getLocalTypeParametersOfType");
|
|
755
|
+
}
|
|
756
|
+
async getObjectType() {
|
|
757
|
+
return this.fetchType(this.objectType, "getObjectTypeOfType");
|
|
758
|
+
}
|
|
759
|
+
async getIndexType() {
|
|
760
|
+
return this.fetchType(this.indexType, "getIndexTypeOfType");
|
|
761
|
+
}
|
|
762
|
+
async getCheckType() {
|
|
763
|
+
return this.fetchType(this.checkType, "getCheckTypeOfType");
|
|
764
|
+
}
|
|
765
|
+
async getExtendsType() {
|
|
766
|
+
return this.fetchType(this.extendsType, "getExtendsTypeOfType");
|
|
767
|
+
}
|
|
768
|
+
async getBaseType() {
|
|
769
|
+
return this.fetchType(this.baseType, "getBaseTypeOfType");
|
|
770
|
+
}
|
|
771
|
+
async getConstraint() {
|
|
772
|
+
return this.fetchType(this.substConstraint, "getConstraintOfType");
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
export class Signature {
|
|
776
|
+
flags;
|
|
777
|
+
id;
|
|
778
|
+
declaration;
|
|
779
|
+
typeParameters;
|
|
780
|
+
parameters;
|
|
781
|
+
thisParameter;
|
|
782
|
+
target;
|
|
783
|
+
constructor(data, objectRegistry) {
|
|
784
|
+
this.id = data.id;
|
|
785
|
+
this.flags = data.flags;
|
|
786
|
+
this.declaration = data.declaration ? new NodeHandle(data.declaration) : undefined;
|
|
787
|
+
this.typeParameters = (data.typeParameters ?? []).map(id => {
|
|
788
|
+
return objectRegistry.getOrCreateType({ id, flags: 0 });
|
|
789
|
+
});
|
|
790
|
+
this.parameters = (data.parameters ?? []).map(id => {
|
|
791
|
+
return objectRegistry.getOrCreateSymbol({ id, name: "", flags: 0, checkFlags: 0 });
|
|
792
|
+
});
|
|
793
|
+
this.thisParameter = data.thisParameter
|
|
794
|
+
? objectRegistry.getOrCreateSymbol({ id: data.thisParameter, name: "", flags: 0, checkFlags: 0 })
|
|
795
|
+
: undefined;
|
|
796
|
+
this.target = data.target
|
|
797
|
+
? objectRegistry.getOrCreateSignature({ id: data.target, flags: 0 })
|
|
798
|
+
: undefined;
|
|
799
|
+
}
|
|
800
|
+
get hasRestParameter() {
|
|
801
|
+
return (this.flags & SignatureFlags.HasRestParameter) !== 0;
|
|
802
|
+
}
|
|
803
|
+
get isConstruct() {
|
|
804
|
+
return (this.flags & SignatureFlags.Construct) !== 0;
|
|
805
|
+
}
|
|
806
|
+
get isAbstract() {
|
|
807
|
+
return (this.flags & SignatureFlags.Abstract) !== 0;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
//# sourceMappingURL=api.js.map
|