Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkolovos2013-02-10 11:23:37 -0500
committerdkolovos2013-02-10 11:23:37 -0500
commit75aca988f96c4d82b40616ff33db116e580d2f8c (patch)
tree7fa0ad1e04847a0d2b5fa54c455894903294d0fe
parent3c31caebf46ae68be1ba0f692d7f24f2fb341a28 (diff)
downloadorg.eclipse.emfatic-75aca988f96c4d82b40616ff33db116e580d2f8c.tar.gz
org.eclipse.emfatic-75aca988f96c4d82b40616ff33db116e580d2f8c.tar.xz
org.eclipse.emfatic-75aca988f96c4d82b40616ff33db116e580d2f8c.zip
Added exception handling to EmfaticParserDriver (for use outside
Eclipse)
-rw-r--r--plugins/org.eclipse.emf.emfatic.core/src/org/eclipse/emf/emfatic/core/lang/gen/parser/EmfaticParserDriver.java61
1 files changed, 33 insertions, 28 deletions
diff --git a/plugins/org.eclipse.emf.emfatic.core/src/org/eclipse/emf/emfatic/core/lang/gen/parser/EmfaticParserDriver.java b/plugins/org.eclipse.emf.emfatic.core/src/org/eclipse/emf/emfatic/core/lang/gen/parser/EmfaticParserDriver.java
index 4dcb1f6..111f051 100644
--- a/plugins/org.eclipse.emf.emfatic.core/src/org/eclipse/emf/emfatic/core/lang/gen/parser/EmfaticParserDriver.java
+++ b/plugins/org.eclipse.emf.emfatic.core/src/org/eclipse/emf/emfatic/core/lang/gen/parser/EmfaticParserDriver.java
@@ -69,37 +69,42 @@ public class EmfaticParserDriver implements IParser {
connector.connect(parseContext, resource, npm);
rootPackage = (EPackage) resource.getContents().get(0);
if (rootPackage != null) {
- // invoke EcoreValidator
- Diagnostician diagnostician = new Diagnostician();
- final Diagnostic diagnostic = diagnostician.validate(rootPackage);
- if (diagnostic.getSeverity() == Diagnostic.OK) {
- return rootPackage;
- }
- /*
- * A tutorial on markers:
- *
- * http://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html
- *
- */
-
- CompUnit compUnit = (CompUnit) parseContext.getParseRoot();
- for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
- Set<ASTNode> problemNodes = new HashSet<ASTNode>();
- String dMsg = childDiagnostic.getMessage();
- if (childDiagnostic.getData().size() > 0) {
- Object primarySourceOfProblem = childDiagnostic.getData().get(0);
- if (primarySourceOfProblem != null && primarySourceOfProblem instanceof EObject) {
- Set<ASTNode> cstUses = compUnit.getEcoreDecl2CstUse().get((EObject) primarySourceOfProblem);
- problemNodes.addAll(cstUses);
- if (problemNodes.size() == 0) {
- problemNodes.add(compUnit.getPackageDecl());
+ try {
+ // invoke EcoreValidator
+ Diagnostician diagnostician = new Diagnostician();
+ final Diagnostic diagnostic = diagnostician.validate(rootPackage);
+ if (diagnostic.getSeverity() == Diagnostic.OK) {
+ return rootPackage;
+ }
+ /*
+ * A tutorial on markers:
+ *
+ * http://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html
+ *
+ */
+
+ CompUnit compUnit = (CompUnit) parseContext.getParseRoot();
+ for (Diagnostic childDiagnostic : diagnostic.getChildren()) {
+ Set<ASTNode> problemNodes = new HashSet<ASTNode>();
+ String dMsg = childDiagnostic.getMessage();
+ if (childDiagnostic.getData().size() > 0) {
+ Object primarySourceOfProblem = childDiagnostic.getData().get(0);
+ if (primarySourceOfProblem != null && primarySourceOfProblem instanceof EObject) {
+ Set<ASTNode> cstUses = compUnit.getEcoreDecl2CstUse().get((EObject) primarySourceOfProblem);
+ problemNodes.addAll(cstUses);
+ if (problemNodes.size() == 0) {
+ problemNodes.add(compUnit.getPackageDecl());
+ }
}
}
+ for (ASTNode problemNode : problemNodes) {
+ ParseMessage pMsg = new EmfaticSemanticWarning.EcoreValidatorDiagnostic(problemNode, dMsg);
+ parseContext.addParseMessage(pMsg);
+ }
}
- for (ASTNode problemNode : problemNodes) {
- ParseMessage pMsg = new EmfaticSemanticWarning.EcoreValidatorDiagnostic(problemNode, dMsg);
- parseContext.addParseMessage(pMsg);
- }
+ }
+ catch (Exception ex) {
+ return rootPackage;
}
}
}

Back to the top