Skip to content

Commit 704d448

Browse files
committed
Remove implements
1 parent d4ff7ff commit 704d448

File tree

6 files changed

+523
-1577
lines changed

6 files changed

+523
-1577
lines changed

compiler/src/model/build-model.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import {
4444
modelBehaviors,
4545
modelEnumDeclaration,
4646
modelGenerics,
47-
modelImplements,
4847
modelInherits,
4948
modelProperty,
5049
modelType,
@@ -77,8 +76,6 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
7776
visibility: spec.visibility
7877
}
7978
},
80-
stability: spec.stability,
81-
visibility: spec.visibility,
8279
request: null,
8380
requestBodyRequired: Boolean(spec.body?.required),
8481
response: null,
@@ -91,7 +88,7 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
9188
})
9289
}
9390
if (typeof spec.feature_flag === 'string') {
94-
map[api].featureFlag = spec.feature_flag
91+
map[api].availability.stack.featureFlag = spec.feature_flag
9592
}
9693
}
9794
return map
@@ -534,8 +531,6 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
534531
for (const implement of declaration.getImplements()) {
535532
if (isKnownBehavior(implement)) {
536533
type.behaviors = (type.behaviors ?? []).concat(modelBehaviors(implement, jsDocs))
537-
} else {
538-
type.implements = (type.implements ?? []).concat(modelImplements(implement))
539534
}
540535
}
541536
}

compiler/src/model/metamodel.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ export class Interface extends BaseType {
235235
*/
236236
generics?: TypeName[]
237237
inherits?: Inherits
238-
implements?: Inherits[] // Unused!
239238

240239
/**
241240
* Behaviors directly implemented by this interface
@@ -266,7 +265,6 @@ export class Request extends BaseType {
266265
generics?: TypeName[]
267266
/** The parent defines additional body properties that are added to the body, that has to be a PropertyBody */
268267
inherits?: Inherits
269-
implements?: Inherits[]
270268
/** URL path properties */
271269
path: Property[]
272270
/** Query string properties */

compiler/src/steps/validate-model.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
135135
const parentTypes = new Set<string>()
136136
for (const type of apiModel.types) {
137137
if (type.kind === 'request' || type.kind === 'interface') {
138-
for (const parent of (type.implements ?? []).concat(type.inherits ?? [])) {
139-
parentTypes.add(fqn(parent.type))
138+
if (type.inherits != null) {
139+
parentTypes.add(fqn(type.inherits.type))
140140
}
141141
}
142142
}
@@ -380,7 +380,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
380380
const openGenerics = openGenericSet(typeDef)
381381

382382
validateInherits(typeDef.inherits, openGenerics)
383-
validateImplements(typeDef.implements, openGenerics)
384383
validateBehaviors(typeDef, openGenerics)
385384

386385
// Note: we validate codegen_name/name uniqueness independently in the path, query and body as there are some
@@ -495,7 +494,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
495494
if (typeDef.inherits != null) {
496495
addInherits(typeDef.inherits)
497496
}
498-
typeDef.implements?.forEach(addInherits)
499497
typeDef.behaviors?.forEach(addInherits)
500498
}
501499

@@ -505,7 +503,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
505503
function validateInterface (typeDef: model.Interface): void {
506504
const openGenerics = openGenericSet(typeDef)
507505

508-
validateImplements(typeDef.implements, openGenerics)
509506
validateInherits(typeDef.inherits, openGenerics)
510507
validateBehaviors(typeDef, openGenerics)
511508
validateProperties(typeDef.properties, openGenerics, inheritedProperties(typeDef))
@@ -694,16 +691,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
694691
context.pop()
695692
}
696693

697-
function validateImplements (parents: (model.Inherits[] | undefined), openGenerics: Set<string>): void {
698-
if (parents == null || parents.length === 0) return
699-
700-
context.push('Implements')
701-
for (const parent of parents) {
702-
validateTypeRef(parent.type, parent.generics, openGenerics)
703-
}
704-
context.pop()
705-
}
706-
707694
function validateBehaviors (typeDef: model.Request | model.Response | model.Interface, openGenerics: Set<string>): void {
708695
if (typeDef.kind !== 'response' && typeDef.behaviors != null && typeDef.behaviors.length > 0) {
709696
context.push('Behaviors')
@@ -746,11 +733,10 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
746733
}
747734

748735
// Does a parent have this behavior?
749-
const parents = (type.implements ?? []).concat(type.inherits ?? [])
750-
for (const parent of parents) {
751-
const parentDef = getTypeDef(parent.type)
736+
if (type.inherits != null) {
737+
const parentDef = getTypeDef(type.inherits.type)
752738
if (parentDef == null) {
753-
modelError(`No type definition for parent '${fqn(parent.type)}'`)
739+
modelError(`No type definition for parent '${fqn(type.inherits.type)}'`)
754740
return false
755741
}
756742
if (parentDef.kind === 'request' || parentDef.kind === 'interface') {

0 commit comments

Comments
 (0)