import { getTestObject } from "framework/Typedefs";

const test = getTestObject()

export type Context = {
	kind: string;
	name: string | symbol;
	access: {
		get?(): unknown;
		set?(value: unknown): void;
		has?(value: unknown): boolean;
	};
	private?: boolean;
	static?: boolean;
	addInitializer?(initializer: () => void): void;
};

export type Method = (...args: any[]) => any;

export function step(label: string): Method {
	return <T extends Method>(value: T, context: Context): Method => {
		return function (this: any, ...args: any[]): Promise<any> {
			// console.log(`Method ${value.name} has been decorated`, context, args, label);
			return test.step(label, async () => {
				return value.call(this, ...args);
			});
		};
	};
}