Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 64 additions & 11 deletions packages/typescript/src/api/async/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1384,11 +1384,21 @@ export class Checker {
* declared type cannot be determined the checker yields the error type (use
* {@link Type.isErrorType} to detect it).
*/
async getDeclaredTypeOfSymbol(symbol: Symbol): Promise<Type> {
async getDeclaredTypeOfSymbol(symbol: Symbol): Promise<Type>;
async getDeclaredTypeOfSymbol(symbols: readonly Symbol[]): Promise<Type[]>;
async getDeclaredTypeOfSymbol(symbolOrSymbols: Symbol | readonly Symbol[]): Promise<Type | Type[]> {
if (Array.isArray(symbolOrSymbols)) {
const data = await this.client.apiRequest("getDeclaredTypesOfSymbols", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data.map(d => this.objectRegistry.getOrCreateType(d));
}
const data = await this.client.apiRequest("getDeclaredTypeOfSymbol", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return this.objectRegistry.getOrCreateType(data);
}
Expand Down Expand Up @@ -1859,11 +1869,21 @@ export class Checker {
* an unresolved alias the checker yields the unknown symbol (use
* {@link Checker.isUnknownSymbol} to detect it).
*/
async getAliasedSymbol(symbol: Symbol): Promise<Symbol> {
async getAliasedSymbol(symbol: Symbol): Promise<Symbol>;
async getAliasedSymbol(symbols: readonly Symbol[]): Promise<Symbol[]>;
async getAliasedSymbol(symbolOrSymbols: Symbol | readonly Symbol[]): Promise<Symbol | Symbol[]> {
if (Array.isArray(symbolOrSymbols)) {
const data = await this.client.apiRequest("getAliasedSymbols", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data.map(d => this.objectRegistry.getOrCreateSymbol(d));
}
const data = await this.client.apiRequest("getAliasedSymbol", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return this.objectRegistry.getOrCreateSymbol(data);
}
Expand All @@ -1880,11 +1900,21 @@ export class Checker {
});
}

async getImmediateAliasedSymbol(symbol: Symbol): Promise<Symbol | undefined> {
async getImmediateAliasedSymbol(symbol: Symbol): Promise<Symbol | undefined>;
async getImmediateAliasedSymbol(symbols: readonly Symbol[]): Promise<(Symbol | undefined)[]>;
async getImmediateAliasedSymbol(symbolOrSymbols: Symbol | readonly Symbol[]): Promise<Symbol | (Symbol | undefined)[] | undefined> {
if (Array.isArray(symbolOrSymbols)) {
const data = await this.client.apiRequest("getImmediateAliasedSymbols", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data ? data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined) : symbolOrSymbols.map(() => undefined);
}
const data = await this.client.apiRequest("getImmediateAliasedSymbol", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
}
Expand Down Expand Up @@ -1945,21 +1975,44 @@ export class Checker {
return signature.id === (await this.getWellKnownSignatures()).unknown;
}

async getExportsOfModule(symbol: Symbol): Promise<readonly Symbol[]> {
async getExportsOfModule(symbol: Symbol): Promise<readonly Symbol[]>;
async getExportsOfModule(symbols: readonly Symbol[]): Promise<readonly (readonly Symbol[])[]>;
async getExportsOfModule(symbolOrSymbols: Symbol | readonly Symbol[]): Promise<readonly Symbol[] | readonly (readonly Symbol[])[]> {
if (Array.isArray(symbolOrSymbols)) {
const data = await this.client.apiRequest("getExportsOfModules", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data.map(d => d ? d.map(s => this.objectRegistry.getOrCreateSymbol(s)) : []);
}
const data = await this.client.apiRequest("getExportsOfModule", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
}

async getMemberInModuleExports(symbol: Symbol, name: string): Promise<Symbol | undefined> {
async getMemberInModuleExports(symbol: Symbol, name: string): Promise<Symbol | undefined>;
async getMemberInModuleExports(requests: readonly { symbol: Symbol; name: string; }[]): Promise<(Symbol | undefined)[]>;
async getMemberInModuleExports(
symbolOrRequests: Symbol | readonly { symbol: Symbol; name: string; }[],
name?: string,
): Promise<Symbol | (Symbol | undefined)[] | undefined> {
if (Array.isArray(symbolOrRequests)) {
const data = await this.client.apiRequest("getMembersInModuleExports", {
snapshot: this.snapshotId,
project: this.project.id,
requests: symbolOrRequests.map(r => ({ symbol: r.symbol.id, name: r.name })),
});
return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
}
const data = await this.client.apiRequest("getMemberInModuleExports", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
name,
symbol: (symbolOrRequests as Symbol).id,
name: name!,
});
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
}
Expand Down
24 changes: 24 additions & 0 deletions packages/typescript/src/api/proto.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface APIMethodInfo {
getTypeOfSymbol: APIMethod<GetTypeOfSymbolParams, TypeResponse>;
getTypesOfSymbols: APIMethod<GetTypesOfSymbolsParams, TypeResponse[]>;
getDeclaredTypeOfSymbol: APIMethod<GetTypeOfSymbolParams, TypeResponse>;
getDeclaredTypesOfSymbols: APIMethod<GetTypesOfSymbolsParams, TypeResponse[]>;
getSourceFile: APIMethod<GetSourceFileParams, SourceFileResponse | null>;
getSourceFileNames: APIMethod<GetSourceFileNamesParams, string[]>;
getSourceFileMetadata: APIMethod<GetSourceFileParams, SourceFileMetadata | null>;
Expand Down Expand Up @@ -104,10 +105,14 @@ export interface APIMethodInfo {
getSignatureFromDeclaration: APIMethod<CheckerNodeParams, SignatureResponse>;
getExportSpecifierLocalTargetSymbol: APIMethod<CheckerNodeParams, SymbolResponse | null>;
getAliasedSymbol: APIMethod<CheckerSymbolParams, SymbolResponse>;
getAliasedSymbols: APIMethod<CheckerSymbolsParams, SymbolResponse[]>;
getImmediateAliasedSymbol: APIMethod<CheckerSymbolParams, SymbolResponse | null>;
getImmediateAliasedSymbols: APIMethod<CheckerSymbolsParams, SymbolResponse[] | null>;
getFullyQualifiedName: APIMethod<CheckerSymbolParams, string>;
getExportsOfModule: APIMethod<CheckerSymbolParams, SymbolResponse[] | null>;
getExportsOfModules: APIMethod<CheckerSymbolsParams, SymbolResponse[][]>;
getMemberInModuleExports: APIMethod<GetMemberInModuleExportsParams, SymbolResponse | null>;
getMembersInModuleExports: APIMethod<GetMembersInModuleExportsParams, SymbolResponse[]>;
getJsDocTags: APIMethod<CheckerSymbolParams, JSDocTagInfo[] | null>;
getDocumentationComment: APIMethod<CheckerSymbolParams, string>;
isArrayType: APIMethod<CheckerTypeParams, boolean>;
Expand Down Expand Up @@ -678,6 +683,13 @@ export interface CheckerSymbolParams {
symbol: number;
}

/** CheckerSymbolsParams are parameters for checker methods that operate on a list of symbols. */
export interface CheckerSymbolsParams {
snapshot: number;
project: string;
symbols: readonly number[] | null;
}

/** GetMemberInModuleExportsParams are parameters for getMemberInModuleExports. */
export interface GetMemberInModuleExportsParams {
snapshot: number;
Expand All @@ -686,6 +698,13 @@ export interface GetMemberInModuleExportsParams {
name: string;
}

/** GetMembersInModuleExportsParams are parameters for getMembersInModuleExports. */
export interface GetMembersInModuleExportsParams {
snapshot: number;
project: string;
requests: readonly MemberInModuleExportsRequest[] | null;
}

/**
* JSDocTagInfo is a single JSDoc tag, mirroring Strada's JSDocTagInfo but with the tag text
* rendered as a plain string rather than SymbolDisplayPart[].
Expand Down Expand Up @@ -1021,6 +1040,11 @@ export interface ImportAdderAction {
isValidTypeOnlyUseSite?: boolean;
}

export interface MemberInModuleExportsRequest {
symbol: number;
name: string;
}

/** CompletionEntryResponse represents a single completion item. */
export interface CompletionEntryResponse {
name: string;
Expand Down
75 changes: 64 additions & 11 deletions packages/typescript/src/api/sync/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1392,11 +1392,21 @@ export class Checker {
* declared type cannot be determined the checker yields the error type (use
* {@link Type.isErrorType} to detect it).
*/
getDeclaredTypeOfSymbol(symbol: Symbol): Type {
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
getDeclaredTypeOfSymbol(symbols: readonly Symbol[]): Type[];
getDeclaredTypeOfSymbol(symbolOrSymbols: Symbol | readonly Symbol[]): Type | Type[] {
if (Array.isArray(symbolOrSymbols)) {
const data = this.client.apiRequest("getDeclaredTypesOfSymbols", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data.map(d => this.objectRegistry.getOrCreateType(d));
}
const data = this.client.apiRequest("getDeclaredTypeOfSymbol", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return this.objectRegistry.getOrCreateType(data);
}
Expand Down Expand Up @@ -1867,11 +1877,21 @@ export class Checker {
* an unresolved alias the checker yields the unknown symbol (use
* {@link Checker.isUnknownSymbol} to detect it).
*/
getAliasedSymbol(symbol: Symbol): Symbol {
getAliasedSymbol(symbol: Symbol): Symbol;
getAliasedSymbol(symbols: readonly Symbol[]): Symbol[];
getAliasedSymbol(symbolOrSymbols: Symbol | readonly Symbol[]): Symbol | Symbol[] {
if (Array.isArray(symbolOrSymbols)) {
const data = this.client.apiRequest("getAliasedSymbols", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data.map(d => this.objectRegistry.getOrCreateSymbol(d));
}
const data = this.client.apiRequest("getAliasedSymbol", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return this.objectRegistry.getOrCreateSymbol(data);
}
Expand All @@ -1888,11 +1908,21 @@ export class Checker {
});
}

getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined {
getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined;
getImmediateAliasedSymbol(symbols: readonly Symbol[]): (Symbol | undefined)[];
getImmediateAliasedSymbol(symbolOrSymbols: Symbol | readonly Symbol[]): Symbol | (Symbol | undefined)[] | undefined {
if (Array.isArray(symbolOrSymbols)) {
const data = this.client.apiRequest("getImmediateAliasedSymbols", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data ? data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined) : symbolOrSymbols.map(() => undefined);
}
const data = this.client.apiRequest("getImmediateAliasedSymbol", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
}
Expand Down Expand Up @@ -1953,21 +1983,44 @@ export class Checker {
return signature.id === (this.getWellKnownSignatures()).unknown;
}

getExportsOfModule(symbol: Symbol): readonly Symbol[] {
getExportsOfModule(symbol: Symbol): readonly Symbol[];
getExportsOfModule(symbols: readonly Symbol[]): readonly (readonly Symbol[])[];
getExportsOfModule(symbolOrSymbols: Symbol | readonly Symbol[]): readonly Symbol[] | readonly (readonly Symbol[])[] {
if (Array.isArray(symbolOrSymbols)) {
const data = this.client.apiRequest("getExportsOfModules", {
snapshot: this.snapshotId,
project: this.project.id,
symbols: symbolOrSymbols.map(s => s.id),
});
return data.map(d => d ? d.map(s => this.objectRegistry.getOrCreateSymbol(s)) : []);
}
const data = this.client.apiRequest("getExportsOfModule", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
symbol: (symbolOrSymbols as Symbol).id,
});
return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
}

getMemberInModuleExports(symbol: Symbol, name: string): Symbol | undefined {
getMemberInModuleExports(symbol: Symbol, name: string): Symbol | undefined;
getMemberInModuleExports(requests: readonly { symbol: Symbol; name: string; }[]): (Symbol | undefined)[];
getMemberInModuleExports(
symbolOrRequests: Symbol | readonly { symbol: Symbol; name: string; }[],
name?: string,
): Symbol | (Symbol | undefined)[] | undefined {
if (Array.isArray(symbolOrRequests)) {
const data = this.client.apiRequest("getMembersInModuleExports", {
snapshot: this.snapshotId,
project: this.project.id,
requests: symbolOrRequests.map(r => ({ symbol: r.symbol.id, name: r.name })),
});
return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
}
const data = this.client.apiRequest("getMemberInModuleExports", {
snapshot: this.snapshotId,
project: this.project.id,
symbol: symbol.id,
name,
symbol: (symbolOrRequests as Symbol).id,
name: name!,
});
return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
}
Expand Down
Loading