use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement in project titan.EclipsePlug-ins by eclipse.
the class IsBoundWithoutElse method process.
@Override
protected void process(final IVisitableNode node, final Problems problems) {
if (!(node instanceof If_Statement)) {
return;
}
final If_Statement ifs = (If_Statement) node;
final StatementBlock elseClause = ifs.getStatementBlock();
if (elseClause != null) {
return;
}
// there is no else clause present
final If_Clauses ifcs = ifs.getIfClauses();
if (ifcs == null) {
return;
}
final List<If_Clause> ifcL = ifcs.getClauses();
if (ifcL == null || ifcL.isEmpty()) {
return;
}
for (final If_Clause ifc : ifcL) {
final IfConditionVisitor visitor = new IfConditionVisitor(problems);
ifc.accept(visitor);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement in project titan.EclipsePlug-ins by eclipse.
the class LogicInversion method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof If_Statement) {
final If_Statement s = (If_Statement) node;
if (s.getStatementBlock() == null) {
return;
}
final If_Clauses ifClauses = s.getIfClauses();
if (ifClauses == null) {
return;
}
final List<If_Clause> clauses = ifClauses.getClauses();
if (clauses.size() != 1) {
return;
}
final Value expression = clauses.get(0).getExpression();
if (expression != null && Value_type.EXPRESSION_VALUE.equals(expression.getValuetype()) && Operation_type.NOT_OPERATION.equals(((Expression_Value) expression).getOperationType())) {
problems.report(s.getLocation(), ERROR_MESSAGE);
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement 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.TTCN3.statements.If_Statement in project titan.EclipsePlug-ins by eclipse.
the class IfInsteadAltguard method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof AltGuard) {
final AltGuard ag = (AltGuard) node;
final StatementBlock statements = ag.getStatementBlock();
if (statements != null && !statements.isEmpty()) {
final Statement firstStatement = statements.getStatementByIndex(0);
if (firstStatement instanceof If_Statement) {
final Value condition = ((If_Statement) firstStatement).getIfClauses().getClauses().get(0).getExpression();
Location reportAt;
if (condition != null) {
reportAt = condition.getLocation();
} else {
reportAt = firstStatement.getLocation();
}
problems.report(reportAt, MIGHT_ALTGUARD);
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement in project titan.EclipsePlug-ins by eclipse.
the class ContainsRef method visit.
@Override
public int visit(final IVisitableNode node) {
if (node instanceof If_Statement) {
final List<If_Clause> ifs = ((If_Statement) node).getIfClauses().getClauses();
for (final If_Clause clause : ifs) {
final Value cond = clause.getExpression();
if (cond != null) {
final RefUsedInMatching mv = new RefUsedInMatching(redirectValue);
cond.accept(mv);
if (mv.getUsed()) {
smells = true;
suspicious = clause;
}
}
}
return V_SKIP;
}
return V_CONTINUE;
}
Aggregations