Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-09-27 14:24:45 +0000
committerEd Willink2016-10-05 04:13:30 +0000
commit4aa42888857ffced3f04e3c9b5e70e0ab5e5fa1b (patch)
treedffb993216072ac242196519bd3b6fef393164c9 /plugins
parentcd92f07a33fed67d0dfc76d7e33ed39837cf51a4 (diff)
downloadorg.eclipse.qvtd-4aa42888857ffced3f04e3c9b5e70e0ab5e5fa1b.tar.gz
org.eclipse.qvtd-4aa42888857ffced3f04e3c9b5e70e0ab5e5fa1b.tar.xz
org.eclipse.qvtd-4aa42888857ffced3f04e3c9b5e70e0ab5e5fa1b.zip
[502235] Diagnose accumulated CodeGenerator.problems
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java9
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/AbstractCompilerChain.java13
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java17
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java21
4 files changed, 51 insertions, 9 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
index 4a2fd2f8d..7cd7e1503 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/analyzer/QVTiAS2CGVisitor.java
@@ -1020,7 +1020,8 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
genModelHelper.getGetAccessor(eStructuralFeature);
cgPropertyAssignment.setEStructuralFeature(eStructuralFeature);
} catch (GenModelException e) {
- System.out.println("Missing getAccessor for " + eStructuralFeature + "ignored : " + e.getMessage());
+ codeGenerator.addProblem(e);
+ // System.out.println("Missing getAccessor for " + eStructuralFeature + "ignored : " + e.getMessage());
}
}
return cgPropertyAssignment;
@@ -1038,7 +1039,8 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
cgEcorePropertyAssignment.setEStructuralFeature(eStructuralFeature);
cgPropertyAssignment = cgEcorePropertyAssignment;
} catch (GenModelException e) {
- System.out.println("Missing getAccessor for " + eStructuralFeature + "ignored : " + e.getMessage());
+ codeGenerator.addProblem(e);
+ // System.out.println("Missing getAccessor for " + eStructuralFeature + "ignored : " + e.getMessage());
}
}
else {
@@ -1052,7 +1054,8 @@ public class QVTiAS2CGVisitor extends AS2CGVisitor implements QVTimperativeVisit
cgEcoreContainerAssignment.setEStructuralFeature(eStructuralFeature);
cgPropertyAssignment = cgEcoreContainerAssignment;
} catch (GenModelException e) {
- System.out.println("Missing getAccessor for " + eStructuralFeature + "ignored : " + e.getMessage());
+ codeGenerator.addProblem(e);
+ // System.out.println("Missing getAccessor for " + eStructuralFeature + "ignored : " + e.getMessage());
}
}
}
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 1f048faf5..7675a8633 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
@@ -149,7 +149,7 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
super(compilerChain, JAVA_STEP);
}
- protected @NonNull JavaResult execute(@NonNull URI txURI, @NonNull Transformation asTransformation, @NonNull String ... genModelFiles) throws IOException {
+ protected @NonNull JavaResult execute(@NonNull URI txURI, @NonNull Transformation asTransformation, @NonNull String ... genModelFiles) throws Exception {
URI javaURI = compilerChain.getURI(JAVA_STEP, URI_KEY);
URI classURI = compilerChain.getURI(CLASS_STEP, URI_KEY);
ResourceSet resourceSet = environmentFactory.getResourceSet();
@@ -167,7 +167,14 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
if (javaExtraPrefix != null) {
options.setPackagePrefix(javaExtraPrefix);
}
- String javaCodeSource = cg.generateClassFile();
+ String javaCodeSource;
+ try {
+ javaCodeSource = cg.generateClassFile();
+ }
+ catch (Exception e) {
+ CompilerUtil.throwExceptionWithProblems(cg, e);
+ javaCodeSource = ""; // Never happens but suppresses JDT error.
+ }
URI normalizedURI = resourceSet.getURIConverter().normalize(javaURI);
String javaFileName;
File explicitClassPath;
@@ -575,7 +582,7 @@ public abstract class AbstractCompilerChain extends CompilerUtil implements Comp
return qvtm2qvtpCompilerStep.execute(mResource);
}
- protected @NonNull JavaResult qvti2java(@NonNull Transformation asTransformation, @NonNull String ... genModelFiles) throws IOException {
+ protected @NonNull JavaResult qvti2java(@NonNull Transformation asTransformation, @NonNull String ... genModelFiles) throws Exception {
return qvti2javaCompilerStep.execute(txURI, asTransformation, genModelFiles);
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java
index 88bdd9a7c..37d99ebce 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/utilities/CompilerUtil.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil.UnresolvedProxyCrossReferencer;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.ocl.examples.codegen.generator.CodeGenerator;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.PivotTables;
import org.eclipse.ocl.pivot.messages.StatusCodes;
@@ -45,6 +46,7 @@ import org.eclipse.ocl.pivot.utilities.OCL;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
import org.eclipse.ocl.xtext.base.utilities.ElementUtil;
import org.eclipse.ocl.xtext.basecs.ModelElementCS;
+import org.eclipse.qvtd.compiler.CompilerChainException;
import org.eclipse.qvtd.pivot.qvtcore.utilities.QVTcore;
import org.eclipse.qvtd.pivot.qvtcore.utilities.QVTcoreUtil;
import org.eclipse.xtext.nodemodel.ICompositeNode;
@@ -249,4 +251,19 @@ public class CompilerUtil
removeFrom.remove(element);
}
}
+
+ public static void throwExceptionWithProblems(@NonNull CodeGenerator codeGenerator, @NonNull Exception e) throws Exception {
+ List<@NonNull Exception> problems = codeGenerator.getProblems();
+ if (problems != null) {
+ StringBuilder s = new StringBuilder();
+ for (@NonNull Exception ex : problems) {
+ s.append(ex.toString() + "\n");
+ }
+ s.append(e.toString());
+ throw new CompilerChainException(e, s.toString());
+ }
+ else {
+ throw e;
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java
index 9c6831d5a..c73b3e1e8 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java
@@ -56,6 +56,7 @@ import org.eclipse.qvtd.codegen.qvti.java.QVTiGlobalContext;
import org.eclipse.qvtd.codegen.qvticgmodel.CGGuardVariable;
import org.eclipse.qvtd.codegen.qvticgmodel.CGMapping;
import org.eclipse.qvtd.codegen.utilities.QVTiCGUtil;
+import org.eclipse.qvtd.compiler.internal.utilities.CompilerUtil;
import org.eclipse.qvtd.cs2as.compiler.CS2ASJavaCompiler;
import org.eclipse.qvtd.cs2as.compiler.CS2ASJavaCompilerParameters;
import org.eclipse.qvtd.cs2as.compiler.cgmodel.CGLookupCallExp;
@@ -474,11 +475,25 @@ public class CS2ASJavaCompilerImpl implements CS2ASJavaCompiler {
options.setUseNullAnnotations(true);
options.setIsIncremental(params.isIncremental());
options.setPackagePrefix(params.getPackageName());
- cg.generateClassFile();
+ try {
+ cg.generateClassFile();
+ }
+ catch (Exception e) {
+ CompilerUtil.throwExceptionWithProblems(cg, e);
+ }
+ Log log2 = log;
+ if (log2 != null) {
+ List<@NonNull Exception> problems = cg.getProblems();
+ if (problems != null) {
+ for (@NonNull Exception ex : problems) {
+ log2.info("CG Problem " + ex.toString());
+ }
+ }
+ }
String savePath = params.getSavePath();
cg.saveSourceFile(savePath);
- if (log != null) {
- log.info("Saved " + savePath + cg.getQualifiedName());
+ if (log2 != null) {
+ log2.info("Saved " + savePath + cg.getQualifiedName());
}
return ClassUtil.nonNullState(compileTransformation(new File(new File(savePath).getParentFile(), "bin"), cg));
}

Back to the top