fork of hey-api/openapi-ts because I need some additional things
1import type { AnalysisContext, NodeName, Ref } from '@hey-api/codegen-core';
2import { isNode, isSymbol, ref } from '@hey-api/codegen-core';
3
4import type { py } from '../../ts-python';
5import type { MaybePyDsl } from '../base';
6import { PyDsl } from '../base';
7// import { AsMixin } from '../mixins/as';
8// import { ExprMixin } from '../mixins/expr';
9// import { OperatorMixin } from '../mixins/operator';
10// import { TypeExprMixin } from '../mixins/type-expr';
11
12type Id = NodeName | MaybePyDsl<py.Expression>;
13
14const Mixed = PyDsl<py.Expression>;
15// const Mixed = AsMixin(ExprMixin(OperatorMixin(TypeExprMixin(PyDsl<PyExpression>))));
16
17export class ExprPyDsl extends Mixed {
18 readonly '~dsl' = 'ExprPyDsl';
19
20 protected _exprInput: Ref<Id>;
21
22 constructor(id: Id) {
23 super();
24 this._exprInput = ref(id);
25 if (typeof id === 'string' || isSymbol(id)) {
26 this.name.set(id);
27 } else if (isNode(id)) {
28 this.name.set(id.name);
29 }
30 }
31
32 override analyze(ctx: AnalysisContext): void {
33 super.analyze(ctx);
34 ctx.analyze(this._exprInput);
35 }
36
37 override toAst() {
38 return this.$node(this._exprInput);
39 }
40}