Skip to content

Commit da75a4c

Browse files
committed
Use dedicated Behavior type in metamodel
1 parent e0d1082 commit da75a4c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

compiler/src/model/metamodel.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ export class Container extends VariantBase {
213213
export class Inherits {
214214
type: TypeName
215215
generics?: ValueOf[]
216+
}
217+
218+
export class Behavior {
219+
type: TypeName
220+
generics?: ValueOf[]
216221
meta?: { [p: string]: string }
217222
}
218223

@@ -232,7 +237,7 @@ export class Interface extends BaseType {
232237
/**
233238
* Behaviors directly implemented by this interface
234239
*/
235-
behaviors?: Inherits[]
240+
behaviors?: Behavior[]
236241

237242
/**
238243
* Behaviors attached to this interface, coming from the interface itself (see `behaviors`)
@@ -276,7 +281,7 @@ export class Request extends BaseType {
276281
* that don't have a body.
277282
*/
278283
body: Body
279-
behaviors?: Inherits[]
284+
behaviors?: Behavior[]
280285
attachedBehaviors?: string[]
281286
}
282287

@@ -287,7 +292,7 @@ export class Response extends BaseType {
287292
kind: 'response'
288293
generics?: TypeName[]
289294
body: Body
290-
behaviors?: Inherits[]
295+
behaviors?: Behavior[]
291296
attachedBehaviors?: string[]
292297
exceptions?: ResponseException[]
293298
}

compiler/src/model/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export function modelImplements (node: ExpressionWithTypeArguments): model.Inher
414414
* A class could have multiple behaviors from multiple classes,
415415
* which are defined inside the node typeArguments.
416416
*/
417-
export function modelBehaviors (node: ExpressionWithTypeArguments, jsDocs: JSDoc[]): model.Inherits {
417+
export function modelBehaviors (node: ExpressionWithTypeArguments, jsDocs: JSDoc[]): model.Behavior {
418418
const behaviorName = node.getExpression().getText()
419419
const generics = node.getTypeArguments().map(node => modelType(node))
420420

typescript-generator/src/metamodel.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ export class Container extends VariantBase {
213213
export class Inherits {
214214
type: TypeName
215215
generics?: ValueOf[]
216+
}
217+
218+
export class Behavior {
219+
type: TypeName
220+
generics?: ValueOf[]
216221
meta?: { [p: string]: string }
217222
}
218223

@@ -232,7 +237,7 @@ export class Interface extends BaseType {
232237
/**
233238
* Behaviors directly implemented by this interface
234239
*/
235-
behaviors?: Inherits[]
240+
behaviors?: Behavior[]
236241

237242
/**
238243
* Behaviors attached to this interface, coming from the interface itself (see `behaviors`)
@@ -276,7 +281,7 @@ export class Request extends BaseType {
276281
* that don't have a body.
277282
*/
278283
body: Body
279-
behaviors?: Inherits[]
284+
behaviors?: Behavior[]
280285
attachedBehaviors?: string[]
281286
}
282287

@@ -287,7 +292,7 @@ export class Response extends BaseType {
287292
kind: 'response'
288293
generics?: TypeName[]
289294
body: Body
290-
behaviors?: Inherits[]
295+
behaviors?: Behavior[]
291296
attachedBehaviors?: string[]
292297
exceptions?: ResponseException[]
293298
}

0 commit comments

Comments
 (0)