Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java30
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java8
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java4
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiCompilerChain.java38
4 files changed, 54 insertions, 26 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
index 15f8ce642..f06bfe1f0 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
@@ -853,19 +853,6 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
}
}
- private EObject getContainer(EObject eObject) {
- EObject eContainer = eObject.eContainer();
- if (eContainer != null) {
- return eContainer;
- }
- for (Adapter eAdapter : eObject.eAdapters()) {
- if (eAdapter instanceof QVTiAS2CGVisitor.InlinedBodyAdapter) {
- return ((QVTiAS2CGVisitor.InlinedBodyAdapter)eAdapter).getOperationCallExp();
- }
- }
- return null;
- }
-
protected void doGot(@NonNull CGNavigationCallExp cgPropertyCallExp, @NonNull CGValuedElement source, @NonNull EStructuralFeature eStructuralFeature) {
if (useGot) {
EPackage ePackage = ClassUtil.nonNullModel(eStructuralFeature.getEContainingClass().getEPackage());
@@ -1160,6 +1147,19 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
return allImports;
}
+ private EObject getContainer(EObject eObject) {
+ EObject eContainer = eObject.eContainer();
+ if (eContainer != null) {
+ return eContainer;
+ }
+ for (Adapter eAdapter : eObject.eAdapters()) {
+ if (eAdapter instanceof QVTiAS2CGVisitor.InlinedBodyAdapter) {
+ return ((QVTiAS2CGVisitor.InlinedBodyAdapter)eAdapter).getOperationCallExp();
+ }
+ }
+ return null;
+ }
+
@Override
protected @Nullable EStructuralFeature getESObject(@NonNull Property asProperty) {
EObject esObject = asProperty.getESObject();
@@ -1171,7 +1171,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
return null;
}
if (!oppositeProperty.isIsComposite()) {
- PivotMetamodelManager metamodelManager = analyzer.getCodeGenerator().getEnvironmentFactory().getMetamodelManager();
+ PivotMetamodelManager metamodelManager = environmentFactory.getMetamodelManager();
LibraryProperty libraryProperty = metamodelManager.getImplementation(null, null, asProperty);
if (!(libraryProperty instanceof OclElementOclContainerProperty)) {
return null;
@@ -2105,7 +2105,7 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
List<CGOperation> cgOperations = cgTransformation.getOperations();
doMappingConstructorConstants(cgMappings);
doFunctionConstructorConstants(ClassUtil.nullFree(cgOperations));
- // js.append("\n");
+ js.append("\n");
doConstructor(cgTransformation, oppositeIndex2propertyIdName, allInstancesNames);
js.append("\n");
if (isIncremental) {
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java
index 0b78d28ba..303fd7ff2 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2JavaTxCompiler.java
@@ -19,12 +19,12 @@ import org.eclipse.qvtd.runtime.evaluation.Transformer;
public interface OCL2JavaTxCompiler<P extends OCL2JavaTxCompilerParams> {
// FIXME fix exception handling
-
+
public Class<? extends Transformer> compileTransformation(@Nullable ResourceSet rSet,
@NonNull CS2ASJavaCompilerParameters params, @NonNull URI oclDocURI,
- URI... extendedOCLDocURIs) throws Exception;
-
+ @NonNull URI... extendedOCLDocURIs) throws Exception;
+
public Class<? extends Transformer> compileTransformation(@Nullable ResourceSet rSet,
@NonNull CS2ASJavaCompilerParameters params, @NonNull String tracePropertyName, @NonNull URI oclDocURI,
- URI... extendedOCLDocURIs) throws Exception;
+ @NonNull URI... extendedOCLDocURIs) throws Exception;
}
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java
index 395c8d0f3..a2c404106 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/OCL2QVTiCGTxCompiler.java
@@ -50,7 +50,7 @@ public class OCL2QVTiCGTxCompiler implements OCL2JavaTxCompiler<CS2ASJavaCompile
}
@Override
- public Class<? extends Transformer> compileTransformation(@Nullable ResourceSet rSet, @NonNull CS2ASJavaCompilerParameters params, @NonNull String tracePropertyName, @NonNull URI oclDocURI, URI... extendedOCLDocURIs)
+ public Class<? extends Transformer> compileTransformation(@Nullable ResourceSet rSet, @NonNull CS2ASJavaCompilerParameters params, @NonNull String tracePropertyName, @NonNull URI oclDocURI, @NonNull URI... extendedOCLDocURIs)
throws Exception {
QVTimperative qvt = QVTimperative.newInstance(BasicProjectManager.CLASS_PATH, rSet);
@@ -68,7 +68,7 @@ public class OCL2QVTiCGTxCompiler implements OCL2JavaTxCompiler<CS2ASJavaCompile
return new CS2ASJavaCompilerImpl();
}
- protected Transformation executeOCL2QVTi_CompilerChain(QVTimperative qvt, String tracePropName, URI oclDocURI, URI... extendedOCLDocURIs) throws Exception {
+ protected @NonNull Transformation executeOCL2QVTi_CompilerChain(@NonNull QVTimperative qvt, String tracePropName, @NonNull URI oclDocURI, @NonNull URI... extendedOCLDocURIs) throws Exception {
Map<@NonNull String, @Nullable Map<@NonNull Key<Object>, @Nullable Object>> options = new HashMap<@NonNull String, @Nullable Map<@NonNull Key<Object>, @Nullable Object>>();
// OCL2QVTp options
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiCompilerChain.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiCompilerChain.java
index c8de18590..7efe60e8f 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiCompilerChain.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/OCL2QVTiCompilerChain.java
@@ -18,14 +18,18 @@ import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.Element;
+import org.eclipse.ocl.pivot.resource.ASResource;
+import org.eclipse.ocl.pivot.resource.CSResource;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
import org.eclipse.qvtd.compiler.AbstractCompilerChain;
import org.eclipse.qvtd.compiler.AbstractCompilerStep;
import org.eclipse.qvtd.compiler.CompilerChain;
+import org.eclipse.qvtd.compiler.CompilerChainException;
import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTransformation;
import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperative;
@@ -39,12 +43,35 @@ public class OCL2QVTiCompilerChain extends AbstractCompilerChain {
public OCL2QVTpCompilerStep(@NonNull CompilerChain compilerChain, @NonNull QVTimperative qvti,
@Nullable Map<@NonNull String, @Nullable Map<@NonNull Key<Object>, @Nullable Object>> options,
- @NonNull URI oclDocURI, URI... extendedDocURIs) {
+ @NonNull URI oclDocURI, @NonNull URI... extendedDocURIs) throws CompilerChainException {
super(compilerChain, QVTP_STEP);
this.traceabilityPropName = getTraceabilityPropertyName();
- this.oclASUri = ClassUtil.nonNullState(qvti.parse(oclDocURI)).getURI();
- for (URI oclDocUri : extendedDocURIs) {
- this.extendedASUris.add(ClassUtil.nonNullState(qvti.parse(oclDocUri)).getURI()); // We add the AS URI
+ ResourceSet externalResourceSet = qvti.getResourceSet();
+ CSResource csResource = (CSResource) externalResourceSet.getResource(oclDocURI, true);
+ if (csResource == null) {
+ throw new CompilerChainException("Failed to parse " + oclDocURI);
+ }
+ ASResource asResource = qvti.cs2as(csResource);
+ this.oclASUri = ClassUtil.nonNullState(asResource.getURI());
+ for (@NonNull URI extendedDocURI : extendedDocURIs) {
+ csResource = (CSResource) externalResourceSet.getResource(extendedDocURI, true);
+ if (csResource == null) {
+ throw new CompilerChainException("Failed to parse " + extendedDocURI);
+ }
+ asResource = qvti.cs2as(csResource);
+ this.extendedASUris.add(ClassUtil.nonNullState(asResource.getURI())); // We add the AS URI
+ }
+ StringBuilder s = null;
+ for (@NonNull Resource resource : externalResourceSet.getResources()) {
+ if (resource.getErrors().size() > 0) {
+ if (s == null) {
+ s = new StringBuilder();
+ }
+ s.append(PivotUtil.formatResourceDiagnostics(resource.getErrors(), "\nErrors in " + resource.getURI(), "\n\t"));
+ }
+ }
+ if (s != null) {
+ throw new CompilerChainException(s.toString());
}
}
@@ -90,9 +117,10 @@ public class OCL2QVTiCompilerChain extends AbstractCompilerChain {
* @param options optional options
* @param oclDocURI the mandatory main OCL document URI to compile
* @param extendedDocURIs optional OCL document URIs that the main one extends
+ * @throws CompilerChainException
*/
public OCL2QVTiCompilerChain(@NonNull QVTimperative qvti, @Nullable Map<@NonNull String, @Nullable Map<@NonNull Key<Object>, @Nullable Object>> options,
- @NonNull URI oclDocURI, URI... extendedDocURIs) {
+ @NonNull URI oclDocURI, @NonNull URI... extendedDocURIs) throws CompilerChainException {
super(qvti.getEnvironmentFactory(), oclDocURI, options);
this.ocl2qvtpCompilerStep = new OCL2QVTpCompilerStep(this, qvti, options, oclDocURI, extendedDocURIs);
}

Back to the top