Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-10-28 16:01:36 +0000
committerEd Willink2016-10-29 17:36:20 +0000
commitfb0d96788c5b635bdd9eab8ddffe6196c67e82ec (patch)
tree2b50de3137f2d0a649bfa5a82339cc649e3a6a17
parent10bff90c6e36012238febe96f3ec8e762376d1a1 (diff)
downloadorg.eclipse.qvtd-fb0d96788c5b635bdd9eab8ddffe6196c67e82ec.tar.gz
org.eclipse.qvtd-fb0d96788c5b635bdd9eab8ddffe6196c67e82ec.tar.xz
org.eclipse.qvtd-fb0d96788c5b635bdd9eab8ddffe6196c67e82ec.zip
[506716] Hide QVTp2QVTg, CompilerChain inside SchedulerConstants
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java35
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTg.java35
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTs.java9
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/SchedulerConstants.java28
4 files changed, 27 insertions, 80 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java
index 2ece8bd7d..c65f7434d 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java
@@ -39,9 +39,7 @@ import org.eclipse.qvtd.codegen.qvti.java.QVTiCodeGenerator;
import org.eclipse.qvtd.compiler.internal.qvtc2qvtu.QVTc2QVTu;
import org.eclipse.qvtd.compiler.internal.qvtc2qvtu.QVTuConfiguration;
import org.eclipse.qvtd.compiler.internal.qvtm2qvtp.QVTm2QVTp;
-import org.eclipse.qvtd.compiler.internal.qvtp2qvts.ClassRelationships;
import org.eclipse.qvtd.compiler.internal.qvtp2qvts.MultiRegion;
-import org.eclipse.qvtd.compiler.internal.qvtp2qvts.QVTp2QVTg;
import org.eclipse.qvtd.compiler.internal.qvtp2qvts.QVTp2QVTs;
import org.eclipse.qvtd.compiler.internal.qvtp2qvts.RootScheduledRegion;
import org.eclipse.qvtd.compiler.internal.qvts2qvti.QVTs2QVTi;
@@ -54,12 +52,9 @@ import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseEnvironmentFactory.CreateStrategy;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
-import org.eclipse.qvtd.pivot.qvtcore.analysis.QVTcoreDomainUsageAnalysis;
-import org.eclipse.qvtd.pivot.qvtcore.analysis.RootDomainUsageAnalysis;
import org.eclipse.qvtd.pivot.qvtcore.utilities.QVTcEnvironmentFactory;
import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTransformation;
import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiEnvironmentFactory;
-import org.eclipse.qvtd.pivot.schedule.Schedule;
import org.eclipse.qvtd.runtime.evaluation.Transformer;
public abstract class AbstractCompilerChain extends CompilerUtil implements CompilerChain
@@ -238,23 +233,14 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
QVTp2QVTs.DEBUG_GRAPHS.setState(getOption(CompilerChain.DEBUG_KEY) == Boolean.TRUE);
}
- public @NonNull RootScheduledRegion execute(@NonNull Resource pResource, @NonNull RootDomainUsageAnalysis domainUsageAnalysis, @NonNull ClassRelationships classRelationships) throws IOException {
+ public @NonNull RootScheduledRegion execute(@NonNull Resource pResource) throws IOException {
CreateStrategy savedStrategy = environmentFactory.setCreateStrategy(QVTcEnvironmentFactory.CREATE_STRATEGY);
try {
- QVTp2QVTg qvtp2qvtg = new QVTp2QVTg(domainUsageAnalysis, classRelationships);
- URI qvtgURI = compilerChain.getURI(QVTS_STEP, URI_KEY);
- Resource gResource = createResource(qvtgURI);
- Transformation asTransformation = getTransformation(pResource);
- domainUsageAnalysis.analyzeTransformation(asTransformation);
- qvtp2qvtg.run(pResource, gResource);
- gResource.getContents().add(domainUsageAnalysis.getPrimitiveTypeModel());
- saveResource(gResource);
-
- Schedule schedule = getSchedule(gResource);
- QVTp2QVTs qvtp2qvts = new QVTp2QVTs(this, environmentFactory, schedule, qvtp2qvtg, domainUsageAnalysis);
+ Transformation asTransformation = AbstractCompilerChain.getTransformation(pResource);
+ QVTp2QVTs qvtp2qvts = new QVTp2QVTs(this, environmentFactory, asTransformation);
MultiRegion multiRegion = qvtp2qvts.transform();
throwCompilerChainExceptionForErrors();
- String rootName = ClassUtil.nonNullState(qvtp2qvts.getDependencyGraph().eResource().getURI().trimFileExtension().trimFileExtension().lastSegment());
+ String rootName = ClassUtil.nonNullState(asTransformation.eResource().getURI().trimFileExtension().trimFileExtension().lastSegment());
QVTs2QVTs qvts2qvts = new QVTs2QVTs(this, environmentFactory, rootName);
RootScheduledRegion rootRegion = qvts2qvts.transform(multiRegion);
throwCompilerChainExceptionForErrors();
@@ -266,15 +252,6 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
environmentFactory.setCreateStrategy(savedStrategy);
}
}
-
- private @NonNull Schedule getSchedule(@NonNull Resource gResource) throws IOException {
- for (EObject eContent : gResource.getContents()) {
- if (eContent instanceof Schedule) {
- return (Schedule) eContent;
- }
- }
- throw new IOException("No Schedule element in " + gResource.getURI());
- }
}
protected static class QVTs2QVTiCompilerStep extends AbstractCompilerStep
@@ -564,9 +541,7 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
}
protected @NonNull ImperativeTransformation qvtp2qvti(@NonNull Resource pResource) throws IOException {
- RootDomainUsageAnalysis domainAnalysis = new QVTcoreDomainUsageAnalysis(environmentFactory);
- ClassRelationships classRelationships = new ClassRelationships(environmentFactory);
- RootScheduledRegion rootRegion = qvtp2qvtsCompilerStep.execute(pResource, domainAnalysis, classRelationships);
+ RootScheduledRegion rootRegion = qvtp2qvtsCompilerStep.execute(pResource);
return qvts2qvtiCompilerStep.execute(rootRegion);
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTg.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTg.java
index f87f6c607..efad5e325 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTg.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTg.java
@@ -23,7 +23,6 @@ import java.util.Set;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.CallExp;
@@ -37,7 +36,6 @@ import org.eclipse.ocl.pivot.NavigationCallExp;
import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.OperationCallExp;
-import org.eclipse.ocl.pivot.Package;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.ShadowExp;
import org.eclipse.ocl.pivot.Type;
@@ -46,7 +44,6 @@ import org.eclipse.ocl.pivot.Variable;
import org.eclipse.ocl.pivot.VariableExp;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
-import org.eclipse.qvtd.pivot.qvtbase.BaseModel;
import org.eclipse.qvtd.pivot.qvtbase.Domain;
import org.eclipse.qvtd.pivot.qvtbase.Rule;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
@@ -165,36 +162,14 @@ public class QVTp2QVTg {
}
}
- public void run(@NonNull Resource qvtpModel, @NonNull Resource qvtsModel) {
- clearCaches();
-
- for (EObject eObject : qvtpModel.getContents()) {
- if (eObject instanceof BaseModel) {
- transformPackages(((BaseModel)eObject).getOwnedPackages());
- }
- }
-
- // We add the result to the output result
- qvtsModel.getContents().clear();
- qvtsModel.getContents().add(dg);
- }
-
- protected void transformPackages(@NonNull List<Package> pPackages) {
- for (org.eclipse.ocl.pivot.Package pPackage : pPackages) {
- for (org.eclipse.ocl.pivot.Class pClass : pPackage.getOwnedClasses()) {
- if (pClass instanceof Transformation) {
- transformTransformation((Transformation)pClass);
- }
- }
- transformPackages(pPackage.getOwnedPackages());
- }
- }
- protected void transformTransformation(@NonNull Transformation pTransformation) {
+ public @NonNull Schedule transformTransformation(@NonNull Transformation pTransformation) {
+ clearCaches();
computeInitialCaches(pTransformation);
for (Rule pRule : pTransformation.getRule()) {
createMappingAction((Mapping) pRule);
}
+ return dg;
}
protected MappingAction createMappingAction(Mapping mapping) {
@@ -288,10 +263,6 @@ public class QVTp2QVTg {
return cDatum;
}
- public @NonNull ClassRelationships getClassRelationships() {
- return classRelationships;
- }
-
@NonNull
protected PropertyDatum createPropertyDatum(@NonNull TypedModel typedModel, org.eclipse.ocl.pivot.@NonNull Class context, Property property) {
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTs.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTs.java
index ab17ce2b6..f5622e34a 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTs.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/QVTp2QVTs.java
@@ -36,11 +36,10 @@ import org.eclipse.qvtd.compiler.CompilerConstants;
import org.eclipse.qvtd.compiler.CompilerProblem;
import org.eclipse.qvtd.compiler.ProblemHandler;
import org.eclipse.qvtd.compiler.internal.qvts2qvts.Region2Depth;
-import org.eclipse.qvtd.pivot.qvtcore.analysis.RootDomainUsageAnalysis;
+import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.schedule.AbstractAction;
import org.eclipse.qvtd.pivot.schedule.ClassDatum;
import org.eclipse.qvtd.pivot.schedule.MappingAction;
-import org.eclipse.qvtd.pivot.schedule.Schedule;
import org.eclipse.qvtd.pivot.schedule.utilities.DependencyUtil;
public class QVTp2QVTs extends SchedulerConstants
@@ -70,10 +69,10 @@ public class QVTp2QVTs extends SchedulerConstants
private final @NonNull List<@NonNull AbstractAction> orderedActions;
- public QVTp2QVTs(@NonNull ProblemHandler problemHandler, @NonNull EnvironmentFactory environmentFactory, @NonNull Schedule schedule, @NonNull QVTp2QVTg qvtp2qvtg, @NonNull RootDomainUsageAnalysis domainAnalysis) {
- super(environmentFactory, schedule, qvtp2qvtg, domainAnalysis);
+ public QVTp2QVTs(@NonNull ProblemHandler problemHandler, @NonNull EnvironmentFactory environmentFactory, @NonNull Transformation asTransformation) {
+ super(environmentFactory, asTransformation);
this.problemHandler = problemHandler;
- DependencyUtil.NaturalOrderer orderer = new DependencyUtil.NaturalOrderer(schedule);
+ DependencyUtil.NaturalOrderer orderer = new DependencyUtil.NaturalOrderer(getDependencyGraph());
List<@NonNull AbstractAction> orderedActions = orderer.computeOrdering(); // FIXME ??is this ordering still needed??
if (orderedActions == null) {
throw new IllegalArgumentException(orderer.diagnoseOrderingFailure());
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/SchedulerConstants.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/SchedulerConstants.java
index f77b18db7..47a2723a5 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/SchedulerConstants.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtp2qvts/SchedulerConstants.java
@@ -44,14 +44,13 @@ import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
import org.eclipse.qvtd.pivot.qvtbase.graphs.DOTStringBuilder;
import org.eclipse.qvtd.pivot.qvtbase.graphs.GraphMLStringBuilder;
-import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
import org.eclipse.qvtd.pivot.qvtcore.analysis.DomainUsage;
import org.eclipse.qvtd.pivot.qvtcore.analysis.DomainUsageAnalysis;
+import org.eclipse.qvtd.pivot.qvtcore.analysis.QVTcoreDomainUsageAnalysis;
import org.eclipse.qvtd.pivot.qvtcore.analysis.RootDomainUsageAnalysis;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
import org.eclipse.qvtd.pivot.schedule.AbstractDatum;
import org.eclipse.qvtd.pivot.schedule.ClassDatum;
-import org.eclipse.qvtd.pivot.schedule.MappingAction;
import org.eclipse.qvtd.pivot.schedule.PropertyDatum;
import org.eclipse.qvtd.pivot.schedule.Schedule;
@@ -83,16 +82,17 @@ public abstract class SchedulerConstants
return s.toString();
}
+ private final @NonNull EnvironmentFactory environmentFactory;
+ private final @NonNull Transformation transformation;
+ private final @NonNull ClassRelationships classRelationships;
+ private final @NonNull RootDomainUsageAnalysis domainAnalysis;
+ private final @NonNull QVTp2QVTg qvtp2qvtg;
/**
* The DependencyGraph to be analyzed
*/
private final @NonNull Schedule dependencyGraph;
- private final @NonNull RootDomainUsageAnalysis domainAnalysis;
- private final @NonNull QVTp2QVTg qvtp2qvtg;
@SuppressWarnings("unused")
private final @NonNull DomainUsage inputUsage;
- private final @NonNull EnvironmentFactory environmentFactory;
- private final @NonNull Transformation transformation;
private final @NonNull OperationId collectionSelectByKindId;
private final @NonNull OperationId oclAnyEqualsId;
@@ -136,12 +136,14 @@ public abstract class SchedulerConstants
private /*@LazyNonNull */ DependencyAnalyzer dependencyAnalyzer = null;
- protected SchedulerConstants(@NonNull EnvironmentFactory environmentFactory, @NonNull Schedule dependencyGraph, @NonNull QVTp2QVTg qvtp2qvtg, @NonNull RootDomainUsageAnalysis domainAnalysis) {
+ protected SchedulerConstants(@NonNull EnvironmentFactory environmentFactory, @NonNull Transformation asTransformation) {
this.environmentFactory = environmentFactory;
- this.dependencyGraph = dependencyGraph;
- this.domainAnalysis = domainAnalysis;
- this.qvtp2qvtg = qvtp2qvtg;
- this.transformation = ClassUtil.nonNullState(QVTbaseUtil.getContainingTransformation(((MappingAction)dependencyGraph.getActions().get(0)).getMapping()));
+ this.transformation = asTransformation;
+ this.classRelationships = new ClassRelationships(environmentFactory);
+ this.domainAnalysis = new QVTcoreDomainUsageAnalysis(environmentFactory);
+ domainAnalysis.analyzeTransformation(asTransformation);
+ this.qvtp2qvtg = new QVTp2QVTg(domainAnalysis, classRelationships);
+ this.dependencyGraph = qvtp2qvtg.transformTransformation(asTransformation);
//
this.inputUsage = domainAnalysis.getInputUsage();
// int outputMask = ((DomainUsage.Internal)domainAnalysis.getOutputUsage()).getMask();
@@ -273,7 +275,7 @@ public abstract class SchedulerConstants
}
public @NonNull ClassRelationships getClassRelationships() {
- return qvtp2qvtg.getClassRelationships();
+ return classRelationships;
}
// @SuppressWarnings("null")
@@ -315,7 +317,7 @@ public abstract class SchedulerConstants
}
protected @NonNull URI getGraphsBaseURI() {
- return dependencyGraph.eResource().getURI().trimSegments(1).appendSegment("graphs").appendSegment("");
+ return transformation.eResource().getURI().trimSegments(1).appendSegment("graphs").appendSegment("");
}
public @NonNull Property getIterateProperty(@NonNull Type type) {

Back to the top