use of abs.frontend.ast.ModuleDecl 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);
}
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class ModuleDecorator method checkModulePath.
private void checkModulePath(IDecoration decoration, ModulePath m) {
AbsNature nature = m.getNature();
Model model = nature.getCompleteModel();
if (model != null) {
for (ModuleDecl mod : model.getModuleDecls()) {
if (mod.getName().startsWith(m.getModulePath() + ".")) {
if (hasModuleDeclErrors(mod, nature)) {
addErrorOverlay(decoration);
return;
}
}
}
}
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class ModuleDecorator method decorate.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public void decorate(Object element, IDecoration decoration) {
if (element instanceof InternalASTNode<?>) {
InternalASTNode<?> node = (InternalASTNode<?>) element;
if (node.hasASTNodeOfType(ModuleDecl.class)) {
checkModuleDecl(decoration, (InternalASTNode<ModuleDecl>) node);
}
} else if (element instanceof ModulePath) {
ModulePath m = (ModulePath) element;
checkModulePath(decoration, m);
} else if (element instanceof IProject) {
IProject project = (IProject) element;
checkProject(project, decoration);
}
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class ABSNavigatorStyledLabelProvider method getStyledString.
/**
* Gets a styledString for the object. If the object is
* <ul>
* <li>an InternalASTnode<ModuleDecl>, the part of the name after the last '.' will be returned.</li>
* </ul>
* In all other cases {@link org.absmodels.abs.plugin.editor.outline.ABSContentOutlineUtils#getLabel(ModulePath)} will be used.
* @param obj the Object whose String representation should be returned
* @return A String representation of obj
*/
protected StyledString getStyledString(Object obj) {
StyledString styledString;
if (obj instanceof InternalASTNode) {
InternalASTNode<?> node = (InternalASTNode<?>) obj;
if (node.getASTNode() instanceof ModuleDecl) {
String name = ((ModuleDecl) node.getASTNode()).getName();
String lastName;
if (name.indexOf('.') > 0) {
lastName = name.substring(name.lastIndexOf('.') + 1, name.length());
} else {
lastName = name;
}
styledString = new StyledString(lastName, STYLER_BLACK);
} else {
styledString = getLabel(node);
}
} else if (obj instanceof ModulePath) {
styledString = getLabel((ModulePath) obj);
} else {
styledString = getLabel(obj);
}
return styledString;
}
use of abs.frontend.ast.ModuleDecl in project abstools by abstools.
the class LinkHelper method getModuleDeclAtCurrentCursor.
private ModuleDecl getModuleDeclAtCurrentCursor(IFile file, AbsNature nature, ITextEditor editor) {
ModuleDecl md = null;
synchronized (nature.modelLock) {
if (nature.getCompilationUnit(file).getNumModuleDecl() > 0) {
// get start line of editor selection
ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
int startLine = selection.getStartLine();
CompilationUnit cu = nature.getCompilationUnit(file);
// find the module which the selection is located in...
for (ModuleDecl m : cu.getModuleDecls()) {
EditorPosition position = UtilityFunctions.getPosition(m);
int moduleStartLine = position.getLinestart();
int moduleEndLine = position.getLineend();
if (startLine >= moduleStartLine && startLine <= moduleEndLine) {
md = m;
break;
}
}
// if no module was found or no selection was made, take the first one in the compilation unit as fallback
if (md == null) {
md = cu.getModuleDecl(0);
}
}
}
return md;
}
Aggregations