| /********************************************************************* |
| * Copyright (c) 2019 The University of York. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| **********************************************************************/ |
| package org.eclipse.epsilon.executors; |
| |
| import java.io.File; |
| import java.util.Collection; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Optional; |
| |
| import org.eclipse.epsilon.common.parse.problem.ParseProblem; |
| import org.eclipse.epsilon.eol.exceptions.EolRuntimeException; |
| import org.eclipse.epsilon.eol.models.IModel; |
| import org.eclipse.epsilon.eol.types.IToolNativeTypeDelegate; |
| import org.eclipse.epsilon.erl.execute.RuleProfiler; |
| |
| /** |
| * The IEpsilonLanguageExecutor defines a common executor API that the different Epsilon languages |
| * can use to facilitate running Epsilon scripts in standalone applications. |
| * <p> |
| * The API provides 4 phases to the execution of an Epsilon Module: {@link #preProcess}, {@link #execute}, |
| * {@link #postProcess}, and {@link #dispose}. |
| * The 4 phases should provide enough flexibility for specific executors to correctly prepare |
| * execution, execute, do any post execution processing and finally dispose the executor. |
| * |
| * @author Horacio Hoyos Rodriguez |
| * |
| */ |
| public interface EpsilonLanguageExecutor<R> { |
| |
| // Methods to interact with the underlying module |
| boolean parse(File file) throws Exception; |
| |
| // boolean parse(URI uri) throws Exception; |
| |
| boolean parse(String code) throws Exception; |
| |
| List<ParseProblem> getParseProblems(); |
| |
| void addModels(Collection<IModel> models); |
| |
| void addParamters(final Map<String, ?> parameters); |
| |
| void addNativeTypeDelegates(Collection<IToolNativeTypeDelegate> nativeDelegates); |
| |
| Optional<RuleProfiler> getRuleProfiler(); |
| |
| void disposeModelRepository(); |
| |
| void clearModelRepository(); |
| |
| void dispose(); |
| |
| /** |
| * This method will be invoked before execution of the script |
| */ |
| void preProcess(); |
| |
| /** |
| * This method will be invoked after execution of the script |
| */ |
| void postProcess(); |
| |
| /** |
| * Execute the provided script, against the list of models using the executor's module. |
| * @throws EpsilonExecutorException |
| */ |
| R execute() throws EolRuntimeException; |
| |
| } |