Skip to content

Commit

Permalink
fix(cto) Prints extends and identified in declarations in the right o…
Browse files Browse the repository at this point in the history
…rder

Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
Jerome Simeon authored and jeromesimeon committed Dec 17, 2021
1 parent be431f1 commit da86220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/concerto-cto/lib/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,16 @@ function declFromMetaModel(mm) {
result += `enum ${mm.name} `;
break;
}
if (mm.superType) {
result += `extends ${mm.superType.name} `;
}
// XXX Needs to be fixed to support `identified`
if (mm.identified) {
if (mm.identified.$class === 'concerto.metamodel.IdentifiedBy') {
result += `identified by ${mm.identified.name} `;
} else {
result += 'identified ';
}
}
if (mm.superType) {
result += `extends ${mm.superType.name} `;
}
result += '{';
mm.properties.forEach((property) => {
result += `\n ${propertyFromMetaModel(property)}`;
Expand Down
5 changes: 5 additions & 0 deletions packages/concerto-cto/test/cto/identified.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace test.field

concept Foo identified extends Concept {
o String foo default="FOO" optional
}
1 change: 1 addition & 0 deletions packages/concerto-cto/test/cto/identified.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$class":"concerto.metamodel.Model","namespace":"test.field","imports":[],"declarations":[{"$class":"concerto.metamodel.ConceptDeclaration","name":"Foo","isAbstract":false,"properties":[{"$class":"concerto.metamodel.StringProperty","name":"foo","isArray":false,"isOptional":true,"location":{"$class":"concerto.metamodel.Range","start":{"offset":65,"line":4,"column":3,"$class":"concerto.metamodel.Position"},"end":{"offset":101,"line":5,"column":1,"$class":"concerto.metamodel.Position"}},"defaultValue":"FOO"}],"location":{"$class":"concerto.metamodel.Range","start":{"offset":22,"line":3,"column":1,"$class":"concerto.metamodel.Position"},"end":{"offset":102,"line":5,"column":2,"$class":"concerto.metamodel.Position"}},"superType":{"$class":"concerto.metamodel.TypeIdentifier","name":"Concept"},"identified":{"$class":"concerto.metamodel.Identified"}}]}

0 comments on commit da86220

Please sign in to comment.