use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class JavaJob method searchForMainBlockInCurrentFile.
/**
* @return a module with a main block from the current file or null if no such module was found
* @throws AbsJobException
*/
private ModuleDecl searchForMainBlockInCurrentFile() throws AbsJobException {
if (currentFile == null) {
return null;
}
AbsNature nature = UtilityFunctions.getAbsNature(project);
if (nature == null) {
throw new AbsJobException("Could not start the debugger, because selected file (" + currentFile.getName() + ") is not in an ABS project!");
}
synchronized (nature.modelLock) {
CompilationUnit unit = nature.getCompilationUnit(currentFile);
List<ModuleDecl> modules = findModulesWithMain(unit);
// TODO: is the module still valid once you have returned the lock?
return modules.size() == 0 ? null : modules.get(0);
}
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class JavaJob method getModuleByName.
/**
* finds a module with a given name in the current
* @param moduleName
* @return
* @throws AbsJobException
*/
private ModuleDecl getModuleByName(String moduleName) throws AbsJobException {
AbsNature nature = UtilityFunctions.getAbsNature(project);
if (nature == null) {
throw new AbsJobException("Could not start the debugger, because selected file (" + currentFile.getName() + ") is not in an ABS project!");
}
synchronized (nature.modelLock) {
Model model = nature.getCompleteModel();
ModuleDecl result = model.lookupModule(moduleName);
if (result == null) {
throw new AbsJobException("Could not find a module with name " + moduleName + ".");
}
return result;
}
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class JavaTabMain method getRunTargets.
private List<RunTarget> getRunTargets(IProject proj) {
AbsNature n = UtilityFunctions.getAbsNature(proj);
if (n == null) {
return Collections.emptyList();
}
Model m = n.getCompleteModel();
if (m == null) {
return Collections.emptyList();
}
List<RunTarget> result = new ArrayList<RunTarget>();
for (CompilationUnit cu : m.getCompilationUnits()) {
for (ModuleDecl module : cu.getModuleDecls()) {
if (module.getBlockOpt().hasChildren()) {
if (module.getName().equals(ABSTestRunnerGenerator.RUNNER_MAIN)) {
// do not show generated unit test file
continue;
}
result.add(new RunTargetModule(module));
}
// TODO add unit test classes
// for (Decl d : module.getDecls()) {
// if (d.isInterface()) {
// InterfaceDecl i = (InterfaceDecl) d;
// for (Annotation annotation : i.getAnnotations()) {
// if (annotation.getValue() )
// }
// }
// }
}
}
result.add(new RunTargetUnitTests());
return result;
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateTestRunner.
@Override
public void generateTestRunner(PrintStream stream) {
ModuleDecl module = new ModuleDecl();
module.setName(RUNNER_MAIN);
module.setImportList(generateImportsAST());
module.setBlock(generateMainBlockAST(module.getImportList()));
PrintWriter writer = new PrintWriter(stream, true);
ABSFormatter formatter = new DefaultABSFormatter(writer);
module.doPrettyPrint(writer, formatter);
}
Aggregations