diff --git a/fr.inria.atlanmod.json.discoverer.zoo/src/fr/inria/atlanmod/json/discoverer/zoo/ModelDrawer.java b/fr.inria.atlanmod.json.discoverer.zoo/src/fr/inria/atlanmod/json/discoverer/zoo/ModelDrawer.java index aedfec6..f8c3621 100644 --- a/fr.inria.atlanmod.json.discoverer.zoo/src/fr/inria/atlanmod/json/discoverer/zoo/ModelDrawer.java +++ b/fr.inria.atlanmod.json.discoverer.zoo/src/fr/inria/atlanmod/json/discoverer/zoo/ModelDrawer.java @@ -21,10 +21,12 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import org.emftools.emf2gv.graphdesc.GraphdescPackage; @@ -76,8 +78,23 @@ else if (file.isFile() && file.getName().endsWith("ecore") && (overwrite || !pic e.printStackTrace(); } - List elements = new ArrayList<>(); + List elementsToUnset = new ArrayList<>(); TreeIterator treeIt = res.getAllContents(); + while(treeIt.hasNext()) { + EObject eObject = treeIt.next(); + EStructuralFeature esf = eObject.eClass().getEStructuralFeature("eAnnotations"); + if(esf != null && eObject.eIsSet(esf)) { + elementsToUnset.add(eObject); + } + } + + for(EObject eObject : elementsToUnset) { + EStructuralFeature esf = eObject.eClass().getEStructuralFeature("eAnnotations"); + eObject.eUnset(esf); + } + + List elements = new ArrayList<>(); + treeIt = res.getAllContents(); while(treeIt.hasNext()) { EObject eObject = treeIt.next(); elements.add(eObject); diff --git a/fr.inria.atlanmod.json.discoverer/src/fr/inria/atlanmod/discoverer/AnnotationHelper.java b/fr.inria.atlanmod.json.discoverer/src/fr/inria/atlanmod/discoverer/AnnotationHelper.java index 3d3f5e8..2edf0f2 100644 --- a/fr.inria.atlanmod.json.discoverer/src/fr/inria/atlanmod/discoverer/AnnotationHelper.java +++ b/fr.inria.atlanmod.json.discoverer/src/fr/inria/atlanmod/discoverer/AnnotationHelper.java @@ -145,6 +145,25 @@ public String getSourceName(EClass modelElement) { EAnnotation annotation = getCoverageAnnotation(modelElement); return annotation.getDetails().get(SOURCE_NAME_TAG); } + + /** + * Remove all the annotations. Be careful, the method returns the same epackage. + * + * @param ePackage + * @return + */ + public EPackage cleanAnnotations(EPackage ePackage) { + for(EClassifier eClassifier : ePackage.getEClassifiers()) { + eClassifier.getEAnnotations().clear(); + if (eClassifier instanceof EClass) { + EClass eClass = (EClass) eClassifier; + for(EStructuralFeature eStructuralFeature : eClass.getEStructuralFeatures()) { + eStructuralFeature.getEAnnotations().clear(); + } + } + } + return ePackage; + } }