Skip to content

Commit

Permalink
#254 Fixed exception on deletion of elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
seiferma committed Mar 15, 2018
1 parent c9c43db commit 5076b4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<UMLReferencingElement<Element>> {

Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5076b4e

Please sign in to comment.