use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class ModuleDecorator method checkSemanticErrorRange.
private boolean checkSemanticErrorRange(SemanticConditionList list, CompilationUnit c, int startLine, int endLine, AbsNature nature) {
synchronized (nature.modelLock) {
if (list != null) {
if (list.containsErrors()) {
for (SemanticCondition err : list) {
ASTNode<?> node = err.getNode();
int line = err.getLine();
CompilationUnit cu = node.getCompilationUnit();
if (c == cu && checkLine(line, startLine, endLine)) {
return true;
}
}
}
}
}
return false;
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class OpenTypeHierarchyDelegate method getNodeUnderCursor.
InternalASTNode<?> getNodeUnderCursor(ABSEditor abseditor, TextSelection sel) {
InternalASTNode<CompilationUnit> cu = abseditor.getCompilationUnit();
if (cu == null) {
return null;
}
IDocument doc = abseditor.getDocumentProvider().getDocument(editor.getEditorInput());
synchronized (cu.getNature()) {
try {
ASTNode<?> node = UtilityFunctions.getASTNodeOfOffset(doc, cu.getASTNode(), sel.getOffset());
return new InternalASTNode(node, cu.getNature());
} catch (BadLocationException e) {
e.printStackTrace();
}
}
return null;
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class IncrementalModelBuilder method addCompilationUnit.
/**
* Creates an empty model with only the stdlib when you pass null.
*/
public synchronized void addCompilationUnit(CompilationUnit cu) {
if (model == null) {
model = new Model();
model.addCompilationUnit(getStdLibCompilationUnit());
if (// just give us the stdlib
cu != null)
model.addCompilationUnit(cu);
return;
}
if (cu == null)
return;
String filename = cu.getFileName();
assert filename != null;
CompilationUnit cuold = null;
try {
cuold = getCompilationUnit(filename);
} catch (NoModelException e) {
// we're pretty sure there's a model.
assert false;
}
List<CompilationUnit> culist = model.getCompilationUnitList();
int cindex = culist.getIndexOfChild(cuold);
if (cindex > 0) {
model.setCompilationUnit(cu, cindex);
} else {
model.addCompilationUnit(cu);
}
// model.flushCache();
flushAll(model);
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class IncrementalModelBuilder method getStdLibCompilationUnit.
private CompilationUnit getStdLibCompilationUnit() {
CompilationUnit stdLib;
File bundle;
try {
stdLib = new Main().getStdLib();
bundle = FileLocator.getBundleFile(Platform.getBundle(ABSFRONTEND_PLUGIN_ID));
} catch (IOException e) {
Activator.logException(e);
// Your plugin is probably busted.
return null;
} catch (InternalBackendException e) {
Activator.logException(e);
// Your plugin is probably busted.
return null;
}
File src = new File(bundle, stdLib.getFileName());
if (!src.exists()) {
src = new File(bundle, "src/" + stdLib.getFileName());
}
stdLib.setName(src.getAbsolutePath());
return stdLib;
}
use of abs.frontend.ast.CompilationUnit in project abstools by abstools.
the class IncrementalModelBuilder method getCompilationUnit.
public synchronized CompilationUnit getCompilationUnit(String fileName) throws NoModelException {
if (model == null)
throw new NoModelException();
Iterator<CompilationUnit> iter = model.getCompilationUnits().iterator();
// normalize representation:
fileName = normalizePath(fileName);
while (iter.hasNext()) {
CompilationUnit cu = iter.next();
String cuFileName = cu.getFileName();
// normalize representation:
cuFileName = normalizePath(cuFileName);
if (fileName.equals(cuFileName)) {
return cu;
}
}
return null;
}
Aggregations