/// <reference path="../node/node.d.ts" preserve="true" />
import { CompletionItemKind } from "#enums/completionItemKind";
import { DiagnosticCategory } from "#enums/diagnosticCategory";
import { ElementFlags } from "#enums/elementFlags";
import { NodeBuilderFlags } from "#enums/nodeBuilderFlags";
import { ObjectFlags } from "#enums/objectFlags";
import { SignatureFlags } from "#enums/signatureFlags";
import { SignatureKind } from "#enums/signatureKind";
import { SymbolFlags } from "#enums/symbolFlags";
import { TypeFlags } from "#enums/typeFlags";
import { TypePredicateKind } from "#enums/typePredicateKind";
import { type Expression, type Identifier, ModifierFlags, type Node, type Path, type SourceFile, type SyntaxKind, type TypeNode } from "../../ast/index.ts";
import { type ObjectFactories, ObjectRegistry } from "../objectRegistry.ts";
import type { APIOptions, LSPConnectionOptions } from "../options.ts";
import type { ConfigResponse, DocumentIdentifier, DocumentPosition, LSPUpdateSnapshotParams, ProjectResponse, SignatureResponse, SymbolResponse, TypeResponse, UpdateSnapshotParams, UpdateSnapshotResponse } from "../proto.ts";
import { SourceFileCache } from "../sourceFileCache.ts";
import { Client, type ClientSocketOptions, type ClientSpawnOptions } from "./client.ts";
import type { AssertsIdentifierTypePredicate, AssertsThisTypePredicate, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, FreshableType, IdentifierTypePredicate, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, LiteralType, ObjectType, StringMappingType, SubstitutionType, TemplateLiteralType, ThisTypePredicate, TupleType, Type, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType } from "./types.ts";
export { CompletionItemKind, DiagnosticCategory, ElementFlags, ModifierFlags, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind };
export type { APIOptions, ClientSocketOptions, ClientSpawnOptions, DocumentIdentifier, DocumentPosition, LSPConnectionOptions };
export type { AssertsIdentifierTypePredicate, AssertsThisTypePredicate, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, FreshableType, IdentifierTypePredicate, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, LiteralType, ObjectType, StringMappingType, SubstitutionType, TemplateLiteralType, ThisTypePredicate, TupleType, Type, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType };
export { documentURIToFileName, fileNameToDocumentURI } from "../path.ts";
export declare class API<FromLSP extends boolean = false> {
    private client;
    private sourceFileCache;
    private toPath;
    private initialized;
    private activeSnapshots;
    private latestSnapshot;
    readonly internal: InternalAPI;
    constructor(options: APIOptions | LSPConnectionOptions);
    /**
     * Create an API instance from an existing LSP connection's API session.
     * Use this when connecting to an API pipe provided by an LSP server via custom/initializeAPISession.
     */
    static fromLSPConnection(options: LSPConnectionOptions): API<true>;
    private ensureInitialized;
    parseConfigFile(file: DocumentIdentifier): ConfigResponse;
    updateSnapshot(params?: FromLSP extends true ? LSPUpdateSnapshotParams : UpdateSnapshotParams): Snapshot;
    close(): void;
    clearSourceFileCache(): void;
}
export declare class InternalAPI {
    private client;
    private ensureInitialized;
    /** @internal */
    constructor(client: Client, ensureInitialized: () => void);
    startCPUProfile(dir: string): void;
    stopCPUProfile(): string;
    saveHeapProfile(dir: string): string;
}
export declare class Snapshot {
    readonly id: number;
    private projectMap;
    private toPath;
    private client;
    private objectRegistry;
    private disposed;
    private onDispose;
    constructor(data: UpdateSnapshotResponse, client: Client, sourceFileCache: SourceFileCache, toPath: (fileName: string) => Path, onDispose: () => void);
    getProjects(): readonly Project[];
    getProject(configFileName: string): Project | undefined;
    getDefaultProjectForFile(file: DocumentIdentifier): Project | undefined;
    [globalThis.Symbol.dispose](): void;
    dispose(): void;
    isDisposed(): boolean;
    private ensureNotDisposed;
}
declare class SnapshotObjectRegistry extends ObjectRegistry<Symbol, TypeObject, Signature> {
    private client;
    private snapshotId;
    constructor(factories: ObjectFactories<Symbol, TypeObject, Signature>, client: Client, snapshotId: number);
    fetchType<T extends Type>(source: Symbol | Signature | Type, method: string, handle: number | undefined): T;
    fetchSymbol(source: Symbol | Signature | Type, method: string, handle: number | undefined): Symbol;
    fetchSignature(source: Symbol | Signature | Type, method: string, handle: number | undefined): Signature;
    fetchTypes(source: Symbol | Signature | Type, method: string, handles?: readonly number[]): readonly Type[];
    fetchSymbols(source: Symbol | Signature | Type, method: string, handles?: readonly number[]): readonly Symbol[];
}
export declare class Project {
    readonly id: string;
    readonly configFileName: string;
    readonly compilerOptions: Record<string, unknown>;
    readonly rootFiles: readonly string[];
    readonly program: Program;
    readonly checker: Checker;
    readonly emitter: Emitter;
    private client;
    constructor(data: ProjectResponse, snapshotId: number, client: Client, objectRegistry: SnapshotObjectRegistry, sourceFileCache: SourceFileCache, toPath: (fileName: string) => Path);
}
export declare class Program {
    private snapshotId;
    private projectId;
    private client;
    private sourceFileCache;
    private toPath;
    private decoder;
    constructor(snapshotId: number, projectId: string, client: Client, sourceFileCache: SourceFileCache, toPath: (fileName: string) => Path);
    getSourceFile(file: DocumentIdentifier): SourceFile | undefined;
    /**
     * Get syntactic (parse) diagnostics for a specific file or all files.
     * @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
     */
    getSyntacticDiagnostics(file?: DocumentIdentifier): readonly Diagnostic[];
    /**
     * Get semantic (type-check) diagnostics for a specific file or all files.
     * @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
     */
    getSemanticDiagnostics(file?: DocumentIdentifier): readonly Diagnostic[];
    /**
     * Get suggestion diagnostics for a specific file or all files.
     * @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
     */
    getSuggestionDiagnostics(file?: DocumentIdentifier): readonly Diagnostic[];
    /**
     * Get declaration emit diagnostics for a specific file or all files.
     * @param file - Optional file to get diagnostics for. If omitted, returns diagnostics for all files.
     */
    getDeclarationDiagnostics(file?: DocumentIdentifier): readonly Diagnostic[];
    /**
     * Get config file parsing diagnostics for the project.
     */
    getConfigFileParsingDiagnostics(): readonly Diagnostic[];
}
export declare class Checker {
    private snapshotId;
    private projectId;
    private client;
    private objectRegistry;
    constructor(snapshotId: number, projectId: string, client: Client, objectRegistry: SnapshotObjectRegistry);
    getSymbolAtLocation(node: Node): Symbol | undefined;
    getSymbolAtLocation(nodes: readonly Node[]): (Symbol | undefined)[];
    getSymbolAtPosition(file: DocumentIdentifier, position: number): Symbol | undefined;
    getSymbolAtPosition(file: DocumentIdentifier, positions: readonly number[]): (Symbol | undefined)[];
    getTypeOfSymbol(symbol: Symbol): Type | undefined;
    getTypeOfSymbol(symbols: readonly Symbol[]): (Type | undefined)[];
    getDeclaredTypeOfSymbol(symbol: Symbol): Type | undefined;
    getReferencesToSymbolInFile(file: DocumentIdentifier, symbol: Symbol): NodeHandle[];
    getReferencedSymbolsForNode(node: Node, position: number): ReferencedSymbolEntry[];
    getSignatureUsage(signatureDecl: Node): SignatureUsage[];
    getCompletionsAtPosition(document: string, position: number, options?: CompletionOptions): CompletionInfo | undefined;
    getTypeAtLocation(node: Node): Type | undefined;
    getTypeAtLocation(nodes: readonly Node[]): (Type | undefined)[];
    getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
    getResolvedSignature(node: Node): Signature | undefined;
    getTypeAtPosition(file: DocumentIdentifier, position: number): Type | undefined;
    getTypeAtPosition(file: DocumentIdentifier, positions: readonly number[]): (Type | undefined)[];
    resolveName(name: string, meaning: SymbolFlags, location?: Node | DocumentPosition, excludeGlobals?: boolean): Symbol | undefined;
    getResolvedSymbol(node: Identifier): Symbol | undefined;
    getContextualType(node: Expression): Type | undefined;
    getBaseTypeOfLiteralType(type: Type): Type | undefined;
    getNonNullableType(type: Type): Type | undefined;
    getTypeFromTypeNode(node: TypeNode): Type | undefined;
    getWidenedType(type: Type): Type | undefined;
    getParameterType(signature: Signature, index: number): Type | undefined;
    isArrayLikeType(type: Type): boolean;
    isTypeAssignableTo(source: Type, target: Type): boolean;
    getShorthandAssignmentValueSymbol(node: Node): Symbol | undefined;
    getTypeOfSymbolAtLocation(symbol: Symbol, location: Node): Type | undefined;
    private getIntrinsicType;
    getAnyType(): Type;
    getStringType(): Type;
    getNumberType(): Type;
    getBooleanType(): Type;
    getVoidType(): Type;
    getUndefinedType(): Type;
    getNullType(): Type;
    getNeverType(): Type;
    getUnknownType(): Type;
    getBigIntType(): Type;
    getESSymbolType(): Type;
    typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: number): TypeNode | undefined;
    signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): Node | undefined;
    typeToString(type: Type, enclosingDeclaration?: Node, flags?: number): string;
    isContextSensitive(node: Node): boolean;
    getReturnTypeOfSignature(signature: Signature): Type | undefined;
    getRestTypeOfSignature(signature: Signature): Type | undefined;
    getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
    getBaseTypes(type: Type): readonly Type[];
    getPropertiesOfType(type: Type): readonly Symbol[];
    getIndexInfosOfType(type: Type): readonly IndexInfo[];
    getConstraintOfTypeParameter(type: Type): Type | undefined;
    getTypeArguments(type: Type): readonly Type[];
}
export interface PrintNodeOptions {
    preserveSourceNewlines?: boolean;
    neverAsciiEscape?: boolean;
    terminateUnterminatedLiterals?: boolean;
}
export declare class Emitter {
    private client;
    constructor(client: Client);
    printNode(node: Node, options?: PrintNodeOptions): string;
}
export declare class NodeHandle {
    readonly index: number;
    readonly kind: SyntaxKind;
    readonly path: Path;
    constructor(handle: string);
    /**
     * Resolve this handle to the actual AST node by fetching the source file
     * from the given project and looking up the node by index.
     */
    resolve(project: Project): Node | undefined;
}
/** A symbol definition paired with all of its reference nodes. */
export interface ReferencedSymbolEntry {
    /** The node handle for the symbol's definition. */
    definition: NodeHandle;
    /** The resolved symbol for the definition, if available. */
    symbol?: Symbol;
    /** The node handles for each reference to the symbol. */
    references: NodeHandle[];
}
/** A single usage of a signature, pairing the reference name with its call expression (if any). */
export interface SignatureUsage {
    /** The node handle for the name reference. */
    name: NodeHandle;
    /** The node handle for the call expression, if the reference is invoked. */
    call?: NodeHandle;
}
export declare class Symbol {
    private objectRegistry;
    readonly id: number;
    readonly name: string;
    readonly flags: SymbolFlags;
    readonly checkFlags: number;
    readonly declarations: readonly NodeHandle[];
    readonly valueDeclaration: NodeHandle | undefined;
    readonly parent: number;
    readonly exportSymbol: number;
    constructor(data: SymbolResponse, objectRegistry: SnapshotObjectRegistry);
    getParent(): Symbol | undefined;
    getMembers(): readonly Symbol[];
    getExports(): readonly Symbol[];
    getExportSymbol(): Symbol;
}
declare class TypeObject implements Type {
    private objectRegistry;
    readonly id: number;
    readonly flags: TypeFlags;
    readonly objectFlags: ObjectFlags;
    readonly symbol: number;
    readonly value: string | number | boolean;
    readonly intrinsicName: string;
    readonly isThisType: boolean;
    readonly freshType: number;
    readonly regularType: number;
    readonly target: number;
    readonly typeParameters: readonly number[];
    readonly outerTypeParameters: readonly number[];
    readonly localTypeParameters: readonly number[];
    readonly aliasTypeArguments: readonly number[];
    readonly aliasSymbol: number;
    readonly elementFlags: readonly ElementFlags[];
    readonly fixedLength: number;
    readonly readonly: boolean;
    readonly texts: readonly string[];
    readonly objectType: number;
    readonly indexType: number;
    readonly checkType: number;
    readonly extendsType: number;
    readonly baseType: number;
    readonly substConstraint: number;
    constructor(data: TypeResponse, objectRegistry: SnapshotObjectRegistry);
    getSymbol(): Symbol | undefined;
    getAliasSymbol(): Symbol | undefined;
    getTarget(): Type;
    getFreshType(): FreshableType | undefined;
    getRegularType(): FreshableType | undefined;
    getTypes(): readonly Type[];
    getTypeParameters(): readonly Type[];
    getOuterTypeParameters(): readonly Type[];
    getLocalTypeParameters(): readonly Type[];
    getAliasTypeArguments(): readonly Type[];
    getObjectType(): Type;
    getIndexType(): Type;
    getCheckType(): Type;
    getExtendsType(): Type;
    getBaseType(): Type;
    getConstraint(): Type;
}
export declare class Signature {
    private flags;
    private objectRegistry;
    readonly id: number;
    readonly declaration?: NodeHandle | undefined;
    readonly typeParameters?: readonly number[] | undefined;
    readonly parameters: readonly number[];
    readonly thisParameter?: number | undefined;
    readonly target?: number | undefined;
    constructor(data: SignatureResponse, objectRegistry: SnapshotObjectRegistry);
    getTypeParameters(): readonly Type[];
    getParameters(): readonly Symbol[];
    getThisParameter(): Symbol | undefined;
    getTarget(): Signature | undefined;
    get hasRestParameter(): boolean;
    get isConstruct(): boolean;
    get isAbstract(): boolean;
}
//# sourceMappingURL=api.d.ts.map