From 5076b4e4e4c76cb3c24eaeb43792822e077b630e Mon Sep 17 00:00:00 2001 From: Stephan Seifermann Date: Thu, 15 Mar 2018 16:16:52 +0100 Subject: [PATCH] #254 Fixed exception on deletion of elements. --- ...UMLReferencingElementMissingElementResolution.xtend | 10 ++++++++-- .../transforms/Textual_to_Graphical_for_Class.qvto | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bundles/de.cooperateproject.modeling.textual.common/src/de/cooperateproject/modeling/textual/common/issues/CommonUMLReferencingElementMissingElementResolution.xtend b/bundles/de.cooperateproject.modeling.textual.common/src/de/cooperateproject/modeling/textual/common/issues/CommonUMLReferencingElementMissingElementResolution.xtend index a145292d2..8259c433b 100644 --- a/bundles/de.cooperateproject.modeling.textual.common/src/de/cooperateproject/modeling/textual/common/issues/CommonUMLReferencingElementMissingElementResolution.xtend +++ b/bundles/de.cooperateproject.modeling.textual.common/src/de/cooperateproject/modeling/textual/common/issues/CommonUMLReferencingElementMissingElementResolution.xtend @@ -6,6 +6,7 @@ import de.cooperateproject.modeling.textual.xtext.runtime.issues.automatedfixing import de.cooperateproject.modeling.textual.xtext.runtime.issues.automatedfixing.IResolvableChecker import org.eclipse.uml2.uml.Element import de.cooperateproject.modeling.textual.common.metamodel.textualCommons.PackageImport +import org.eclipse.emf.ecore.util.EcoreUtil class CommonUMLReferencingElementMissingElementResolution extends AutomatedIssueResolutionBase> { @@ -27,9 +28,14 @@ class CommonUMLReferencingElementMissingElementResolution extends AutomatedIssue if(!resolvePossible) return Void val commentedElement = element.commentedElement val Element umlCommentedElement = commentedElement.referencedElement - val umlComment = umlCommentedElement.nearestPackage.createOwnedComment() + + var umlComment = EcoreUtil.getAllContents(umlCommentedElement.eResource, true).filter(org.eclipse.uml2.uml.Comment).findFirst[c | c.annotatedElements.contains(umlCommentedElement)] + if (umlComment === null) { + umlComment = umlCommentedElement.nearestPackage.createOwnedComment() + umlComment.annotatedElements.add(umlCommentedElement) + } + umlComment.body = element.body - umlComment.annotatedElements.add(umlCommentedElement) element.referencedElement = umlComment } diff --git a/bundles/de.cooperateproject.modeling.transformation.cls/transforms/Textual_to_Graphical_for_Class.qvto b/bundles/de.cooperateproject.modeling.transformation.cls/transforms/Textual_to_Graphical_for_Class.qvto index 93b59d87c..5ad94f967 100644 --- a/bundles/de.cooperateproject.modeling.transformation.cls/transforms/Textual_to_Graphical_for_Class.qvto +++ b/bundles/de.cooperateproject.modeling.transformation.cls/transforms/Textual_to_Graphical_for_Class.qvto @@ -25,7 +25,7 @@ mapping cls::ClassDiagram::diagramToDiagram() : notation::Diagram { var allConnectors := self.getAllTransitiveConnectors(); var allPackages := self.getAllTransitivePackages(); - children := self.rootPackage.packages.oclAsType(cls::Package)->map packageToShape(); + children += self.rootPackage.packages.oclAsType(cls::Package)->map packageToShape(); children += self.rootPackage.classifiers->map classifierToShape(); children += allConnectors->selectByKind(cls::Association)->select(memberEnds->size() > 2)->map multiAssociationToShape(); // all nested in root children += self.rootPackage.connectors->select(isCommented())->selectByKind(textualCommons::Commentable).comments->map commentToShape();