Skip to content

Commit fbc80ee

Browse files
committed
Remove implements
1 parent 5a8b608 commit fbc80ee

File tree

6 files changed

+517
-1559
lines changed

6 files changed

+517
-1559
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
@@ -533,8 +530,6 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
533530
for (const implement of declaration.getImplements()) {
534531
if (isKnownBehavior(implement)) {
535532
type.behaviors = (type.behaviors ?? []).concat(modelBehaviors(implement))
536-
} else {
537-
type.implements = (type.implements ?? []).concat(modelImplements(implement))
538533
}
539534
}
540535
}

compiler/src/model/metamodel.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ export class Interface extends BaseType {
224224
*/
225225
generics?: TypeName[]
226226
inherits?: Inherits
227-
implements?: Inherits[] // Unused!
228227

229228
/**
230229
* Behaviors directly implemented by this interface
@@ -255,7 +254,6 @@ export class Request extends BaseType {
255254
generics?: TypeName[]
256255
/** The parent defines additional body properties that are added to the body, that has to be a PropertyBody */
257256
inherits?: Inherits
258-
implements?: Inherits[]
259257
/** URL path properties */
260258
path: Property[]
261259
/** 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))
@@ -628,16 +625,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
628625
context.pop()
629626
}
630627

631-
function validateImplements (parents: (model.Inherits[] | undefined), openGenerics: Set<string>): void {
632-
if (parents == null || parents.length === 0) return
633-
634-
context.push('Implements')
635-
for (const parent of parents) {
636-
validateTypeRef(parent.type, parent.generics, openGenerics)
637-
}
638-
context.pop()
639-
}
640-
641628
function validateBehaviors (typeDef: model.Request | model.Response | model.Interface, openGenerics: Set<string>): void {
642629
if (typeDef.kind !== 'response' && typeDef.behaviors != null && typeDef.behaviors.length > 0) {
643630
context.push('Behaviors')
@@ -673,11 +660,10 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
673660
}
674661

675662
// Does a parent have this behavior?
676-
const parents = (type.implements ?? []).concat(type.inherits ?? [])
677-
for (const parent of parents) {
678-
const parentDef = getTypeDef(parent.type)
663+
if (type.inherits != null) {
664+
const parentDef = getTypeDef(type.inherits.type)
679665
if (parentDef == null) {
680-
modelError(`No type definition for parent '${fqn(parent.type)}'`)
666+
modelError(`No type definition for parent '${fqn(type.inherits.type)}'`)
681667
return false
682668
}
683669
if (parentDef.kind === 'request' || parentDef.kind === 'interface') {

0 commit comments

Comments
 (0)