use of org.eclipse.titan.designer.AST.TTCN3.types.EnumerationItems in project titan.EclipsePlug-ins by eclipse.
the class Def_Type_Visit_Handler method visitDefTypeChildrenNodes.
public void visitDefTypeChildrenNodes(IVisitableNode node) {
if (node instanceof Def_Port) {
Def_Port port = (Def_Port) node;
componentPortNames.add(port.getIdentifier().toString());
}
if (node instanceof Def_Var) {
Def_Var var = (Def_Var) node;
componentVarNames.add(var.getIdentifier().toString());
if (var.getType(compilationCounter) instanceof Integer_Type) {
componentVarTypes.add("INTEGER");
}
}
if (waitForCompReference && (node instanceof Reference)) {
componentPortTypes.add(((Reference) node).getId().toString());
}
if (waitForSetOfFieldType) {
if (node instanceof Reference) {
setOfFieldType = node.toString();
myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
waitForSetOfFieldType = false;
} else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SetOf_Type)) {
Type type = (Type) node;
setOfFieldType = TypeMapper.map(type.getTypename());
myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
waitForSetOfFieldType = false;
}
}
if (waitForRecordOfFieldType) {
if (node instanceof Reference) {
recordOfFieldType = node.toString();
myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
waitForRecordOfFieldType = false;
} else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SequenceOf_Type)) {
Type type = (Type) node;
recordOfFieldType = TypeMapper.map(type.getTypename());
myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
waitForRecordOfFieldType = false;
}
}
if (node instanceof CompField) {
// component
CompField compFieldNode = (CompField) node;
if (compFieldNode.getType() instanceof Referenced_Type) {
compFieldTypes.add(((Referenced_Type) compFieldNode.getType()).getReference().getId().toString());
} else {
compFieldTypes.add(myASTVisitor.cutModuleNameFromBeginning(compFieldNode.getType().getTypename()));
}
compFieldNames.add(compFieldNode.getIdentifier().toString());
}
if (node instanceof Charstring_Value) {
// charstring
Charstring_Value singleValuedNode = (Charstring_Value) node;
charstringValue = singleValuedNode.getValue();
}
if (node instanceof Integer_Value) {
String value = ((Integer_Value) node).toString();
if (myASTVisitor.isNextIntegerNegative) {
value = "-" + value;
}
expressionValue.add("new INTEGER(\"" + value + "\")");
}
if (node instanceof Real_Value) {
String value = ((Real_Value) node).toString();
if (myASTVisitor.isNextIntegerNegative) {
value = "-" + value;
}
if (value.equals("-Infinity") || value.equals("Infinity")) {
value = "null";
}
expressionValue.add(value);
}
if (node instanceof Undefined_LowerIdentifier_Value) {
String value = ((Undefined_LowerIdentifier_Value) node).getIdentifier().toString();
if (myASTVisitor.isNextIntegerNegative) {
value = "-" + value;
}
expressionValue.add(value);
}
if (node instanceof EnumerationItems) {
for (int i = 0; i < ((EnumerationItems) node).getItems().size(); i++) {
enumItems.add(((EnumerationItems) node).getItems().get(i).getId().toString());
if (((EnumerationItems) node).getItems().get(i).getValue() != null) {
enumItemValues.add(((EnumerationItems) node).getItems().get(i).getValue().toString());
} else {
enumItemValues.add(null);
}
}
}
if (waitingForPortAttriburtes && (node instanceof Referenced_Type)) {
isPortTypeAReferencedType = true;
}
if (waitingForPortAttriburtes && (node instanceof PortTypeBody)) {
PortTypeBody body = (PortTypeBody) node;
int inCount = body.getInMessages().getNofTypes();
int outCount = body.getOutMessage().getNofTypes();
for (int i = 0; i < inCount; i++) {
inMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getInMessages().getTypeByIndex(i).getTypename()));
}
for (int i = 0; i < outCount; i++) {
outMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getOutMessage().getTypeByIndex(i).getTypename()));
}
int shorterListSize = inMessageName.size() <= outMessageName.size() ? inMessageName.size() : outMessageName.size();
// if inout delete from both lists and add to inout
for (int i = 0; i < inMessageName.size(); i++) {
for (int j = 0; j < outMessageName.size(); j++) {
if (inMessageName.get(i).equals(outMessageName.get(j))) {
inOutMessageName.add(inMessageName.get(i));
inMessageName.remove(i);
if (j == (outMessageName.size() - 1)) {
i--;
}
outMessageName.remove(j);
j--;
}
}
}
myASTVisitor.portNamePortTypeHashMap.put(currentPortName, body.getTestportType().toString());
portTypeList.add(body.getTestportType().toString());
}
}
Aggregations