-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: alias Import rules added (#855)
* feat: Alias Import rules added * Rules for AliasedIdentifier and Types added. * aliasedTypes filtered in callback of ImportTypes Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat: Grammar rules updated - as token defined for aliasing types in the import statements - as is defined local reserved word - AST made backward compatible Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat: Printer updated - Printer now handles the aliased types. - Test case added for parser and printer. Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias import): Printer and parser test cases - Test case added containing alias import Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias import): test cases for updated grammar - test cases added for both parser and printer - bad test cases added as well for the parser Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias import): PR changes - renamed the Types rule to IdentifierTypeExpression - Indentation fixed - Extra white spaces removed Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias): Minor fixes - Code changes made on suggestion. Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias): disabled aliasing to primitive types Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias): handle pr comments - Test cases added - pr comments handled Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias): variables renamed and code cleaned Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias import): printer code refactored - printer code refactored - coverage 100% tested locally Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias import): Updated concerto-metamodel version Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias import): Pr suggestion : code refactor Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias):package-lock.json fixed Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> * feat(alias): fixing pr Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com> --------- Signed-off-by: Jaskeerat Singh Saluja <58400083+salujajaskeerat@users.noreply.github.com>
- Loading branch information
1 parent
731b2f1
commit 032bd75
Showing
8 changed files
with
858 additions
and
559 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace test.aliasing | ||
|
||
import org.accordproject.{doc1 as d1,doc2 as d2} | ||
import org.accordproject.files.{file1,file2 as f2,file3} | ||
import com.example.foo@1.0.4-X.y.z-01.{baz1 as bar1} | ||
import com.example.foo@1.0.4.{baz2 as bar2} from https://com.example.co.uk/models/com.example.foo.cto | ||
import com.example.foo@1.0.4.{tee,baz as bar,lorem,ipsum,dolor as freq} | ||
import com.example.foo@1.0.4.{As as as,as as as} | ||
import com.example.foo@1.0.4.{baz} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.Model", | ||
"decorators": [], | ||
"namespace": "test.aliasing", | ||
"imports": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "org.accordproject", | ||
"types": ["doc1", "doc2"], | ||
"aliasedTypes": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "doc1", | ||
"aliasedName": "d1" | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "doc2", | ||
"aliasedName": "d2" | ||
} | ||
] | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "org.accordproject.files", | ||
"types": ["file1", "file2", "file3"], | ||
"aliasedTypes": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "file2", | ||
"aliasedName": "f2" | ||
} | ||
] | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "com.example.foo@1.0.4-X.y.z-01", | ||
"types": ["baz1"], | ||
"aliasedTypes": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "baz1", | ||
"aliasedName": "bar1" | ||
} | ||
] | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "com.example.foo@1.0.4", | ||
"types": ["baz2"], | ||
"aliasedTypes": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "baz2", | ||
"aliasedName": "bar2" | ||
} | ||
], | ||
"uri": "https://com.example.co.uk/models/com.example.foo.cto" | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "com.example.foo@1.0.4", | ||
"types": ["tee", "baz", "lorem", "ipsum", "dolor"], | ||
"aliasedTypes": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "baz", | ||
"aliasedName": "bar" | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "dolor", | ||
"aliasedName": "freq" | ||
} | ||
] | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "com.example.foo@1.0.4", | ||
"types": ["As", "as"], | ||
"aliasedTypes": [ | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "As", | ||
"aliasedName": "as" | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.AliasedType", | ||
"name": "as", | ||
"aliasedName": "as" | ||
} | ||
] | ||
}, | ||
{ | ||
"$class": "concerto.metamodel@1.0.0.ImportTypes", | ||
"namespace": "com.example.foo@1.0.4", | ||
"types": ["baz"] | ||
} | ||
], | ||
"declarations": [] | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/concerto-cto/test/cto/bad/aliasImport.bad.alias-missing.cto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace test.bad.alias.missing@1.0.0 | ||
|
||
import ns.{doc as} | ||
|
4 changes: 4 additions & 0 deletions
4
packages/concerto-cto/test/cto/bad/aliasImport.bad.single.cto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace test.aliasing@1.0.0 | ||
|
||
//Bad Import : without paranthesis | ||
import com.example.foo@1.0.4.baz as bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters