private void visitStructMembers( AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) { AST memberTypeNode = identifierNode.getNextSibling(); while (memberTypeNode != null) { AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode); XmlSchemaType schemaType = null; CorbaTypeImpl corbaType = null; Scope fqName = null; try { TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null); visitor.visit(memberTypeNode); schemaType = visitor.getSchemaType(); corbaType = visitor.getCorbaType(); fqName = visitor.getFullyQualifiedName(); } catch (Exception ex) { throw new RuntimeException(ex); } // Handle multiple struct member declarators // <declarators> :== <declarator> { "," <declarator> }* // // A multiple declarator must be an identifier (i.e. of type IDENT) // and cannot be a previous declared (or forward declared) type // (hence the ScopedNameVisitor.accept() call). while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor)) { XmlSchemaType memberSchemaType = schemaType; CorbaTypeImpl memberCorbaType = corbaType; // needed for anonymous arrays in structs if (ArrayVisitor.accept(memberNode)) { Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode)); ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName); arrayVisitor.setSchemaType(schemaType); arrayVisitor.setCorbaType(corbaType); arrayVisitor.visit(memberNode); memberSchemaType = arrayVisitor.getSchemaType(); memberCorbaType = arrayVisitor.getCorbaType(); fqName = arrayVisitor.getFullyQualifiedName(); } XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName); sequence.getItems().add(member); MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName); struct.getMember().add(memberType); memberNode = memberNode.getNextSibling(); } memberTypeNode = memberNode; } }
public void visitDeclaredStruct(AST identifierNode) { Scope structScope = new Scope(getScope(), identifierNode); // xmlschema:struct XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema); complexType.setName(mapper.mapToQName(structScope)); XmlSchemaSequence sequence = new XmlSchemaSequence(); complexType.setParticle(sequence); // corba:struct Struct struct = new Struct(); struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString())); struct.setType(complexType.getQName()); struct.setRepositoryID(structScope.toIDLRepositoryID()); boolean recursiveAdd = addRecursiveScopedName(identifierNode); // struct members visitStructMembers(identifierNode, struct, sequence, structScope); if (recursiveAdd) { removeRecursiveScopedName(identifierNode); } // add schemaType schema.getItems().add(complexType); schema.addType(complexType); // add corbaType typeMap.getStructOrExceptionOrUnion().add(struct); // REVISIT: are there assignment needed? setSchemaType(complexType); setCorbaType(struct); // Need to check if the struct was forward declared processForwardStructActions(structScope); // Once we've finished declaring the struct, we should make sure it has been removed from // the list of scopedNames so that we inidicate that is no longer simply forward declared. scopedNames.remove(structScope); }