Skip to content

CD2JavaGenCoCos for the CDGenTool#86

Open
MaxStachon wants to merge 7 commits intodevfrom
msh/cdgen-cocos
Open

CD2JavaGenCoCos for the CDGenTool#86
MaxStachon wants to merge 7 commits intodevfrom
msh/cdgen-cocos

Conversation

@MaxStachon
Copy link
Collaborator

  • CDUniqueAssociation now allows "duplicate" associations with explicitly opposing navigation directions: e.g., A -> B, A <- B.
  • CDUniqueAssociation and CDUniqueAssociationInHierarchy output SourcePosition of the associations

@MaxStachon MaxStachon requested review from luepges and schmalzing and removed request for schmalzing February 6, 2026 15:22
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

✔️ Changes pass the MontiVerse

Project Status
details
Project Status
montiarc
umlp
sd
montifun
fd
automaton
sc
guidsl
artifacts
ocl
od
ucd
langexperiments
json
xml
cd2gui
mlc
cd4analysis
monticore_basic
class2mc

The MontiVerse is a collection of (internal and public) language projects.

/**
* @param node class to check.
*/
/** @param node class to check. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really a javadoc - -> remove?

import java.util.*;

/**
* Checks that there are not multiple occurrences of the same association between types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give an example?
What does "occurrences of the same association " mean?

* helper-method to find types by full-name
*/

private static boolean isNavigable(ASTCDAssociation assoc1, AssocSide side1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why static?
=> removes chance for overriding this method

AssocSide.LEFT))) {
checkRef(node, findTypeByFullName(assoc1, assoc1.getRightQualifiedName().getQName()),
findTypeByFullName(assoc2, assoc2.getRightQualifiedName().getQName()), assoc1);
if (deriveRoleName(assoc1, AssocSide.LEFT).equals(deriveRoleName(assoc2, AssocSide.LEFT))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why equals with enum (instead of ==)

}

Log.error("0xCDCE2: Could not find: " + fullName + ".");
Log.error("0xCDCE2: Could not find: " + fullName + ".", node.get_SourcePositionStart());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what context could fullName not be found?


Log.error("0xCDCE2: Could not find: " + fullName + ".");
Log.error("0xCDCE2: Could not find: " + fullName + ".", node.get_SourcePositionStart());
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a junit Test exist for this error?

Cause CoCos aggregate errors (quickFail==false), but findTypeByFullName might return null -> NPE

type2.getName()), assoc1.isPresent_SourcePositionStart() ? assoc1
.get_SourcePositionStart() : null, assoc1.isPresent_SourcePositionEnd() ? assoc1
.get_SourcePositionEnd() : null);
Log.error(String.format("0xCDCE1: %s has duplicate associations at %s and %s.", type1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does duplicate associations mean?

And also report the name of the assoc (if given?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And add some text, that duplicate associations are not supported

if (nextType.getFullName().equals(type2.getSymbol().getFullName())) {
Log.error(String.format("0xCDCE6: %s redefines an association of %s.", type1.getName(),
type2.getName()));
Log.error(String.format("0xCDCE6: %s redefines an association of %s from %s at %s", type1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some text, that "redefines an association " are not supported.

public void testNonOpposedAssocs3() throws IOException {
String model = "classdiagram DuplicateAssocs {" + " class A; class B;"
+ " association A -> B;" + " association B <- A;" + "}";
runTestForErrorCode(model, ERROR_CODE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to also check for the content of the error message?

Would help making sure the error messages are useful to users of a tool / makes review easier

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.

2 participants