Commit 178b9440 authored by Erwan Bousse's avatar Erwan Bousse
Browse files

Beggining maveninsation

parent 5ab9e438
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CloningMaterialGenerator
Bundle-SymbolicName: fr.inria.diverse.cloning.materialgenerator;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 0.1.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.gmt.modisco.java.generation;bundle-version="0.11.1",
org.eclipse.emf.common,
......
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.inria.diverse.cloning</groupId>
<artifactId>fr.inria.diverse.cloning.materialgenerator</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>fr.inria.diverse.cloning</groupId>
<artifactId>parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.inria.diverse.cloning</groupId>
<artifactId>fr.inria.diverse.cloning.materialgenerator</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>fr.inria.diverse.cloning</groupId>
<artifactId>parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>../fr.inria.diverse.cloning.master/pom.xml</relativePath>
</parent>
</project>
......@@ -5,12 +5,12 @@ import java.io.IOException;
import java.io.PrintStream;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import fr.inria.diverse.cloning.materialgenerator.tagger.Tagger;
import fr.inria.diverse.cloning.materialgenerator.util.CodeGeneration;
import fr.inria.diverse.cloning.runtime.common.CloningMaterial;
import fr.inria.diverse.cloning.runtime.common.MetamodelTags;
import fr.inria.diverse.cloning.runtime.emfextension.impl.LooseCopier;
public class CloningMaterialClassGenerator {
/**
......@@ -44,8 +44,9 @@ public class CloningMaterialClassGenerator {
// Imports not metamodel dependent
imports += "import " + CloningMaterial.class.getCanonicalName() + ";\n";
imports += "import " + LooseCopier.class.getCanonicalName() + ";\n";
//imports += "import " + LooseCopier.class.getCanonicalName() + ";\n";
imports += "import " + MetamodelTags.class.getCanonicalName() + ";\n";
imports += "import " + Copier.class.getCanonicalName() + ";\n";
// Class declaration
String classdef = "public class " + className + " implements " + CloningMaterial.class.getSimpleName()
......@@ -75,8 +76,11 @@ public class CloningMaterialClassGenerator {
// createLightCopier method declaration
String copierClassName = CodeGeneration.firstCharUp(tagger.getMetamodelName() + tagger.getCloningName()
+ Constants.COPIER_SUFFIX);
classdef += "public " + LooseCopier.class.getSimpleName() + " createLightCopier() {\n";
classdef += "return new " + copierClassName + "();";
classdef += "public " + Copier.class.getSimpleName() + " createCopier() {\n";
if (tagger.mayTagClassesPartShareable())
classdef += "return new " + copierClassName + "();";
else
classdef += "return new Copier ();";
// end createLightCopier method declaration
classdef += "}\n";
......
......@@ -2,7 +2,7 @@ package fr.inria.diverse.cloning.materialgenerator.generators;
public class Constants {
public static final String COPIER_SUFFIX = "LightCopier";
public static final String COPIER_SUFFIX = "Copier";
public static final String TAGS_SUFFIX = "Tags";
public static final String CLONING_MATERIAL__SUFFIX = "CloningMaterial";
public static final String METRICS__SUFFIX = "Metrics";
......
......@@ -544,7 +544,8 @@ public class EMFImpl2PImpl {
File outputDir = new File(srcOutputFolder + "/" + generateFullyQualifiedName(pack, "/"));
// Generating the copier
LightCopierGenerator.generate(tagger.getMetamodel(),generateFullyQualifiedName(pack), outputDir, tagger);
if (tagger.mayTagClassesPartShareable())
LightCopierGenerator.generate(tagger.getMetamodel(),generateFullyQualifiedName(pack), outputDir, tagger);
//generateCopierClass(tagger.getMetamodel(),generateFullyQualifiedName(pack), outputDir, tagger);
......
......@@ -3,6 +3,8 @@ package fr.inria.diverse.cloning.materialgenerator.start;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import org.eclipse.core.resources.IResource;
......@@ -26,8 +28,10 @@ import fr.inria.diverse.cloning.materialgenerator.generators.EMFCodeGenerator.EM
import fr.inria.diverse.cloning.materialgenerator.generators.EMFImpl2PImpl;
import fr.inria.diverse.cloning.materialgenerator.generators.ManifestEditor;
import fr.inria.diverse.cloning.materialgenerator.tagger.Tagger;
import fr.inria.diverse.cloning.materialgenerator.tagger.impl.DeepTagger;
import fr.inria.diverse.cloning.materialgenerator.tagger.impl.MutClassesOnlyTagger;
import fr.inria.diverse.cloning.materialgenerator.tagger.impl.DeepCloningTagger;
import fr.inria.diverse.cloning.materialgenerator.tagger.impl.ShareFieldsOnlyTagger;
import fr.inria.diverse.cloning.materialgenerator.tagger.impl.ShareAllTagger;
import fr.inria.diverse.cloning.materialgenerator.tagger.impl.ShareObjOnlyTagger;
import fr.inria.diverse.cloning.runtime.util.Log;
public class Start {
......@@ -54,9 +58,10 @@ public class Start {
rs.getResource(URI.createFileURI(f.getAbsolutePath()), true);
// Tagging
Tagger tagger = new MutClassesOnlyTagger(rs, metamodelName);
Tagger tagger2 = new DeepTagger(rs, metamodelName);
Collection<Tagger> taggers = Arrays.asList(new DeepCloningTagger(rs, metamodelName),
new ShareFieldsOnlyTagger(rs, metamodelName), new ShareObjOnlyTagger(rs, metamodelName),
new ShareAllTagger(rs, metamodelName));
// Discovering the model from the project
DiscoverJavaModelFromJavaProject discoverer = new DiscoverJavaModelFromJavaProject();
......@@ -73,21 +78,30 @@ public class Start {
String srcOutputFolder = new File(emfProjectFolder, "src").getAbsolutePath();
// Calling the partial implementations transformer with one tagger
Model originalModel = new EMFImpl2PImpl(javaModel, tagger, true).transform2PImpl(srcOutputFolder);
new EMFImpl2PImpl(originalModel, tagger2, true).transform2PImpl(srcOutputFolder);
// Generating the code from the obtained model
GenerateJavaExtended javaGenerator = new GenerateJavaExtended(javaModel, new File(srcOutputFolder),
new ArrayList<Object>());
javaGenerator.doGenerate(null);
// Generating the code from the obtained model
GenerateJavaExtended javaGenerator2 = new GenerateJavaExtended(originalModel, new File(srcOutputFolder),
new ArrayList<Object>());
javaGenerator2.doGenerate(null);
Model brandNew;
Model toProcess = javaModel;
for (Tagger t : taggers) {
brandNew = new EMFImpl2PImpl(toProcess, t, true).transform2PImpl(srcOutputFolder);
GenerateJavaExtended javaGenerator = new GenerateJavaExtended(toProcess, new File(srcOutputFolder),
new ArrayList<Object>());
javaGenerator.doGenerate(null);
toProcess = brandNew;
}
//new EMFImpl2PImpl(originalModel, tagger2, true).transform2PImpl(srcOutputFolder);
// // Generating the code from the obtained model
// GenerateJavaExtended javaGenerator = new GenerateJavaExtended(javaModel, new File(srcOutputFolder),
// new ArrayList<Object>());
// javaGenerator.doGenerate(null);
//
// // Generating the code from the obtained model
// GenerateJavaExtended javaGenerator2 = new GenerateJavaExtended(originalModel, new File(srcOutputFolder),
// new ArrayList<Object>());
// javaGenerator2.doGenerate(null);
// Adding a dependency in the manifest
ManifestEditor manEdit= new ManifestEditor(javaProject.getProject());
ManifestEditor manEdit = new ManifestEditor(javaProject.getProject());
manEdit.addDependency("fr.inria.diverse.cloning.runtime");
manEdit.save();
......@@ -109,5 +123,4 @@ public class Start {
e.printStackTrace();
}
}
}
......@@ -11,6 +11,8 @@ public interface Tagger {
public abstract void recomputeTags();
public abstract boolean mayTagClassesShareable();
public abstract boolean mayTagClassesPartShareable();
public abstract String getSuffix();
......
......@@ -62,12 +62,6 @@ public abstract class AbstractTagger implements Tagger {
return f.getName().endsWith("_m");
}
/*
* protected static Set<EClass> findAllLoadedClasses() { Set<EClass> allLoadedEClasses = new HashSet<EClass>(); for
* (Object o : EPackage.Registry.INSTANCE.values()) { EPackage p = (EPackage) o; if (p.getNsURI() !=
* "http://www.eclipse.org/emf/2002/Ecore") { for (EClassifier c : p.getEClassifiers()) { if (c instanceof EClass)
* allLoadedEClasses.add((EClass) c); } } } return allLoadedEClasses; }
*/
protected enum PropertiesMutability {
allMutable, someMutable, noneMutable
......@@ -75,28 +69,6 @@ public abstract class AbstractTagger implements Tagger {
/*
* protected static Set<Set<Resource>> findAllLoadedMetamodels() { Set<Set<Resource>> result = new
* HashSet<Set<Resource>>();
*
* // For each loaded epackage (excepted ecore itself) for (Object o : EPackage.Registry.INSTANCE.values()) {
* EPackage p = (EPackage)o; if (p.getNsURI()!="http://www.eclipse.org/emf/2002/Ecore") {
*
*
* // We find or create the metamodel for this package Set<Resource> pMetamodel = null; for (Set<Resource> metamodel
* : result) { if (metamodel.contains(p.eResource())) { pMetamodel = metamodel; break; } } if (pMetamodel == null){
* pMetamodel = new HashSet<Resource>(); pMetamodel.add(p.eResource()); result.add(pMetamodel); }
*
*
*
* // We look at the content (classes) for(EClassifier c : p.getEClassifiers()) { if (c instanceof EClass) { // For
* each class, we check that it does try to access to another resource // If it does, we add the resource of the
* class to the metamodel for (EReference r : ((EClass)c).getEAllReferences()) {
* pMetamodel.add(r.getEReferenceType().eResource()); } } } } }
*
* System.out.println("Found metamodels"); return result; }
*/
@Override
public ClassTag getTagOfEClass(EClass c) {
if (classesTags.containsKey(c)) {
......
package fr.inria.diverse.cloning.materialgenerator.tagger.impl;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
import fr.inria.diverse.cloning.materialgenerator.tagger.Tagger;
import fr.inria.diverse.cloning.runtime.common.ClassTag;
public class DeepCloningTagger implements Tagger {
protected String metamodelname;
protected ResourceSet metamodel;
public DeepCloningTagger(ResourceSet metamodel, String metamodelname) {
this.metamodel = metamodel;
this.metamodelname = metamodelname;
}
@Override
public void recomputeTags() {
// Nothing to do
}
@Override
public boolean mayTagClassesShareable() {
return false;
}
@Override
public String getSuffix() {
return "DeepCloningProxy";
}
@Override
public String getCloningName() {
return "DeepCloning";
}
@Override
public ClassTag getTagOfEClass(EClass c) {
return ClassTag.NOT_SHAREABLE;
}
@Override
public ResourceSet getMetamodel() {
return metamodel;
}
@Override
public boolean isPropertyShareable(EStructuralFeature property) {
return false;
}
@Override
public String getMetamodelName() {
return metamodelname;
}
@Override
public boolean mayTagClassesPartShareable() {
return false;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment