From ca9c5d2181550aa782a820f75541a4f8954f22d7 Mon Sep 17 00:00:00 2001
From: dgelessus <dgelessus@users.noreply.github.com>
Date: Tue, 27 Sep 2022 12:28:50 +0200
Subject: [PATCH] Update to new B parser exception class

---
 .../editor/observer/ListenOperationByPredicate.java    |  4 ++--
 .../src/de/bmotionstudio/gef/editor/util/BMSUtil.java  |  4 ++--
 .../de/prob/core/command/ConstructTraceCommand.java    |  4 ++--
 .../core/command/GetOperationByPredicateCommand.java   | 10 +++++-----
 .../prob/core/command/LoadClassicalBModelCommand.java  |  4 ++--
 .../core/domainobjects/eval/AbstractEvalElement.java   |  4 ++--
 .../core/domainobjects/eval/ExpressionEvalElement.java |  9 +++++----
 .../core/domainobjects/eval/PredicateEvalElement.java  |  9 +++++----
 .../operationview/CustomPreconditionInputDialog.java   |  4 ++--
 .../operationview/GetOperationByPredicateCommand2.java | 10 +++++-----
 10 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java
index 83542e85..e97873f7 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ListenOperationByPredicate.java
@@ -9,7 +9,7 @@ package de.bmotionstudio.gef.editor.observer;
 import java.util.ArrayList;
 import java.util.List;
 
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.bmotionstudio.gef.editor.Animation;
 import de.bmotionstudio.gef.editor.AttributeConstants;
 import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
@@ -128,7 +128,7 @@ public class ListenOperationByPredicate extends Observer {
 						// addError(control, animation,
 						// "An error occurred while evaluating. Reason: "
 						// + e.getMessage());
-					} catch (BException e) {
+					} catch (BCompoundException e) {
 						// addError(control, animation, "Parsing error in: "
 						// + fPredicate + " Reason: " + e.getMessage());
 					}
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java
index ed487db0..4fa2ef9c 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/util/BMSUtil.java
@@ -9,7 +9,7 @@ import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.bmotionstudio.gef.editor.Animation;
 import de.bmotionstudio.gef.editor.AttributeConstants;
 import de.bmotionstudio.gef.editor.model.BControl;
@@ -213,7 +213,7 @@ public class BMSUtil {
 					opRandom);
 
 		} catch (ProBException e) {
-		} catch (BException e) {
+		} catch (BCompoundException e) {
 		}
 
 		return null;
diff --git a/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java b/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java
index a12b0d91..53e3aa38 100644
--- a/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java
+++ b/de.prob.core/src/de/prob/core/command/ConstructTraceCommand.java
@@ -14,7 +14,7 @@ import java.util.List;
 import java.util.Set;
 
 import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog;
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.prob.core.Animator;
 import de.prob.core.domainobjects.Operation;
 import de.prob.core.domainobjects.State;
@@ -53,7 +53,7 @@ public final class ConstructTraceCommand implements IComposableCommand {
 		for (String string : predicates) {
 			try {
 				evalElement.add(PredicateEvalElement.create(string));
-			} catch (BException e) {
+			} catch (BCompoundException e) {
 				throw new IllegalArgumentException(
 						"Formula must be a predicate: " + string);
 			}
diff --git a/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java b/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java
index 51d42750..62d7767a 100644
--- a/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java
+++ b/de.prob.core/src/de/prob/core/command/GetOperationByPredicateCommand.java
@@ -10,7 +10,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog;
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.prob.core.Animator;
 import de.prob.core.ProblemHandler;
 import de.prob.core.domainobjects.Operation;
@@ -51,7 +51,7 @@ public final class GetOperationByPredicateCommand implements IComposableCommand
 		PredicateEvalElement parsedEvalElement = null;
 		try {
 			parsedEvalElement = PredicateEvalElement.create(predicate);
-		} catch (BException e) {
+		} catch (BCompoundException e) {
 			String message = "Fatal error when trying to parse " + predicate
 					+ ". Execution of operation " + name + " aborted.";
 			ProblemHandler.raiseCommandException(message);
@@ -66,7 +66,7 @@ public final class GetOperationByPredicateCommand implements IComposableCommand
 	 */
 	public static Operation getOperation(final Animator a,
 			final String stateId, final String name, final String predicate)
-			throws ProBException, BException {
+			throws ProBException, BCompoundException {
 
 		List<Operation> operations = getOperations(a, stateId, name, predicate,
 				1);
@@ -91,14 +91,14 @@ public final class GetOperationByPredicateCommand implements IComposableCommand
 	 * @param nrOfSolutions
 	 *            - maximum number of solutions
 	 * @return an Operation or null
-	 * @throws BException
+	 * @throws BCompoundException
 	 *             - if the B predicate contains errors
 	 * @throws ProBException
 	 *             - if something terrible happens ;-)
 	 */
 	public static List<Operation> getOperations(final Animator a,
 			final String stateId, final String name, final String predicate,
-			final int nrOfSolutions) throws ProBException, BException {
+			final int nrOfSolutions) throws ProBException, BCompoundException {
 
 		GetOperationByPredicateCommand executeOperationCommand = new GetOperationByPredicateCommand(
 				stateId, name, predicate, nrOfSolutions);
diff --git a/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java b/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java
index 5dcff862..2fa022b6 100644
--- a/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java
+++ b/de.prob.core/src/de/prob/core/command/LoadClassicalBModelCommand.java
@@ -19,7 +19,7 @@ import org.osgi.service.prefs.Preferences;
 
 import de.be4.classicalb.core.parser.BParser;
 import de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader;
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.be4.classicalb.core.parser.node.Start;
 import de.prob.core.Animator;
 import de.prob.core.domainobjects.Operation;
@@ -154,7 +154,7 @@ public final class LoadClassicalBModelCommand {
 		} catch (IOException e) {
 			Logger.notifyUser("IO Error", e);
 			throw new CommandException(e.getLocalizedMessage(), e);
-		} catch (BException e) {
+		} catch (BCompoundException e) {
 			Logger.notifyUser("Parser Error " + e.getLocalizedMessage(), e);
 			throw new CommandException(e.getLocalizedMessage(), e);
 		}
diff --git a/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java b/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java
index acf76587..d725f17f 100644
--- a/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java
+++ b/de.prob.core/src/de/prob/core/domainobjects/eval/AbstractEvalElement.java
@@ -7,7 +7,7 @@
 package de.prob.core.domainobjects.eval;
 
 import de.be4.classicalb.core.parser.BParser;
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.be4.classicalb.core.parser.node.Start;
 import de.prob.core.Animator;
 import de.prob.core.command.EvaluateRawExpressionsCommand;
@@ -30,7 +30,7 @@ public abstract class AbstractEvalElement {
 	public abstract String getLabel();
 
 	protected Start parse(final String prefix, final String code)
-			throws BException {
+			throws BCompoundException {
 		final BParser parser = new BParser();
 		final Start modelAst = parser.parse(prefix + code, false);
 		return modelAst;
diff --git a/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java b/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java
index 02b22f69..cb5932d9 100644
--- a/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java
+++ b/de.prob.core/src/de/prob/core/domainobjects/eval/ExpressionEvalElement.java
@@ -9,6 +9,7 @@ package de.prob.core.domainobjects.eval;
 import org.eventb.core.ast.Expression;
 
 import de.be4.classicalb.core.parser.BParser;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.be4.classicalb.core.parser.exceptions.BException;
 import de.be4.classicalb.core.parser.node.AExpressionParseUnit;
 import de.be4.classicalb.core.parser.node.EOF;
@@ -22,10 +23,10 @@ public final class ExpressionEvalElement extends AbstractEvalElement {
 	private final String expression;
 
 	public static ExpressionEvalElement fromRodin(final Expression expression)
-			throws BException {
+			throws BCompoundException {
 		if (expression == null) {
 			String message = "Expression input must not be null";
-			throw new BException("", new NullPointerException(message));
+			throw new BCompoundException(new BException("", message, new NullPointerException(message)));
 		}
 		final PExpression expr = TranslationVisitor
 				.translateExpression(expression);
@@ -35,11 +36,11 @@ public final class ExpressionEvalElement extends AbstractEvalElement {
 	}
 
 	public static ExpressionEvalElement create(final String expression)
-			throws BException {
+			throws BCompoundException {
 		return new ExpressionEvalElement(expression);
 	}
 
-	public ExpressionEvalElement(final String expression) throws BException {
+	public ExpressionEvalElement(final String expression) throws BCompoundException {
 		this.expression = expression;
 		parse = parse(BParser.EXPRESSION_PREFIX, expression);
 	}
diff --git a/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java b/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java
index c5589b2a..d545f152 100644
--- a/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java
+++ b/de.prob.core/src/de/prob/core/domainobjects/eval/PredicateEvalElement.java
@@ -10,6 +10,7 @@ import org.eventb.core.ast.Predicate;
 
 import de.be4.classicalb.core.parser.BParser;
 import de.be4.classicalb.core.parser.analysis.DepthFirstAdapter;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.be4.classicalb.core.parser.exceptions.BException;
 import de.be4.classicalb.core.parser.node.AConjunctPredicate;
 import de.be4.classicalb.core.parser.node.ADisjunctPredicate;
@@ -30,10 +31,10 @@ public class PredicateEvalElement extends AbstractEvalElement {
 	private final String predicate;
 
 	public static PredicateEvalElement fromRodin(final Predicate predicate)
-			throws BException {
+			throws BCompoundException {
 		if (predicate == null) {
 			String message = "Predicate input must not be null";
-			throw new BException("", new NullPointerException(message));
+			throw new BCompoundException(new BException("", message, new NullPointerException(message)));
 		}
 		final PPredicate apred = TranslationVisitor
 				.translatePredicate(predicate);
@@ -43,11 +44,11 @@ public class PredicateEvalElement extends AbstractEvalElement {
 	}
 
 	public static PredicateEvalElement create(final String predicate)
-			throws BException {
+			throws BCompoundException {
 		return new PredicateEvalElement(predicate);
 	}
 
-	private PredicateEvalElement(final String predicate) throws BException {
+	private PredicateEvalElement(final String predicate) throws BCompoundException {
 		this.predicate = predicate;
 		parse = parse(BParser.PREDICATE_PREFIX, predicate);
 	}
diff --git a/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java b/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java
index 5873a5e2..38f3b9af 100644
--- a/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java
+++ b/de.prob.ui/src/de/prob/ui/operationview/CustomPreconditionInputDialog.java
@@ -13,7 +13,7 @@ import java.util.List;
 import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.swt.widgets.Shell;
 
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.prob.core.Animator;
 import de.prob.core.command.*;
 import de.prob.core.domainobjects.Operation;
@@ -81,7 +81,7 @@ public class CustomPreconditionInputDialog extends InputDialog {
 		} catch (ProBException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
-		} catch (BException e) {
+		} catch (BCompoundException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
diff --git a/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java b/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java
index 86620965..eadac737 100644
--- a/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java
+++ b/de.prob.ui/src/de/prob/ui/operationview/GetOperationByPredicateCommand2.java
@@ -14,7 +14,7 @@ import org.eventb.core.ast.IParseResult;
 import org.eventb.core.ast.Predicate;
 
 import de.be4.classicalb.core.parser.analysis.prolog.ASTProlog;
-import de.be4.classicalb.core.parser.exceptions.BException;
+import de.be4.classicalb.core.parser.exceptions.BCompoundException;
 import de.prob.core.Animator;
 import de.prob.core.ProblemHandler;
 import de.prob.core.command.CommandException;
@@ -64,7 +64,7 @@ public final class GetOperationByPredicateCommand2 implements
 
 		try {
 			parsedEvalElement = PredicateEvalElement.fromRodin(parsedPredicate);
-		} catch (BException e) {
+		} catch (BCompoundException e) {
 			String message = "Fatal error when trying to parse " + predicate
 					+ ". Execution of event " + name + " aborted.";
 			ProblemHandler.raiseCommandException(message);
@@ -79,7 +79,7 @@ public final class GetOperationByPredicateCommand2 implements
 	 */
 	public static Operation getOperation(final Animator a,
 			final String stateId, final String name, final String predicate)
-			throws ProBException, BException {
+			throws ProBException, BCompoundException {
 
 		List<Operation> operations = getOperations(a, stateId, name, predicate,
 				1);
@@ -104,14 +104,14 @@ public final class GetOperationByPredicateCommand2 implements
 	 * @param nrOfSolutions
 	 *            - maximum number of solutions
 	 * @return an Operation or null
-	 * @throws BException
+	 * @throws BCompoundException
 	 *             - if the B predicate contains errors
 	 * @throws ProBException
 	 *             - if something terrible happens ;-)
 	 */
 	public static List<Operation> getOperations(final Animator a,
 			final String stateId, final String name, final String predicate,
-			final int nrOfSolutions) throws ProBException, BException {
+			final int nrOfSolutions) throws ProBException, BCompoundException {
 
 		GetOperationByPredicateCommand2 executeOperationCommand = new GetOperationByPredicateCommand2(
 				stateId, name, predicate, nrOfSolutions);
-- 
GitLab