@specs-feup/lara
Version:
A js port of the popular framework for building source-to-source compilers
67 lines • 2.86 kB
TypeScript
/**
* Type for type equality assertion. If T is equal to U, return Y, otherwise return N.
* Source: https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650
* @example
* type A = Equals<string, string, "Y", "N">; // "Y"
* type B = Equals<string, number, "Y", "N">; // "N"
*/
type Equals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
type DefaultAttributeHelper<T extends typeof LaraJoinPoint, DefaultAttributeMap, PrivateMapper> = {
[K in keyof DefaultAttributeMap]: K extends keyof PrivateMapper ? Equals<T, PrivateMapper[K], DefaultAttributeMap[K], never> : never;
}[keyof DefaultAttributeMap];
type ExtractedType<T> = T extends undefined ? never : T;
export type DefaultAttribute<T extends typeof LaraJoinPoint> = DefaultAttributeHelper<T, ExtractedType<T["_defaultAttributeInfo"]["map"]>, ExtractedType<T["_defaultAttributeInfo"]["type"]>>;
type NameFromWrapperClassHelper<T extends typeof LaraJoinPoint, U> = {
[K in keyof U]: Equals<T, U[K], K, never>;
}[keyof U];
export type NameFromWrapperClass<T extends typeof LaraJoinPoint> = NameFromWrapperClassHelper<T, ExtractedType<T["_defaultAttributeInfo"]["jpMapper"]>>;
export declare class LaraJoinPoint {
/**
* @internal
*/
static readonly _defaultAttributeInfo: {
readonly map?: any;
readonly name: string | null;
readonly type?: any;
readonly jpMapper?: any;
};
/**
* @internal
*/
_javaObject: any;
constructor(obj: any);
get attributes(): string[];
get selects(): string[];
get actions(): string[];
get dump(): string;
get joinPointType(): string;
get node(): object;
get self(): LaraJoinPoint;
get super(): LaraJoinPoint;
get children(): LaraJoinPoint[];
get descendants(): LaraJoinPoint[];
get scopeNodes(): LaraJoinPoint[];
insert(position: "before" | "after" | "replace", code: string): LaraJoinPoint;
insert(position: "before" | "after" | "replace", joinpoint: LaraJoinPoint): LaraJoinPoint;
def(attribute: string, value: object): void;
toString(): string;
equals(jp: LaraJoinPoint): boolean;
instanceOf(name: string): boolean;
instanceOf(names: string[]): boolean;
}
export type JoinpointMapperType = {
[key: string]: typeof LaraJoinPoint;
};
export declare function registerJoinpointMapper(mapper: JoinpointMapperType): void;
/**
* This function is for internal use only. DO NOT USE IT!
*/
export declare function clearJoinpointMappers(): void;
/**
* This function is for internal use only. DO NOT USE IT!
*/
export declare function getJoinpointMappers(): JoinpointMapperType[];
export declare function wrapJoinPoint(obj: any): any;
export declare function unwrapJoinPoint(obj: any): any;
export {};
//# sourceMappingURL=LaraJoinPoint.d.ts.map