Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/junit/plugins/uml/alf/org.eclipse.papyrus.uml.alf.tests/src/org/eclipse/papyrus/uml/alf/tests/mapper/AlfCompiler.java')
-rw-r--r--tests/junit/plugins/uml/alf/org.eclipse.papyrus.uml.alf.tests/src/org/eclipse/papyrus/uml/alf/tests/mapper/AlfCompiler.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/junit/plugins/uml/alf/org.eclipse.papyrus.uml.alf.tests/src/org/eclipse/papyrus/uml/alf/tests/mapper/AlfCompiler.java b/tests/junit/plugins/uml/alf/org.eclipse.papyrus.uml.alf.tests/src/org/eclipse/papyrus/uml/alf/tests/mapper/AlfCompiler.java
index 1cea8635fc5..8f3fcd38e89 100644
--- a/tests/junit/plugins/uml/alf/org.eclipse.papyrus.uml.alf.tests/src/org/eclipse/papyrus/uml/alf/tests/mapper/AlfCompiler.java
+++ b/tests/junit/plugins/uml/alf/org.eclipse.papyrus.uml.alf.tests/src/org/eclipse/papyrus/uml/alf/tests/mapper/AlfCompiler.java
@@ -60,17 +60,22 @@ public class AlfCompiler extends AlfMapper {
return result.getRootASTElement();
}
}
-
- public String getTextualRepresentation(Element element) {
+
+ public Comment getTextualRepresentationComment(Element element) {
for (Comment comment : element.getOwnedComments()) {
if (comment.isStereotypeApplied(this.textualRepresentationStereotype) &&
"Alf".equals(comment.getValue(this.textualRepresentationStereotype, "language"))) {
- return comment.getBody();
+ return comment;
}
}
return null;
}
+ public String getTextualRepresentation(Element element) {
+ Comment comment = this.getTextualRepresentationComment(element);
+ return comment == null? null: comment.getBody();
+ }
+
public void addTextualRepresentation(Element element, String textualRepresentation) {
Comment comment = UMLFactory.eINSTANCE.createComment();
comment.setBody(textualRepresentation);
@@ -82,6 +87,15 @@ public class AlfCompiler extends AlfMapper {
comment.applyStereotype(this.textualRepresentationStereotype);
comment.setValue(this.textualRepresentationStereotype, "language", "Alf");
}
+
+ public void updateTextualRepresentation(Element element, String textualRepresentation) {
+ Comment comment = this.getTextualRepresentationComment(element);
+ if (comment == null) {
+ this.addTextualRepresentation(element, textualRepresentation);
+ } else {
+ comment.setBody(textualRepresentation);
+ }
+ }
public void compile(NamedElement contextElement) throws ParsingError, MappingError {
String textualRepresentation = this.getTextualRepresentation(contextElement);
@@ -97,7 +111,7 @@ public class AlfCompiler extends AlfMapper {
alf.add(this.parse(textualRepresentation));
this.map(contextElement, alf);
- this.addTextualRepresentation(contextElement, textualRepresentation);
+ this.updateTextualRepresentation(contextElement, textualRepresentation);
}
}

Back to the top