Skip to content

Commit

Permalink
chore(aliasing): tests import aliasing
Browse files Browse the repository at this point in the history
Signed-off-by: sanketshevkar <[email protected]>
  • Loading branch information
sanketshevkar committed Jan 13, 2025
1 parent 85366be commit 0c99609
Show file tree
Hide file tree
Showing 14 changed files with 2,350 additions and 2,044 deletions.
1,157 changes: 489 additions & 668 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/concerto-core/lib/introspect/declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Declaration extends Decorated {
throw new IllegalModelException(`Invalid class name '${this.ast.name}'`, this.modelFile, this.ast.location);
}

// should we use resolved name here?
this.name = this.ast.name;
this.fqn = ModelUtil.getFullyQualifiedName(this.modelFile.getNamespace(), this.name);
}
Expand Down
1 change: 1 addition & 0 deletions packages/concerto-core/lib/introspect/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Property extends Decorated {
this.type = 'String';
break;
case `${MetaModelNamespace}.ObjectProperty`:
// should we have resolved name here?
this.type = this.ast.type ? this.ast.type.name : null;
break;
case `${MetaModelNamespace}.RelationshipProperty`:
Expand Down
2 changes: 1 addition & 1 deletion packages/concerto-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"dependencies": {
"@accordproject/concerto-cto": "3.20.1",
"@accordproject/concerto-metamodel": "3.10.4",
"@accordproject/concerto-metamodel": "../../../concerto-metamodel",
"@accordproject/concerto-util": "3.20.1",
"dayjs": "1.11.13",
"debug": "4.3.7",
Expand Down
5 changes: 5 additions & 0 deletions packages/concerto-core/test/data/aliasing/child.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace [email protected]
concept Child {
o Integer age
}
scalar MyString extends String
24 changes: 24 additions & 0 deletions packages/concerto-core/test/data/aliasing/parent.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@test(Kid)
namespace [email protected]

import [email protected].{MyString as Str, Child as Kid}

@test(Kid)
concept Child extends Kid {
@test(Kid)
o Kid kid
o Str str
}

concept Student extends Child {
o Str schoolName
o Str name
o Child myChild
}

@test(Kid)
map KidIndex {
o Str
@test(Kid)
o Kid
}
167 changes: 166 additions & 1 deletion packages/concerto-core/test/data/model/carResolved.json
Original file line number Diff line number Diff line change
@@ -1 +1,166 @@
{"$class":"[email protected]","models":[{"$class":"[email protected]","decorators":[],"namespace":"org.vehicle","imports":[],"declarations":[{"$class":"[email protected]","name":"Manufactured","isAbstract":true,"properties":[],"location":{"$class":"[email protected]","start":{"offset":23,"line":3,"column":1,"$class":"[email protected]"},"end":{"offset":56,"line":4,"column":2,"$class":"[email protected]"}}},{"$class":"[email protected]","name":"Vehicle","isAbstract":true,"properties":[{"$class":"[email protected]","name":"name","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":108,"line":7,"column":3,"$class":"[email protected]"},"end":{"offset":124,"line":8,"column":3,"$class":"[email protected]"}}},{"$class":"[email protected]","name":"range","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":124,"line":8,"column":3,"$class":"[email protected]"},"end":{"offset":139,"line":9,"column":1,"$class":"[email protected]"}}}],"location":{"$class":"[email protected]","start":{"offset":58,"line":6,"column":1,"$class":"[email protected]"},"end":{"offset":140,"line":9,"column":2,"$class":"[email protected]"}},"superType":{"$class":"[email protected]","name":"Manufactured","namespace":"org.vehicle"}}]},{"$class":"[email protected]","decorators":[],"namespace":"org.car","imports":[{"$class":"[email protected]","namespace":"org.vehicle"}],"declarations":[{"$class":"[email protected]","name":"Car","isAbstract":false,"properties":[{"$class":"[email protected]","name":"mileage","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":73,"line":6,"column":3,"$class":"[email protected]"},"end":{"offset":90,"line":7,"column":1,"$class":"[email protected]"}}}],"location":{"$class":"[email protected]","start":{"offset":41,"line":5,"column":1,"$class":"[email protected]"},"end":{"offset":91,"line":7,"column":2,"$class":"[email protected]"}},"superType":{"$class":"[email protected]","name":"Vehicle","namespace":"org.vehicle"}}]}]}
{
"$class": "[email protected]",
"models": [
{
"$class": "[email protected]",
"decorators": [],
"namespace": "org.vehicle",
"imports": [],
"declarations": [
{
"$class": "[email protected]",
"name": "Manufactured",
"isAbstract": true,
"properties": [],
"location": {
"$class": "[email protected]",
"start": {
"offset": 23,
"line": 3,
"column": 1,
"$class": "[email protected]"
},
"end": {
"offset": 56,
"line": 4,
"column": 2,
"$class": "[email protected]"
}
}
},
{
"$class": "[email protected]",
"name": "Vehicle",
"isAbstract": true,
"properties": [
{
"$class": "[email protected]",
"name": "name",
"isArray": false,
"isOptional": false,
"location": {
"$class": "[email protected]",
"start": {
"offset": 108,
"line": 7,
"column": 3,
"$class": "[email protected]"
},
"end": {
"offset": 124,
"line": 8,
"column": 3,
"$class": "[email protected]"
}
}
},
{
"$class": "[email protected]",
"name": "range",
"isArray": false,
"isOptional": false,
"location": {
"$class": "[email protected]",
"start": {
"offset": 124,
"line": 8,
"column": 3,
"$class": "[email protected]"
},
"end": {
"offset": 139,
"line": 9,
"column": 1,
"$class": "[email protected]"
}
}
}
],
"location": {
"$class": "[email protected]",
"start": {
"offset": 58,
"line": 6,
"column": 1,
"$class": "[email protected]"
},
"end": {
"offset": 140,
"line": 9,
"column": 2,
"$class": "[email protected]"
}
},
"superType": {
"$class": "[email protected]",
"name": "Manufactured",
"namespace": "org.vehicle",
"resolvedName": "Manufactured"
}
}
]
},
{
"$class": "[email protected]",
"decorators": [],
"namespace": "org.car",
"imports": [
{
"$class": "[email protected]",
"namespace": "org.vehicle"
}
],
"declarations": [
{
"$class": "[email protected]",
"name": "Car",
"isAbstract": false,
"properties": [
{
"$class": "[email protected]",
"name": "mileage",
"isArray": false,
"isOptional": false,
"location": {
"$class": "[email protected]",
"start": {
"offset": 73,
"line": 6,
"column": 3,
"$class": "[email protected]"
},
"end": {
"offset": 90,
"line": 7,
"column": 1,
"$class": "[email protected]"
}
}
}
],
"location": {
"$class": "[email protected]",
"start": {
"offset": 41,
"line": 5,
"column": 1,
"$class": "[email protected]"
},
"end": {
"offset": 91,
"line": 7,
"column": 2,
"$class": "[email protected]"
}
},
"superType": {
"$class": "[email protected]",
"name": "Vehicle",
"namespace": "org.vehicle",
"resolvedName": "Vehicle"
}
}
]
}
]
}
Loading

0 comments on commit 0c99609

Please sign in to comment.