-
Notifications
You must be signed in to change notification settings - Fork 11
Add Bidirectional Reference Logic #105
Add Bidirectional Reference Logic #105
Conversation
@@ -128,6 +135,48 @@ public GEdge create(EReference eReference) { | |||
.build(); | |||
} | |||
|
|||
private GEdge createBidirectionalEdge(EReference eReference, String source, String target) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we unify the code especially the big block of the GEdgeBuilder?
173f826
to
9f56014
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -150,4 +155,8 @@ public void remove(EObject eObject) { | |||
} | |||
semanticIndex.inverse().remove(eObject); | |||
} | |||
|
|||
public Set<Integer> getBidirectionalReferences() { | |||
return bidirectionalReferences; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashCodes shouldn't be used as IDs, as they're not guaranteed to be unique. Even if hashcode are used as a temporary solution, I would use a String-type Set, and a helper method to get a String-ID from an EReference (And there, you may use Integer.toString(ref.hashCode()), so it can easily be replaced later on with proper stable IDs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CamilleLetavernier The code has been adapted now - though it seems, that Github did not catch up with the squashed branches.
Is this now as it should be?
|
||
modelState.getIndex().getSemantic(elementId).ifPresent(element -> { | ||
if(element instanceof EReference && ((EReference) element).getEOpposite() != null) { | ||
EcoreUtil.remove(((EReference) element).getEOpposite()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, EcoreUtil.delete() should be preferred, as it will not only remove the object from the model, but also clean all references to that object (Preventing DanglingHref exceptions)
"No edge for label with id " + editLabelAction.getLabelId() + " found"); | ||
EReference reference_semantic = (EReference) getOrThrow(index.getSemantic(edge), | ||
"No semantic element for labelContainer with id " + edge.getId() + " found"); | ||
String edgeId = editLabelAction.getLabelId().split("_")[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the labelID is created from multiple segments, I would recommend moving the split to a helper method (e.g. ReferenceUtil.getEdgeID(labelId)). It makes it easier to understand the code, and easier to modify
c4bb258
to
f2bddde
Compare
f2bddde
to
41ec151
Compare
41ec151
to
a07a292
Compare
Resolves #38
Resolves jcebel#18
This need to be aligned with PR #99, as this one changes the logic of the labels.