Search in sources :

Example 1 with InvalidRandomSeedException

use of org.absmodels.abs.plugin.debug.model.Debugger.InvalidRandomSeedException in project abstools by abstools.

the class JavaJob method findAndExecuteMain.

/**
 * Tries to find the main block in the chosen ABS file or in the
 * ABS project, if file is null.
 *
 * Finally: executes Modulename.Main
 *
 * @param absFrontendLocation - where to find the absfrontend
 * @throws AbsJobException - if no main block found
 * @throws IOException - If an I/O error occurs
 */
private void findAndExecuteMain(String absFrontendLocation) throws AbsJobException, IOException {
    String info = null;
    ModuleDecl module;
    if (absUnit) {
        module = getModuleByName(ABSTestRunnerGenerator.RUNNER_MAIN);
    } else if (runTarget != null) {
        module = getModuleByName(runTarget);
    } else {
        module = searchForMainBlockInCurrentFile();
        // Search for the main file if previous searching was not successful
        if (module == null) {
            List<ModuleDecl> modules = getAllModulesWithMainInCurrentProject();
            if (modules.size() == 0) {
                throw new AbsJobException("No Module with main block found.");
            } else {
                module = modules.get(0);
            }
            if (currentFile != null) {
                info = "No main file found for \"" + currentFile.getName() + "\".\nBut there is a main file in the project:";
            }
        }
    }
    String moduleName = JavaBackend.getFullJavaNameForMainBlock(module);
    try {
        debugAbsFiles(absFrontendLocation, javaPath, startSDE, moduleName, info);
    } catch (InvalidRandomSeedException e) {
        throw new AbsJobException(e);
    }
}
Also used : InvalidRandomSeedException(org.absmodels.abs.plugin.debug.model.Debugger.InvalidRandomSeedException) ModuleDecl(abs.frontend.ast.ModuleDecl) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) AbsJobException(org.absmodels.abs.plugin.exceptions.AbsJobException)

Aggregations

ModuleDecl (abs.frontend.ast.ModuleDecl)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 InvalidRandomSeedException (org.absmodels.abs.plugin.debug.model.Debugger.InvalidRandomSeedException)1 AbsJobException (org.absmodels.abs.plugin.exceptions.AbsJobException)1