diff options
| author | Pierre-Charles David | 2015-09-28 12:42:28 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2015-09-28 15:41:00 +0000 |
| commit | 90f4cc30054957aa8376572ed9391a02882687d1 (patch) | |
| tree | 2704255f4d09bc52fb10f6f45a6a1fff24c71c70 | |
| parent | 08161920c46dceda019b8969a58af5f60d798c3c (diff) | |
| download | org.eclipse.sirius-90f4cc30054957aa8376572ed9391a02882687d1.tar.gz org.eclipse.sirius-90f4cc30054957aa8376572ed9391a02882687d1.tar.xz org.eclipse.sirius-90f4cc30054957aa8376572ed9391a02882687d1.zip | |
[474878] Make ODesignGenericInterpreter implement IInterpreterWithDiagnostic
ODesignGenericInterpreter is, among all the IInterpreter
implementations, the actual façade visible from outside a Sirius
session. Make it implement IInterpreterWithDiagnostic so that the
additional features this interface provides (better error reporting) is
actually available to every client code which is aware of this feature.
In particular, this makes the finer error reporting available from the
"Interpreter" view.
Bug: 474878
Change-Id: I270bda79f2fe3a3f6d89dcb509a8e64bd2e23ada
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/interpreter/ODesignGenericInterpreter.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/interpreter/ODesignGenericInterpreter.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/interpreter/ODesignGenericInterpreter.java index 85c248a24d..b82f94aeed 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/interpreter/ODesignGenericInterpreter.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/interpreter/ODesignGenericInterpreter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; import org.eclipse.sirius.common.tools.DslCommonPlugin; @@ -31,6 +32,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter; import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterContext; import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterProvider; import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterStatus; +import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterWithDiagnostic; import org.eclipse.sirius.common.tools.api.interpreter.IVariableStatusListener; import org.eclipse.sirius.common.tools.api.interpreter.VariableManager; import org.eclipse.sirius.common.tools.api.profiler.ProfilerTask; @@ -45,7 +47,7 @@ import com.google.common.collect.Sets; * * @author ymortier */ -public class ODesignGenericInterpreter implements IInterpreter, IProposalProvider { +public class ODesignGenericInterpreter implements IInterpreter, IProposalProvider, IInterpreterWithDiagnostic { /** Maps provider with interpreters. */ private final Map<IInterpreterProvider, IInterpreter> loadedInterpreters = new HashMap<IInterpreterProvider, IInterpreter>(); @@ -116,6 +118,31 @@ public class ODesignGenericInterpreter implements IInterpreter, IProposalProvide } @Override + public IEvaluationResult evaluateExpression(final EObject target, final String expression) throws EvaluationException { + final IInterpreter interpreter = getInterpreter(expression); + if (interpreter instanceof IInterpreterWithDiagnostic) { + return ((IInterpreterWithDiagnostic) interpreter).evaluateExpression(target, expression); + } + + // Fall back on the default behavior otherwise with an OK diagnostic + final Object result = interpreter.evaluate(target, expression); + + IEvaluationResult evaluationResult = new IEvaluationResult() { + @Override + public Object getValue() { + return result; + } + + @Override + public Diagnostic getDiagnostic() { + return Diagnostic.OK_INSTANCE; + } + }; + + return evaluationResult; + } + + @Override public Object evaluate(final EObject target, final String expression) throws EvaluationException { preEvaluation(expression); final Object evaluate = getInterpreter(expression).evaluate(target, expression); |
