Skip to content

Commit

Permalink
JNG-5928 groups added to views (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Sep 25, 2024
1 parent 3d1a936 commit 18faac2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@ class NameDuplicationDetectionTests {
type string String min-size:0 max-size:128;
entity A {
relation B b opposite a;
field String b;
field String b;
}
entity B {
relation A a opposite b;
relation A a opposite-add:b;
}
'''.parse => [
assertDuplicateMemberName("Duplicate member declaration: 'b'", JsldslPackage::eINSTANCE.entityFieldDeclaration)
assertDuplicateMemberName("Duplicate member declaration: 'b'", JsldslPackage::eINSTANCE.entityRelationDeclaration)
]
m | m.assertError(JsldslPackage::eINSTANCE.entityRelationOppositeInjected, JslDslValidator.DUPLICATE_MEMBER_NAME)
]
}

@Test
Expand Down Expand Up @@ -81,7 +79,7 @@ class NameDuplicationDetectionTests {
field String name;
}
'''.parse => [
assertOppositeMismatchError("Duplicate member declaration: 'name'", JsldslPackage::eINSTANCE.entityFieldDeclaration)
m | m.assertError(JsldslPackage::eINSTANCE.entityDeclaration, JslDslValidator.INHERITED_MEMBER_NAME_COLLISION)
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class TransferTests {
field Integer e1;
}
'''.parse => [
m | m.assertError(JsldslPackage::eINSTANCE.transferFieldDeclaration, JslDslValidator.DUPLICATE_MEMBER_NAME)
m | m.assertError(JsldslPackage::eINSTANCE.transferFieldDeclaration, JslDslValidator.DUPLICATE_DECLARATION_NAME)
]
}

Expand All @@ -330,7 +330,7 @@ class TransferTests {
field String f1;
}
'''.parse => [
m | m.assertError(JsldslPackage::eINSTANCE.transferFieldDeclaration, JslDslValidator.DUPLICATE_MEMBER_NAME)
m | m.assertError(JsldslPackage::eINSTANCE.transferFieldDeclaration, JslDslValidator.DUPLICATE_DECLARATION_NAME)
]
}

Expand Down
40 changes: 36 additions & 4 deletions model/src/main/java/hu/blackbelt/judo/meta/jsl/JslDsl.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ UIViewMemberDeclaration
: UIViewWidgetDeclaration
| UIViewLinkDeclaration
| UIViewTableDeclaration
| UIViewPanelDeclaration
;

UIViewWidgetDeclaration
Expand All @@ -290,6 +291,27 @@ UIViewTableDeclaration
SC
;


UIViewPanelDeclaration
: UIViewGroupDeclaration
| UIViewTabsDeclaration
;


UIViewGroupDeclaration returns UIViewPanelDeclaration
: {UIViewGroupDeclaration}
KW_GROUP Named
modifiers += (EnabledModifier | VisualModifier | FrameModifier | OrientationModifier | HAlignModifier | VAlignModifier | StretchModifier)*
BLOCK_START (members += UIViewMemberDeclaration)* BLOCK_END
;

UIViewTabsDeclaration returns UIViewPanelDeclaration
: {UIViewTabsDeclaration}
KW_TABS Named
modifiers += (VisualModifier | OrientationModifier | FrameModifier | StretchModifier)*
BLOCK_START (panels += UIViewPanelDeclaration)* BLOCK_END
;

/****************************
* UIRow
****************************/
Expand Down Expand Up @@ -333,22 +355,32 @@ UIMenuDeclaration
UIMenuMemberDeclaration
: UIMenuLinkDeclaration
| UIMenuTableDeclaration
| UIMenuGroupDeclaration
;

UIMenuLinkDeclaration
: KW_LINK referenceType = [UIViewDeclaration | ModelName] Named
UIMenuLinkDeclaration returns UIMenuMemberDeclaration
: {UIMenuLinkDeclaration}
KW_LINK referenceType = [UIViewDeclaration | ModelName] Named
LTE actorAccess = ActorAccessReference
modifiers += (VisualModifier | CreateFormModifier | UpdateViewModifier)*
SC
;

UIMenuTableDeclaration
: KW_TABLE referenceType = [UIRowDeclaration | ModelName] Named
UIMenuTableDeclaration returns UIMenuMemberDeclaration
: {UIMenuTableDeclaration}
KW_TABLE referenceType = [UIRowDeclaration | ModelName] Named
LTE actorAccess = ActorAccessReference
modifiers += (VisualModifier | CreateFormModifier | UpdateViewModifier)*
SC
;

UIMenuGroupDeclaration returns UIMenuMemberDeclaration
: {UIMenuGroupDeclaration}
KW_GROUP Named
modifiers += (LabelModifier | IconModifier | HiddenModifier)*
BLOCK_START (members += UIMenuMemberDeclaration)* BLOCK_END
;

/****************************
* View
****************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,15 +818,15 @@ class JslDslValidator extends AbstractJslDslValidator {
}
}

@Check
def checkForDuplicateNameForEntityMemberDeclaration(EntityMemberDeclaration member) {
if (member instanceof Named && (member.eContainer as EntityDeclaration).getMemberNames(member).map[n | n.toLowerCase].contains(member.name.toLowerCase)) {
error("Duplicate member declaration: '" + member.name + "'",
member.nameAttribute,
DUPLICATE_MEMBER_NAME,
member.name)
}
}
// @Check
// def checkForDuplicateNameForEntityMemberDeclaration(EntityMemberDeclaration member) {
// if (member instanceof Named && (member.eContainer as EntityDeclaration).getMemberNames(member).map[n | n.toLowerCase].contains(member.name.toLowerCase)) {
// error("Duplicate member declaration: '" + member.name + "'",
// member.nameAttribute,
// DUPLICATE_MEMBER_NAME,
// member.name)
// }
// }

@Check
def checkEntityMemberDeclarationLength(EntityMemberDeclaration member) {
Expand Down Expand Up @@ -886,19 +886,34 @@ class JslDslValidator extends AbstractJslDslValidator {
}
}

@Check
def checkForDuplicateNameForDeclaration(Declaration declaration) {
if (!(declaration.eContainer instanceof ModelDeclaration)) return;

if (declaration instanceof FunctionDeclaration) return;
if (declaration instanceof LambdaDeclaration) return;
// @Check
// def checkForDuplicateNameForDeclaration(Declaration declaration) {
// if (!(declaration.eContainer instanceof ModelDeclaration)) return;
//
// if (declaration instanceof FunctionDeclaration) return;
// if (declaration instanceof LambdaDeclaration) return;
//
// if ((declaration.eContainer as ModelDeclaration).getDeclarationNames(declaration).map[n | n.toLowerCase].contains(declaration.name.toLowerCase)) {
// error("Duplicate declaration name: '" + declaration.name + "'",
// declaration.nameAttribute,
// DUPLICATE_DECLARATION_NAME,
// declaration.name)
// }
// }

if ((declaration.eContainer as ModelDeclaration).getDeclarationNames(declaration).map[n | n.toLowerCase].contains(declaration.name.toLowerCase)) {
error("Duplicate declaration name: '" + declaration.name + "'",
declaration.nameAttribute,
@Check
def checkForDuplicateName(Named named) {
if (named instanceof ModelDeclaration) return;
if (named instanceof FunctionDeclaration) return;
if (named instanceof LambdaDeclaration) return;

if (named.eContainer.eContents.filter[o | o instanceof Named].map[o | o.name.toLowerCase].filter[n | n == named.name.toLowerCase].size > 1) {
error("Duplicate declaration name: '" + named.name + "'",
named.nameAttribute,
DUPLICATE_DECLARATION_NAME,
declaration.name)
}
named.name)

}
}

@Check
Expand Down Expand Up @@ -1480,36 +1495,26 @@ class JslDslValidator extends AbstractJslDslValidator {
}
}

@Check
def checkForDuplicateNameForTransferMemberDeclaration(TransferMemberDeclaration member) {
// if (!(member instanceof TransferFieldDeclaration || member instanceof TransferRelationDeclaration)) {
// return
// }

val TransferDeclaration transfer = member.parentContainer(TransferDeclaration)

if (transfer === null) {
return
}

if (transfer.map !== null && member.name.toLowerCase.equals(transfer.map.name.toLowerCase)) {
error("Member declaration name conflicts with mapping field name: '" + member.name + "'.",
member.nameAttribute,
DUPLICATE_MEMBER_NAME,
member.name)
}

// val members = transfer.eAllContents.filter[d | d instanceof TransferFieldDeclaration || d instanceof TransferRelationDeclaration].map[d | d as TransferMemberDeclaration].toList
val members = transfer.eAllContents.filter[d | d instanceof TransferMemberDeclaration].map[d | d as TransferMemberDeclaration].toList

if (members.filter[m | m.name.toLowerCase.equals(member.name.toLowerCase)].size > 1) {
error("Duplicate member declaration: '" + member.name + "'.",
member.nameAttribute,
DUPLICATE_MEMBER_NAME,
member.name)
}
}

// @Check
// def checkForDuplicateNameForTransferMemberDeclaration(TransferMemberDeclaration member) {
// val TransferDeclaration transfer = member.parentContainer(TransferDeclaration)
//
// if (transfer.map !== null && member.name.toLowerCase.equals(transfer.map.name.toLowerCase)) {
// error("Member declaration name conflicts with mapping field name: '" + member.name + "'.",
// member.nameAttribute,
// DUPLICATE_MEMBER_NAME,
// member.name)
// }
//
// val members = transfer.eAllContents.filter[d | d instanceof TransferMemberDeclaration].map[d | d as TransferMemberDeclaration].toList
//
// if (members.filter[m | m.name.toLowerCase.equals(member.name.toLowerCase)].size > 1) {
// error("Duplicate member declaration: '" + member.name + "'.",
// member.nameAttribute,
// DUPLICATE_MEMBER_NAME,
// member.name)
// }
// }

@Check
def checkGuard(GuardModifier guard) {
Expand Down

0 comments on commit 18faac2

Please sign in to comment.