use of org.eclipse.titan.designer.AST.TTCN3.statements.Statement in project titan.EclipsePlug-ins by eclipse.
the class SuperfluousTemplate method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Operation_Altguard) {
final Operation_Altguard ag = (Operation_Altguard) node;
final Statement action = ag.getGuardStatement();
if (action instanceof Receive_Port_Statement) {
final Receive_Port_Statement receive = (Receive_Port_Statement) action;
final SuperfluousTemplate st = new SuperfluousTemplate(receive);
receive.accept(st);
if (st.canReceiveAny() && st.hasValueRedirect()) {
if (st.getReceivable() == null) {
problems.report(receive.getLocation(), CAN_RECEIVE_ANY_OF_MULTIPLE);
} else {
problems.report(receive.getLocation(), CAN_RECEIVE_ANY_OF_ONE);
}
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.Statement in project titan.EclipsePlug-ins by eclipse.
the class ConsecutiveAssignments method process.
@Override
protected void process(final IVisitableNode node, final Problems problems) {
if (!(node instanceof StatementBlock)) {
return;
}
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
int count = 0;
boolean limitReached = false;
Location smellLoc = null;
Assignment_Statement lastAs = null;
Assignment toMatch = null;
final StatementBlock sb = (StatementBlock) node;
// iterate statements in block
for (int i = 0; i < sb.getSize(); i++) {
final Statement s = sb.getStatementByIndex(i);
if (!(s instanceof Assignment_Statement)) {
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
limitReached = false;
}
count = 0;
toMatch = null;
continue;
}
final Assignment_Statement as = (Assignment_Statement) s;
final Reference ref = as.getReference();
final Assignment a = ref.getRefdAssignment(timestamp, false);
if (a == null) {
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
limitReached = false;
}
count = 0;
toMatch = null;
continue;
}
// consecutive assignments: consecutive Assignment_Statements have the same definition
if (toMatch == null) {
toMatch = a;
} else if (toMatch != a) {
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
limitReached = false;
}
count = 0;
toMatch = a;
}
if (count == 0) {
smellLoc = new Location(as.getLocation());
}
lastAs = as;
count++;
if (count >= minCountToMark) {
limitReached = true;
}
}
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
}
}
Aggregations