use of org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement in project titan.EclipsePlug-ins by eclipse.
the class TestCase_Function_Visit_Handler method leave.
public void leave(IVisitableNode node) {
if (waitForTC || waitForFunction) {
if (node instanceof Definition_Statement) {
if (!waitForRecord) {
nodeVarIsRecord.add(false);
}
waitForRecord = false;
waitForValue = false;
evaluateExpression();
}
if (node instanceof Undefined_LowerIdentifier_Value) {
blockReferenceListing = false;
}
if ((node instanceof Assignment_Statement) || ((node instanceof If_Clause))) {
waitForValue = false;
// if assignment is a createExpression
if (node instanceof Assignment_Statement) {
if (((Assignment_Statement) node).getTemplate() instanceof SpecificValue_Template) {
SpecificValue_Template specValTemplate = (SpecificValue_Template) ((Assignment_Statement) node).getTemplate();
if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
isCreate = true;
}
}
}
evaluateExpression();
}
if (node instanceof SequenceOf_Value) {
evaluateExpression();
}
if ((waitForFunction && (node instanceof Return_Statement)) || (waitForTC && (node instanceof ComponentCreateExpression)) || (node instanceof Send_Statement) || (node instanceof Receive_Port_Statement)) {
evaluateExpression();
}
if (waitForTcStartValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
myASTVisitor.blockIdListing = false;
}
if (waitForTcStopValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
myASTVisitor.blockIdListing = false;
}
if (node instanceof Connect_Statement) {
waitForTcConnectValues = false;
}
if (node instanceof Disconnect_Statement) {
waitForTcDisconnectValues = false;
}
if (node instanceof Unknown_Start_Statement) {
waitForTcStartValues = false;
}
if (node instanceof Unknown_Stop_Statement) {
waitForTcStopValues = false;
}
if (node instanceof Definition_Statement) {
waitForDefStatement = false;
if (waitForValue) {
nodeVarValues.add(null);
nodeVarIsAValueReference.add(false);
waitForValue = false;
}
}
if (node instanceof Map_Statement) {
waitForMapIdentifiers = false;
}
if (node instanceof ComponentCreateExpression) {
// switch first two values
testCaseCreateValues.add(testCaseCreateCharValues.get(0));
testCaseCreateValues.add(testCaseCreateRefValues.get(0));
for (int i = 1; i < testCaseCreateCharValues.size(); i++) {
testCaseCreateValues.add(testCaseCreateCharValues.get(i));
}
testCaseCreateCharValues.clear();
testCaseCreateRefValues.clear();
waitForTcCreateValues = false;
}
if (node instanceof Assignment_Statement) {
waitForAssignmentIdentifiers = false;
waitForValue = true;
}
if (waitForTcIfCondition && (node instanceof If_Clause)) {
waitForTcIfCondition = false;
}
if (waitForTcStartParameter && (node instanceof Unknown_Start_Statement)) {
testCaseStartValueParameters.add(null);
}
if (waitForTcStopParameter && (node instanceof Unknown_Stop_Statement)) {
testCaseStopValueParameters.add(null);
}
if (isAltGuards && (node instanceof Operation_Altguard)) {
altGuardConditions.add(null);
}
if (node instanceof Operation_Altguard) {
waitForAltStatements = false;
isAltGuards = false;
isReceiveValue = false;
}
handleAltCases(node);
if (node instanceof Unknown_Start_Statement) {
waitForUnknownStartStatement = false;
}
if (node instanceof Unknown_Stop_Statement) {
waitForUnknownStopStatement = false;
}
if (node instanceof Receive_Port_Statement) {
if (waitForReceiveParameter) {
altGuardReceiveType.add("noparam");
}
// TODO checkAnyport = true;
}
}
if (node instanceof Def_Testcase) {
handleTestcase(node);
waitForTC = false;
}
if (node instanceof Def_Function) {
handleFunction(node);
waitForTC = false;
}
if (waitForAssignmentIdentifiers && (node instanceof ArraySubReference)) {
waitForAssignmentIdentifiers = false;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement in project titan.EclipsePlug-ins by eclipse.
the class Def_Testcase_Writer method writeTestCaseFunction.
public String writeTestCaseFunction(StatementBlock tcStatementBlock) {
int testcaseSize = tcStatementBlock.getSize();
for (int j = 0; j < testcaseSize; j++) {
if (tcStatementBlock.getStatementByIndex(j) instanceof Definition_Statement) {
Definition_Statement tc_defStatement = (Definition_Statement) tcStatementBlock.getStatementByIndex(j);
defCounter++;
defValueCounter++;
writeDefinitionStatement(tc_defStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Assignment_Statement) {
Assignment_Statement tc_assignStatement = (Assignment_Statement) tcStatementBlock.getStatementByIndex(j);
assignCounter++;
testCaseString.append(writeAssignmentStatement(tc_assignStatement));
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Connect_Statement) {
Connect_Statement tc_connectStatement = (Connect_Statement) tcStatementBlock.getStatementByIndex(j);
connectCounter++;
writeConnectStatement(tc_connectStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Start_Statement) {
Unknown_Start_Statement tc_startStatement = (Unknown_Start_Statement) tcStatementBlock.getStatementByIndex(j);
writeUnknownStartStatement(tc_startStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Done_Statement) {
testCaseString.append("hc.done(\"all component\");" + "\r\n");
// TODO: where is all coming from?
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Map_Statement) {
Map_Statement tc_mapStatement = (Map_Statement) tcStatementBlock.getStatementByIndex(j);
mapCounter++;
writeMapStatement(tc_mapStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof If_Statement) {
If_Statement tc_ifStatement = (If_Statement) tcStatementBlock.getStatementByIndex(j);
tcIfConditionCounter++;
writeIfStatement(tc_ifStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Setverdict_Statement) {
Setverdict_Statement tc_setVerdictStatement = (Setverdict_Statement) tcStatementBlock.getStatementByIndex(j);
writeSetVerdictStatement(tc_setVerdictStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof DoWhile_Statement) {
doWhileCounter++;
DoWhile_Statement doWhileStatement = (DoWhile_Statement) tcStatementBlock.getStatementByIndex(j);
String test = doWhileStatement.getExpression().toString();
testCaseString.append("do{" + "\r\n");
this.writeTestCaseFunction(doWhileStatement.getStatementBlock());
testCaseString.append("while(" + doWhileExpressions.get(doWhileCounter) + ".getValue());\r\n");
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Send_Statement) {
Send_Statement tc_SendStatement = (Send_Statement) tcStatementBlock.getStatementByIndex(j);
sendCounter++;
testCaseString.append(writeSendStatement(tc_SendStatement));
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Receive_Port_Statement) {
Receive_Port_Statement tc_ReceiveStatement = (Receive_Port_Statement) tcStatementBlock.getStatementByIndex(j);
receiveCounter++;
blockStatementBlockStatementWriter = true;
testCaseString.append(writeReceiveStatement(tc_ReceiveStatement));
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Stop_Statement) {
Unknown_Stop_Statement tc_StopStatement = (Unknown_Stop_Statement) tcStatementBlock.getStatementByIndex(j);
writeUnknownStopStatement(tc_StopStatement);
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Alt_Statement) {
altStatementCounter++;
altStatements.get(altStatementCounter).setTimerInfo(isThereAStartedTimer, currentTimerName);
testCaseString.append(altStatements.get(altStatementCounter).getJavaSource());
} else if (tcStatementBlock.getStatementByIndex(j) instanceof Disconnect_Statement) {
Disconnect_Statement tc_disconnectStatement = (Disconnect_Statement) tcStatementBlock.getStatementByIndex(j);
disconnectCounter++;
writeDisconnectStatement(tc_disconnectStatement);
} else if ((tcStatementBlock.getStatementByIndex(j) instanceof StatementBlock_Statement) && !blockStatementBlockStatementWriter) {
StatementBlock_Statement tc_statementBlockStatement = (StatementBlock_Statement) tcStatementBlock.getStatementByIndex(j);
blockStatementBlockStatementWriter = false;
testCaseString.append("{\r\n");
blockWriter = true;
writeTestCaseFunction(tc_statementBlockStatement.getStatementBlock());
blockWriter = false;
testCaseString.append("}\r\n");
}
}
if (!blockWriter) {
testCaseString.append("}" + "\r\n");
}
return testCaseString.toString();
}
Aggregations