Skip to content

Commit

Permalink
Use dedicated Behavior type in metamodel
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Jun 26, 2024
1 parent e0d1082 commit da75a4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 8 additions & 3 deletions compiler/src/model/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand All @@ -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`)
Expand Down Expand Up @@ -276,7 +281,7 @@ export class Request extends BaseType {
* that don't have a body.
*/
body: Body
behaviors?: Inherits[]
behaviors?: Behavior[]
attachedBehaviors?: string[]
}

Expand All @@ -287,7 +292,7 @@ export class Response extends BaseType {
kind: 'response'
generics?: TypeName[]
body: Body
behaviors?: Inherits[]
behaviors?: Behavior[]
attachedBehaviors?: string[]
exceptions?: ResponseException[]
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/model/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
11 changes: 8 additions & 3 deletions typescript-generator/src/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand All @@ -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`)
Expand Down Expand Up @@ -276,7 +281,7 @@ export class Request extends BaseType {
* that don't have a body.
*/
body: Body
behaviors?: Inherits[]
behaviors?: Behavior[]
attachedBehaviors?: string[]
}

Expand All @@ -287,7 +292,7 @@ export class Response extends BaseType {
kind: 'response'
generics?: TypeName[]
body: Body
behaviors?: Inherits[]
behaviors?: Behavior[]
attachedBehaviors?: string[]
exceptions?: ResponseException[]
}
Expand Down

0 comments on commit da75a4c

Please sign in to comment.