Skip to content

Commit

Permalink
fix: add default qualifier
Browse files Browse the repository at this point in the history
  • Loading branch information
gxkl committed Oct 29, 2024
1 parent 90acf35 commit e406340
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions core/metadata/src/factory/EggPrototypeCreatorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@ export class EggPrototypeCreatorFactory {

static async createProto(clazz: EggProtoImplClass, loadUnit: LoadUnit): Promise<EggPrototype[]> {
let properties: EggPrototypeInfo[] = [];
const defaultQualifier = [{
attribute: InitTypeQualifierAttribute,
value: PrototypeUtil.getInitType(clazz, {
unitPath: loadUnit.unitPath,
moduleName: loadUnit.name,
})!,
}, {
attribute: LoadUnitNameQualifierAttribute,
value: loadUnit.name,
}];

if (PrototypeUtil.isEggMultiInstancePrototype(clazz)) {
const multiInstanceProtoInfo = PrototypeUtil.getMultiInstanceProperty(clazz, {
unitPath: loadUnit.unitPath,
moduleName: loadUnit.name,
})!;
for (const obj of multiInstanceProtoInfo.objects) {
const defaultQualifier = [{
attribute: InitTypeQualifierAttribute,
value: PrototypeUtil.getInitType(clazz, {
unitPath: loadUnit.unitPath,
moduleName: loadUnit.name,
})!,
}, {
attribute: LoadUnitNameQualifierAttribute,
value: loadUnit.name,
}];
defaultQualifier.forEach(qualifier => {
if (!obj.qualifiers.find(t => t.attribute === qualifier.attribute)) {
obj.qualifiers.push(qualifier);
Expand All @@ -56,7 +57,16 @@ export class EggPrototypeCreatorFactory {
});
}
} else {
properties = [ PrototypeUtil.getProperty(clazz)! ];
const property = PrototypeUtil.getProperty(clazz)!;
if (!property.qualifiers) {
property.qualifiers = [];
}
defaultQualifier.forEach(qualifier => {
if (!property.qualifiers!.find(t => t.attribute === qualifier.attribute)) {
property.qualifiers!.push(qualifier);
}
});
properties = [ property ];
}
const protos: EggPrototype[] = [];
for (const property of properties) {
Expand Down

0 comments on commit e406340

Please sign in to comment.