use of abs.frontend.ast.CompilationUnit 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.CompilationUnit in project abstools by abstools.
the class ModuleDecorator method hasModuleDeclErrors.
/**
* Determines if a module declaration has any errors
*
* @param m
* the module declaration
* @param nature
* the ABS nature
* @return TRUE if the module declaration has errors, FALSE if not or m or
* nature is null
*/
public boolean hasModuleDeclErrors(ModuleDecl m, AbsNature nature) {
synchronized (nature.modelLock) {
if (m != null) {
CompilationUnit cu = m.getCompilationUnit();
EditorPosition pos = UtilityFunctions.getPosition(m);
int startLine = pos.getLinestart();
int endLine = pos.getLineend();
List<ParserError> parserErrors = cu.getParserErrors();
SemanticConditionList list = cu.getModel().getTypeErrors();
if (checkParserErrorRange(startLine, endLine, parserErrors)) {
return true;
} else {
return checkSemanticErrorRange(list, cu, startLine, endLine, nature);
}
}
return false;
}
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class ABSReconcilingStrategy method reconcile.
public synchronized CompilationUnit reconcile(AbsNature nature, boolean withTypechecks) {
CompilationUnit compilationUnit = parseDocument();
if (nature == null) {
setParseErrorMarkers(compilationUnit.getParserErrors());
editor.onCompilationUnitChange(compilationUnit);
return compilationUnit;
}
if (compilationUnit.getParserErrors() == null) {
compilationUnit.setParserErrors(Collections.<ParserError>emptyList());
}
setParseErrorMarkers(compilationUnit.getParserErrors());
AbsModelManager manager = nature.getModelManager();
manager.updateModel(compilationUnit, withTypechecks);
editor.onCompilationUnitChange(manager.getCompilationUnit(editor.getAbsoluteFilePath()));
return compilationUnit;
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class ABSReconcilingStrategy method parseDocument.
private CompilationUnit parseDocument() {
String code = document.get();
CompilationUnit compilationUnit = parse(code);
if (compilationUnit == null || compilationUnit.getNumModuleDecl() + compilationUnit.getNumFeatureDecl() == 0) {
try {
// add semicolon to end of current line and try to parse again
int caretPos = editor.getCaretPos();
IRegion lineInfo = document.getLineInformationOfOffset(caretPos);
int endOfLine = lineInfo.getOffset() + lineInfo.getLength();
code = document.get(0, endOfLine) + ";" + document.get(endOfLine, document.getLength() - endOfLine);
System.out.println(code);
CompilationUnit compilationUnit2 = parse(code);
if (compilationUnit2 != null && compilationUnit2.getNumModuleDecl() + compilationUnit2.getNumFeatureDecl() > 0) {
// compilationUnit2 has better results, so use it
compilationUnit = compilationUnit2;
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
return compilationUnit;
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class AbsModelManagerImpl method updateModel.
@Override
public synchronized void updateModel(CompilationUnit cu, boolean withTypechecks) {
boolean added = false;
for (int i = 0; i < model.getNumCompilationUnit(); i++) {
CompilationUnit c = model.getCompilationUnit(i);
if (c.getFileName().equals(cu.getFileName())) {
// update compilation unit:
model.setCompilationUnit(cu, i);
added = true;
break;
}
}
if (!added) {
model.addCompilationUnit(cu);
}
if (!model.hasParserErrors()) {
if (withTypechecks) {
extendedTypechecking();
}
}
notifyChangeListeners();
}
Aggregations