33import org .eclipse .jdt .core .ICompilationUnit ;
44import org .eclipse .jdt .core .JavaModelException ;
55
6+ import eme .model .IntermediateModel ;
67import jce .codemanipulation .AbstractCodeManipulator ;
78import jce .properties .EcorificationProperties ;
89import jce .properties .TextProperty ;
910import jce .util .jdt .ASTUtil ;
1011
1112/**
12- * This class generates default constructors for every class that does not support default constructors. This is a
13- * unstable fix for the problem that Ecore factories require default constructors to create instances.
13+ * This class generates default constructors for every class that does not
14+ * support default constructors. This is a unstable fix for the problem that
15+ * Ecore factories require default constructors to create instances.
1416 * @author Timur Saglam
1517 */
1618public class DefaultConstructorGenerator extends AbstractCodeManipulator {
19+ private IntermediateModel model ;
1720
1821 /**
1922 * Simple constructor that sets the properties.
2023 * @param properties are the {@link EcorificationProperties}.
24+ * @param model is the {@link IntermediateModel} needed for the Ecorification
25+ * scope.
2126 */
22- public DefaultConstructorGenerator (EcorificationProperties properties ) {
27+ public DefaultConstructorGenerator (EcorificationProperties properties , IntermediateModel model ) {
2328 super (properties , properties .get (TextProperty .ECORE_PACKAGE ), properties .get (TextProperty .WRAPPER_PACKAGE ));
29+ this .model = model ;
2430 }
2531
2632 @ Override
2733 protected void manipulate (ICompilationUnit unit ) throws JavaModelException {
28- ASTUtil .applyVisitorModifications (unit , new ConstructorGenerationVisitor (), monitor );
34+ if (model .isTypeSelected (getPackageMemberName (unit ))) { // only apply on origin type in scope
35+ ASTUtil .applyVisitorModifications (unit , new ConstructorGenerationVisitor (), monitor );
36+ }
2937 }
3038}
0 commit comments