Skip to content

Lda/assoc cocos - #136

Draft
0-ace-l0 wants to merge 7 commits into
devfrom
lda/assoc-cocos
Draft

0-ace-l0 wants to merge 7 commits into
devfrom
lda/assoc-cocos

Conversation

@0-ace-l0

@0-ace-l0 0-ace-l0 commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fix issue #123: Prevent Java classes on either association side and fix CD4A: Missing CDAssociations CoCos

Description: Issue 123
During code generation, associations require specific checks to ensure that only non-Java classes are used on either side. To resolve this issue, I introduced a new Context Condition (CDAssociationJavaClassTypeCoCo) that verifies whether the types on both the left and right sides of an association are valid non-Java classes.

Test:
To ensure that the CoCo functions correctly, I added a positive and a negative test within CDAssociationLeftAndRightJavaClassInvalidTest:

  • Positive test: In the positive test, valid classes are used as types on either side of the association.
  • Negative test: Ensures that Java classes on either side of the association throw the specific CoCo error with the correct error code.

Description: CD4A: Missing CDAssociations CoCos
Link: https://git.rwth-aachen.de/monticore/monticore/-/work_items/5059

Currently, it is possible to combine main association modifiers and individual role modifiers in ways that create ambiguous or conflicting meanings (e.g., marking the whole association as public while setting both roles to private).

Additionally, the SymTabCompleter did not handle all role modifiers for CDRoleSymbol (such as readOnly, abstract, and local).

Solution:

Association & Role CoCos

  • Modifier Transfer: Modifiers are transferred from the association to the role symbols if they are sensible for a role symbol and do not conflict with existing role modifiers.
  • Visibility CoCo: Added a CoCo for checking visibility overrides that throws a WARNING.
  • Static Modifier CoCo: Added a CoCo to forbid static as an association or role modifier.

Symbol Table & Unsupported Modifiers:

  • Updated SymTabCompleter to correctly support and set readOnly via roleSymbol.setIsReadOnly().
  • Added CoCos to explicitly forbid the use of unsupported modifiers like abstract and local on role symbols.

…cocos

# Conflicts:
#	cdlang/src/main/java/de/monticore/cdassociation/_symboltable/CDAssociationSymbolTableCompleter.java
#	cdlang/src/main/java/de/monticore/cdassociation/cocos/ebnf/CDAssociationModifierCoCo.java
…er side of an association + tests (solving issue #123) files: CDAssociationCoCos.java, CDAssociationJavaClassTypeCoCo.java, CDAssociationLeftAndRightJavaClassInvalidTest.java, CDAssociationLeftAndRightJavaClassInvalid.cd
@0-ace-l0
0-ace-l0 requested a review from MaxStachon September 28, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant