From b61e99fe7e656bda2ef7da15792c5ab1093765b3 Mon Sep 17 00:00:00 2001 From: jeromesimeon Date: Wed, 28 Jul 2021 15:13:16 -0400 Subject: [PATCH] feature(enum) Separate enum declarations from class declarations Signed-off-by: jeromesimeon --- src/concerto/metamodel@0.2.0.cto | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/concerto/metamodel@0.2.0.cto b/src/concerto/metamodel@0.2.0.cto index 8e68100..14ef3cb 100644 --- a/src/concerto/metamodel@0.2.0.cto +++ b/src/concerto/metamodel@0.2.0.cto @@ -56,14 +56,30 @@ concept IdentifiedBy extends Identified { o String name } +concept EnumDeclaration { + // TODO use regex /^(?!null|true|false)(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*/u + @FormEditor("title", "Enum Name") + o String name default="ClassName" // regex=/^(?!null|true|false)(\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\S|\\u200C|\\u200D)*$/ + o EnumFieldDeclaration[] fields +} + +concept EnumFieldDeclaration { + // TODO Allow regex modifiers e.g. //ui + // regex /^(?!null|true|false)(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\pLm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*/u + // This regex is an approximation of what the parser accepts without using unicode character classes + o String name default="fieldName" // regex=/^(?!null|true|false)(\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\S|\\u200C|\\u200D)*$/ + @FormEditor("hide", true) + o Decorator[] decorators optional +} + @FormEditor("defaultSubclass","concerto.metamodel.ConceptDeclaration") abstract concept ClassDeclaration { + // TODO use regex /^(?!null|true|false)(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*/u + @FormEditor("title", "Class Name") + o String name default="ClassName" // regex=/^(?!null|true|false)(\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\S|\\u200C|\\u200D)*$/ @FormEditor("hide", true) o Decorator[] decorators optional o Boolean isAbstract default=false - // TODO use regex /^(?!null|true|false)(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*/u - @FormEditor("title", "Name") - o String name default="ClassName" // regex=/^(?!null|true|false)(\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\w|\\d|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\S|\\u200C|\\u200D)*$/ o Identified identified optional @FormEditor("title", "Super Type") o TypeIdentifier superType optional @@ -85,9 +101,6 @@ concept EventDeclaration extends ClassDeclaration { concept ConceptDeclaration extends ClassDeclaration { } -concept EnumDeclaration extends ClassDeclaration { -} - @FormEditor("defaultSubclass","concerto.metamodel.StringFieldDeclaration") abstract concept FieldDeclaration { // TODO Allow regex modifiers e.g. //ui @@ -102,9 +115,6 @@ abstract concept FieldDeclaration { o Decorator[] decorators optional } -concept EnumFieldDeclaration extends FieldDeclaration { -} - concept RelationshipDeclaration extends FieldDeclaration { @FormEditor("title", "Type Name", "selectOptions", "types") o TypeIdentifier type @@ -186,6 +196,8 @@ concept ModelFile { o String namespace default="my.namespace" @FormEditor("hide", true) o Import[] imports optional + @FormEditor("title", "Enums") + o EnumDeclaration[] enumDeclarations optional @FormEditor("title", "Classes") - o ClassDeclaration[] declarations optional + o ClassDeclaration[] classDeclarations optional }