Search in sources :

Example 6 with AltGuard

use of org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard 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);
            }
        }
    }
}
Also used : AltGuard(org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard) Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Statement) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) Value(org.eclipse.titan.designer.AST.Value) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) Location(org.eclipse.titan.designer.AST.Location)

Example 7 with AltGuard

use of org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard in project titan.EclipsePlug-ins by eclipse.

the class Def_Altstep method setMyScope.

@Override
public /**
 * {@inheritDoc}
 */
void setMyScope(final Scope scope) {
    if (bridgeScope != null && bridgeScope.getParentScope() == scope) {
        return;
    }
    bridgeScope = new NamedBridgeScope();
    bridgeScope.setParentScope(scope);
    scope.addSubScope(getLocation(), bridgeScope);
    bridgeScope.setScopeMacroName(identifier.getDisplayName());
    super.setMyScope(bridgeScope);
    if (runsOnRef != null) {
        runsOnRef.setMyScope(bridgeScope);
    }
    formalParList.setMyScope(bridgeScope);
    if (block != null) {
        block.setMyScope(formalParList);
        altGuards.setMyScope(block);
        bridgeScope.addSubScope(block.getLocation(), block);
    }
    bridgeScope.addSubScope(formalParList.getLocation(), formalParList);
    if (altGuards != null) {
        for (int i = 0; i < altGuards.getNofAltguards(); i++) {
            final AltGuard ag = altGuards.getAltguardByIndex(i);
            final StatementBlock sb = ag.getStatementBlock();
            if (sb != null) {
                bridgeScope.addSubScope(sb.getLocation(), sb);
            }
        }
    }
}
Also used : AltGuard(org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard) NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)3 Reference (org.eclipse.titan.designer.AST.Reference)3 AltGuard (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard)3 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)3 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)3 Assignment (org.eclipse.titan.designer.AST.Assignment)2 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)2 AltGuard.altguard_type (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard.altguard_type)2 Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Statement)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IType (org.eclipse.titan.designer.AST.IType)1 Location (org.eclipse.titan.designer.AST.Location)1 NamedBridgeScope (org.eclipse.titan.designer.AST.NamedBridgeScope)1 AltGuards (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards)1 Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)1 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)1 If_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement)1 Operation_Altguard (org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)1 Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement)1