use of org.eclipse.titan.designer.AST.IVisitableNode in project titan.EclipsePlug-ins by eclipse.
the class ConstantParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof Identifier) {
name = node.toString();
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
value = new Value(type, Writable.NULL);
return Action.skip(Type.class, this);
}
if (node instanceof org.eclipse.titan.designer.AST.Value) {
ValueHolder holder = v -> value = v;
return dispatch(this, type, holder, node);
}
return this;
}
use of org.eclipse.titan.designer.AST.IVisitableNode in project titan.EclipsePlug-ins by eclipse.
the class Export_Debug_AST_Action method exportDebugAST.
private void exportDebugAST(final ZipOutputStream out, final Module module) throws Exception {
out.putNextEntry(new ZipEntry("DebugAST_for_" + module.getIdentifier().getName() + ".txt"));
out.write("*************************".getBytes());
out.write(lineend);
out.write(("Printing DEBUG information for module `" + module.getName() + "':").getBytes());
out.write(lineend);
out.write("*************************".getBytes());
out.write(lineend);
module.accept(new ASTVisitor() {
private int padding = 0;
@Override
public int visit(IVisitableNode node) {
if (node instanceof Assignment) {
Assignment assignment = (Assignment) node;
printInfoln(out, padding, assignment.getAssignmentName(), assignment.getFullName(), assignment.getLastTimeChecked(), assignment.getLocation());
} else if (node instanceof Identifier) {
printInfoln(out, padding, "identifier", ((Identifier) node).getDisplayName(), null, ((Identifier) node).getLocation());
} else if (node instanceof Statement) {
Statement statement = (Statement) node;
printInfoln(out, padding, "statement", statement.getFullName(), statement.getLastTimeChecked(), statement.getLocation());
} else if (node instanceof Reference) {
Reference ref = (Reference) node;
printInfoln(out, padding, "reference", ref.getFullName(), ref.getLastTimeChecked(), ref.getLocation());
Assignment old = ref.getAssOld();
if (old != null) {
printInfoln(out, padding + 1, "This reference was last pointing to " + old.getFullName() + " analyzed at " + old.getLastTimeChecked());
}
} else if (node instanceof ComponentTypeBody) {
ComponentTypeBody body = (ComponentTypeBody) node;
Map<String, Definition> map = body.getDefinitionMap();
printInfoln(out, padding + 1, " contains definitions:");
if (map != null) {
for (Map.Entry<String, Definition> entry : map.entrySet()) {
printInfoln(out, padding + 2, entry.getKey() + " was last checked at " + entry.getValue().getLastTimeChecked());
}
}
}
if (node instanceof StatementBlock || node instanceof Definition) {
padding++;
}
return super.visit(node);
}
@Override
public int leave(IVisitableNode node) {
if (node instanceof StatementBlock || node instanceof Definition) {
padding--;
}
return super.leave(node);
}
});
out.write("*************************".getBytes());
out.write(lineend);
out.write(("Printing DEBUG information for module `" + module.getName() + "' finished").getBytes());
out.write(lineend);
out.write("*************************".getBytes());
out.write(lineend);
out.closeEntry();
}
use of org.eclipse.titan.designer.AST.IVisitableNode in project titan.EclipsePlug-ins by eclipse.
the class FMLinesOfCode method measure.
@Override
public Number measure(final MetricData data, final Def_Function function) {
final Counter count = new Counter(0);
function.accept(new CounterVisitor(count) {
@Override
public int visit(final IVisitableNode node) {
if (node instanceof Def_Function) {
return V_CONTINUE;
} else if (node instanceof StatementBlock) {
count.set(((LargeLocation) ((StatementBlock) node).getLocation()).getEndLine());
}
return V_SKIP;
}
});
return count.val() - function.getLocation().getLine() + 1;
}
use of org.eclipse.titan.designer.AST.IVisitableNode in project titan.EclipsePlug-ins by eclipse.
the class IfContext method process_internal.
protected void process_internal() {
final If_Statement st = getNode();
final If_Clauses ics = st.getIfClauses();
final Context child = getChild();
if (child != null && child.getNode().equals(ics)) {
// the log statement is in one of the conditional clauses
final List<If_Clause> icl = ics.getClauses();
final Context clauseContext = child.getChild();
if (clauseContext != null && icl.contains(clauseContext.getNode())) {
final IVisitableNode ic = clauseContext.getNode();
final ClauseVisitor vis = new ClauseVisitor();
ic.accept(vis);
final List<Reference> refs = vis.getResult();
for (Reference ref : refs) {
varNamesInConditions.add(ref.getDisplayName());
}
}
} else {
// the log statement is in the else block
final List<Reference> refs = extractAllIdsFromClauses(ics);
for (Reference ref : refs) {
varNamesInConditions.add(ref.getDisplayName());
}
}
}
use of org.eclipse.titan.designer.AST.IVisitableNode in project titan.EclipsePlug-ins by eclipse.
the class Environment method isLoopScope.
/**
* Returns true if the given BlockNode is a statement block of a loop statement (for, while, alt)
*/
private static boolean isLoopScope(final BlockNode scope) {
final StatementNode parentSN = scope.getParent();
if (parentSN == null) {
return false;
}
final IVisitableNode scopeSt = parentSN.getAstNode();
return (scopeSt instanceof For_Statement || scopeSt instanceof While_Statement || scopeSt instanceof Alt_Statement);
}
Aggregations