Skip to content

Commit 5076b4e

Browse files
committed
#254 Fixed exception on deletion of elements.
1 parent c9c43db commit 5076b4e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

bundles/de.cooperateproject.modeling.textual.common/src/de/cooperateproject/modeling/textual/common/issues/CommonUMLReferencingElementMissingElementResolution.xtend

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import de.cooperateproject.modeling.textual.xtext.runtime.issues.automatedfixing
66
import de.cooperateproject.modeling.textual.xtext.runtime.issues.automatedfixing.IResolvableChecker
77
import org.eclipse.uml2.uml.Element
88
import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.PackageImport
9+
import org.eclipse.emf.ecore.util.EcoreUtil
910

1011
class CommonUMLReferencingElementMissingElementResolution extends AutomatedIssueResolutionBase<UMLReferencingElement<Element>> {
1112

@@ -27,9 +28,14 @@ class CommonUMLReferencingElementMissingElementResolution extends AutomatedIssue
2728
if(!resolvePossible) return Void
2829
val commentedElement = element.commentedElement
2930
val Element umlCommentedElement = commentedElement.referencedElement
30-
val umlComment = umlCommentedElement.nearestPackage.createOwnedComment()
31+
32+
var umlComment = EcoreUtil.getAllContents(umlCommentedElement.eResource, true).filter(org.eclipse.uml2.uml.Comment).findFirst[c | c.annotatedElements.contains(umlCommentedElement)]
33+
if (umlComment === null) {
34+
umlComment = umlCommentedElement.nearestPackage.createOwnedComment()
35+
umlComment.annotatedElements.add(umlCommentedElement)
36+
}
37+
3138
umlComment.body = element.body
32-
umlComment.annotatedElements.add(umlCommentedElement)
3339
element.referencedElement = umlComment
3440
}
3541

bundles/de.cooperateproject.modeling.transformation.cls/transforms/Textual_to_Graphical_for_Class.qvto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mapping cls::ClassDiagram::diagramToDiagram() : notation::Diagram {
2525
var allConnectors := self.getAllTransitiveConnectors();
2626
var allPackages := self.getAllTransitivePackages();
2727

28-
children := self.rootPackage.packages.oclAsType(cls::Package)->map packageToShape();
28+
children += self.rootPackage.packages.oclAsType(cls::Package)->map packageToShape();
2929
children += self.rootPackage.classifiers->map classifierToShape();
3030
children += allConnectors->selectByKind(cls::Association)->select(memberEnds->size() > 2)->map multiAssociationToShape(); // all nested in root
3131
children += self.rootPackage.connectors->select(isCommented())->selectByKind(textualCommons::Commentable).comments->map commentToShape();

0 commit comments

Comments
 (0)