use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase 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.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.
the class ActivateDereferedExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), chain);
chain.release();
if (last.getValuetype() == Value_type.ALTSTEP_REFERENCE_VALUE) {
// the referred testcase is known
final Def_Testcase testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
expression.expression.append(MessageFormat.format("{0}(", testcase.getGenNameFromScope(aData, expression.expression, myScope, "activate_")));
} else {
// the referred testcase is unknown
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".activate(");
}
actualParameters.generateCodeAlias(aData, expression);
expression.expression.append(')');
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.
the class Scope method checkRunsOnScope.
/**
* Checks that operations that can only be executed in definitions that
* have a runs on scope, are really executed in such a definition. And
* that the required runs on component is compatible with the runs on
* component of the definition.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param assignment
* the assignment to check (used or referred to by the
* statement).
* @param errorLocation
* the location to report the error to.
* @param operation
* the name of the operation.
*/
public void checkRunsOnScope(final CompilationTimeStamp timestamp, final Assignment assignment, final ILocateableNode errorLocation, final String operation) {
Component_Type referencedComponent;
switch(assignment.getAssignmentType()) {
case A_ALTSTEP:
referencedComponent = ((Def_Altstep) assignment).getRunsOnType(timestamp);
break;
case A_FUNCTION:
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
referencedComponent = ((Def_Function) assignment).getRunsOnType(timestamp);
break;
case A_TESTCASE:
referencedComponent = ((Def_Testcase) assignment).getRunsOnType(timestamp);
break;
default:
return;
}
if (referencedComponent == null) {
return;
}
final RunsOnScope runsOnScope = getScopeRunsOn();
if (runsOnScope == null) {
errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONREQUIRED, operation, assignment.getDescription(), referencedComponent.getTypename()));
} else {
final Component_Type localType = runsOnScope.getComponentType();
if (!referencedComponent.isCompatible(timestamp, localType, null, null, null)) {
errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONMISSMATCH, localType.getTypename(), operation, assignment.getDescription(), referencedComponent.getTypename()));
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.
the class Shorthand method check.
protected void check(final Statement s, final Problems problems) {
if (s == null) {
return;
}
// shorthand statements are ignored inside alt statements
INamedNode curr = s;
while (curr != null) {
if (curr instanceof Alt_Statement || curr instanceof Call_Statement) {
return;
}
curr = curr.getNameParent();
}
final StatementBlock sb = s.getMyStatementBlock();
if (sb == null) {
return;
}
final Definition d = sb.getMyDefinition();
if (d == null) {
return;
}
// shorthand statements are marked in functions, test cases and altsteps that have a 'runs on' clause
if (d instanceof Def_Function && ((Def_Function) d).getRunsOnType(timestamp) != null) {
problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
return;
}
if (d instanceof Def_Altstep || d instanceof Def_Testcase) {
problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method analyzeFunction.
/**
* Analyze a function or testcase
*/
private List<Edit> analyzeFunction(final Definition def) {
if (!(def instanceof Def_Function || def instanceof Def_Testcase)) {
ErrorReporter.logError("ChangeCreator.analyzeFunction(): def must be a Def_Function or a Def_Testcase! def type: " + def.getClass());
return null;
}
final FunctionAnalyzer vis = new FunctionAnalyzer();
def.accept(vis);
final Environment env = vis.getResult();
final List<Edit> eds = env.refactor();
return eds;
}
Aggregations