From da75a4cd66f9f1d06532e02a9fba82fdcb3e8545 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Wed, 26 Jun 2024 09:16:19 +0200 Subject: [PATCH] Use dedicated `Behavior` type in metamodel --- compiler/src/model/metamodel.ts | 11 ++++++++--- compiler/src/model/utils.ts | 2 +- typescript-generator/src/metamodel.ts | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/compiler/src/model/metamodel.ts b/compiler/src/model/metamodel.ts index 92c6ca141e..f40110c6af 100644 --- a/compiler/src/model/metamodel.ts +++ b/compiler/src/model/metamodel.ts @@ -213,6 +213,11 @@ export class Container extends VariantBase { export class Inherits { type: TypeName generics?: ValueOf[] +} + +export class Behavior { + type: TypeName + generics?: ValueOf[] meta?: { [p: string]: string } } @@ -232,7 +237,7 @@ export class Interface extends BaseType { /** * Behaviors directly implemented by this interface */ - behaviors?: Inherits[] + behaviors?: Behavior[] /** * Behaviors attached to this interface, coming from the interface itself (see `behaviors`) @@ -276,7 +281,7 @@ export class Request extends BaseType { * that don't have a body. */ body: Body - behaviors?: Inherits[] + behaviors?: Behavior[] attachedBehaviors?: string[] } @@ -287,7 +292,7 @@ export class Response extends BaseType { kind: 'response' generics?: TypeName[] body: Body - behaviors?: Inherits[] + behaviors?: Behavior[] attachedBehaviors?: string[] exceptions?: ResponseException[] } diff --git a/compiler/src/model/utils.ts b/compiler/src/model/utils.ts index d44ff39773..75fd7a4ae8 100644 --- a/compiler/src/model/utils.ts +++ b/compiler/src/model/utils.ts @@ -414,7 +414,7 @@ export function modelImplements (node: ExpressionWithTypeArguments): model.Inher * A class could have multiple behaviors from multiple classes, * which are defined inside the node typeArguments. */ -export function modelBehaviors (node: ExpressionWithTypeArguments, jsDocs: JSDoc[]): model.Inherits { +export function modelBehaviors (node: ExpressionWithTypeArguments, jsDocs: JSDoc[]): model.Behavior { const behaviorName = node.getExpression().getText() const generics = node.getTypeArguments().map(node => modelType(node)) diff --git a/typescript-generator/src/metamodel.ts b/typescript-generator/src/metamodel.ts index 92c6ca141e..f40110c6af 100644 --- a/typescript-generator/src/metamodel.ts +++ b/typescript-generator/src/metamodel.ts @@ -213,6 +213,11 @@ export class Container extends VariantBase { export class Inherits { type: TypeName generics?: ValueOf[] +} + +export class Behavior { + type: TypeName + generics?: ValueOf[] meta?: { [p: string]: string } } @@ -232,7 +237,7 @@ export class Interface extends BaseType { /** * Behaviors directly implemented by this interface */ - behaviors?: Inherits[] + behaviors?: Behavior[] /** * Behaviors attached to this interface, coming from the interface itself (see `behaviors`) @@ -276,7 +281,7 @@ export class Request extends BaseType { * that don't have a body. */ body: Body - behaviors?: Inherits[] + behaviors?: Behavior[] attachedBehaviors?: string[] } @@ -287,7 +292,7 @@ export class Response extends BaseType { kind: 'response' generics?: TypeName[] body: Body - behaviors?: Inherits[] + behaviors?: Behavior[] attachedBehaviors?: string[] exceptions?: ResponseException[] }