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