|
1 | 1 | /// <reference path="../node/node.ts" preserve="true" /> |
2 | 2 | import { DiagnosticCategory } from "#enums/diagnosticCategory"; |
3 | 3 | import { ElementFlags } from "#enums/elementFlags"; |
| 4 | +import { NodeBuilderFlags } from "#enums/nodeBuilderFlags"; |
4 | 5 | import { ObjectFlags } from "#enums/objectFlags"; |
5 | 6 | import { SignatureFlags } from "#enums/signatureFlags"; |
6 | 7 | import { SignatureKind } from "#enums/signatureKind"; |
@@ -88,7 +89,7 @@ import type { |
88 | 89 | UnionType, |
89 | 90 | } from "./types.ts"; |
90 | 91 |
|
91 | | -export { DiagnosticCategory, ElementFlags, ModifierFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind }; |
| 92 | +export { DiagnosticCategory, ElementFlags, ModifierFlags, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind }; |
92 | 93 | export type { APIOptions, ClientSocketOptions, ClientSpawnOptions, DocumentIdentifier, DocumentPosition, LSPConnectionOptions }; |
93 | 94 | export type { AssertsIdentifierTypePredicate, AssertsThisTypePredicate, ConditionalType, Diagnostic, IdentifierTypePredicate, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, LiteralType, ObjectType, StringMappingType, SubstitutionType, TemplateLiteralType, ThisTypePredicate, TupleType, Type, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType }; |
94 | 95 | export { documentURIToFileName, fileNameToDocumentURI } from "../path.ts"; |
@@ -538,6 +539,15 @@ export class Checker { |
538 | 539 | return data.map(d => this.objectRegistry.getOrCreateSignature(d)); |
539 | 540 | } |
540 | 541 |
|
| 542 | + async getResolvedSignature(node: Node): Promise<Signature | undefined> { |
| 543 | + const data = await this.client.apiRequest<SignatureResponse | null>("getResolvedSignature", { |
| 544 | + snapshot: this.snapshotId, |
| 545 | + project: this.projectId, |
| 546 | + location: getNodeId(node), |
| 547 | + }); |
| 548 | + return data ? this.objectRegistry.getOrCreateSignature(data) : undefined; |
| 549 | + } |
| 550 | + |
541 | 551 | getTypeAtPosition(file: DocumentIdentifier, position: number): Promise<Type | undefined>; |
542 | 552 | getTypeAtPosition(file: DocumentIdentifier, positions: readonly number[]): Promise<(Type | undefined)[]>; |
543 | 553 | async getTypeAtPosition(file: DocumentIdentifier, positionOrPositions: number | readonly number[]): Promise<Type | (Type | undefined)[] | undefined> { |
@@ -604,6 +614,51 @@ export class Checker { |
604 | 614 | return data ? this.objectRegistry.getOrCreateType(data) : undefined; |
605 | 615 | } |
606 | 616 |
|
| 617 | + async getNonNullableType(type: Type): Promise<Type | undefined> { |
| 618 | + const data = await this.client.apiRequest<TypeResponse | null>("getNonNullableType", { |
| 619 | + snapshot: this.snapshotId, |
| 620 | + project: this.projectId, |
| 621 | + type: type.id, |
| 622 | + }); |
| 623 | + return data ? this.objectRegistry.getOrCreateType(data) : undefined; |
| 624 | + } |
| 625 | + |
| 626 | + async getTypeFromTypeNode(node: TypeNode): Promise<Type | undefined> { |
| 627 | + const data = await this.client.apiRequest<TypeResponse | null>("getTypeFromTypeNode", { |
| 628 | + snapshot: this.snapshotId, |
| 629 | + project: this.projectId, |
| 630 | + location: getNodeId(node), |
| 631 | + }); |
| 632 | + return data ? this.objectRegistry.getOrCreateType(data) : undefined; |
| 633 | + } |
| 634 | + |
| 635 | + async getWidenedType(type: Type): Promise<Type | undefined> { |
| 636 | + const data = await this.client.apiRequest<TypeResponse | null>("getWidenedType", { |
| 637 | + snapshot: this.snapshotId, |
| 638 | + project: this.projectId, |
| 639 | + type: type.id, |
| 640 | + }); |
| 641 | + return data ? this.objectRegistry.getOrCreateType(data) : undefined; |
| 642 | + } |
| 643 | + |
| 644 | + async getParameterType(signature: Signature, index: number): Promise<Type | undefined> { |
| 645 | + const data = await this.client.apiRequest<TypeResponse | null>("getParameterType", { |
| 646 | + snapshot: this.snapshotId, |
| 647 | + project: this.projectId, |
| 648 | + signature: signature.id, |
| 649 | + index, |
| 650 | + }); |
| 651 | + return data ? this.objectRegistry.getOrCreateType(data) : undefined; |
| 652 | + } |
| 653 | + |
| 654 | + async isArrayLikeType(type: Type): Promise<boolean> { |
| 655 | + return this.client.apiRequest<boolean>("isArrayLikeType", { |
| 656 | + snapshot: this.snapshotId, |
| 657 | + project: this.projectId, |
| 658 | + type: type.id, |
| 659 | + }); |
| 660 | + } |
| 661 | + |
607 | 662 | async getShorthandAssignmentValueSymbol(node: Node): Promise<Symbol | undefined> { |
608 | 663 | const data = await this.client.apiRequest<SymbolResponse | null>("getShorthandAssignmentValueSymbol", { |
609 | 664 | snapshot: this.snapshotId, |
@@ -677,6 +732,19 @@ export class Checker { |
677 | 732 | return decodeNode(binaryData) as TypeNode; |
678 | 733 | } |
679 | 734 |
|
| 735 | + async signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): Promise<Node | undefined> { |
| 736 | + const binaryData = await this.client.apiRequestBinary("signatureToSignatureDeclaration", { |
| 737 | + snapshot: this.snapshotId, |
| 738 | + project: this.projectId, |
| 739 | + signature: signature.id, |
| 740 | + kind, |
| 741 | + location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined, |
| 742 | + flags, |
| 743 | + }); |
| 744 | + if (!binaryData) return undefined; |
| 745 | + return decodeNode(binaryData) as Node; |
| 746 | + } |
| 747 | + |
680 | 748 | async typeToString(type: Type, enclosingDeclaration?: Node, flags?: number): Promise<string> { |
681 | 749 | return this.client.apiRequest<string>("typeToString", { |
682 | 750 | snapshot: this.snapshotId, |
|
0 commit comments