Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 14EB7D78B for ; Wed, 5 Dec 2012 20:35:01 +0000 (UTC) Received: (qmail 71366 invoked by uid 500); 5 Dec 2012 20:35:01 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 71323 invoked by uid 500); 5 Dec 2012 20:35:01 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 71315 invoked by uid 99); 5 Dec 2012 20:35:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Dec 2012 20:35:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Dec 2012 20:34:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E9EB1238899C; Wed, 5 Dec 2012 20:34:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1417634 - in /cxf/branches/2.6.x-fixes/tools/corba/src: main/java/org/apache/cxf/tools/corba/processors/idl/ test/java/org/apache/cxf/tools/corba/ test/resources/idl/ Date: Wed, 05 Dec 2012 20:34:37 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121205203438.E9EB1238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Wed Dec 5 20:34:36 2012 New Revision: 1417634 URL: http://svn.apache.org/viewvc?rev=1417634&view=rev Log: Merged revisions 1417633 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1417633 | dkulp | 2012-12-05 15:31:56 -0500 (Wed, 05 Dec 2012) | 2 lines [CXF-3329] Fix issues with struct member name being same as struct/scope name ........ Added: cxf/branches/2.6.x-fixes/tools/corba/src/test/resources/idl/CXF3329.idl Modified: cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java cxf/branches/2.6.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Modified: cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java?rev=1417634&r1=1417633&r2=1417634&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java (original) +++ cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java Wed Dec 5 20:34:36 2012 @@ -55,16 +55,27 @@ public class ScopedNameVisitor extends V public void setExceptionMode(boolean value) { exceptionMode = value; } - public static boolean accept(Scope scope, Definition defn, XmlSchema schemaRef, AST node, WSDLASTVisitor wsdlVisitor) { + return accept(scope, defn, schemaRef, node, wsdlVisitor, false); + } + + // when accepting a "name" (for example, name of a field in a struct), we may need + // to relax the strict checking for forward decls and schema types to not count for + // exact parent scope names + public static boolean accept(Scope scope, + Definition defn, + XmlSchema schemaRef, + AST node, + WSDLASTVisitor wsdlVisitor, + boolean asName) { boolean result = false; if (PrimitiveTypesVisitor.accept(node)) { result = true; - } else if (isforwardDeclared(scope, node, wsdlVisitor)) { + } else if (isforwardDeclared(scope, node, wsdlVisitor, asName)) { result = true; } else if (ObjectReferenceVisitor.accept(scope, schemaRef, @@ -72,7 +83,7 @@ public class ScopedNameVisitor extends V node, wsdlVisitor)) { result = true; - } else if (findSchemaType(scope, defn, schemaRef, node, wsdlVisitor, null)) { + } else if (findSchemaType(scope, defn, schemaRef, node, wsdlVisitor, null, asName)) { result = true; } return result; @@ -154,6 +165,9 @@ public class ScopedNameVisitor extends V } protected static boolean isforwardDeclared(Scope scope, AST node, WSDLASTVisitor wsdlVisitor) { + return isforwardDeclared(scope, node, wsdlVisitor, false); + } + protected static boolean isforwardDeclared(Scope scope, AST node, WSDLASTVisitor wsdlVisitor, boolean b) { boolean isForward = false; Scope currentScope = scope; @@ -172,6 +186,9 @@ public class ScopedNameVisitor extends V if (scopedNames.getScope(scopedName) != null) { isForward = true; } + if (b && currentScope.equals(new Scope(currentScope.getParent(), node))) { + break; + } currentScope = currentScope.getParent(); } } @@ -255,13 +272,21 @@ public class ScopedNameVisitor extends V return result; } - protected static boolean findSchemaType(Scope scope, Definition defn, XmlSchema schemaRef, AST node, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) { + return findSchemaType(scope, defn, schemaRef, node, wsdlVisitor, holder, false); + } + protected static boolean findSchemaType(Scope scope, + Definition defn, + XmlSchema schemaRef, + AST node, + WSDLASTVisitor wsdlVisitor, + VisitorTypeHolder holder, + boolean checkExact) { boolean result = false; Scope currentScope = scope; @@ -289,6 +314,10 @@ public class ScopedNameVisitor extends V node, wsdlVisitor, holder); } + if (checkExact && currentScope.equals(new Scope(currentScope.getParent(), node))) { + return false; + } + currentScope = currentScope.getParent(); } } Modified: cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java?rev=1417634&r1=1417633&r2=1417634&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java (original) +++ cxf/branches/2.6.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java Wed Dec 5 20:34:36 2012 @@ -138,7 +138,7 @@ public class StructVisitor extends Visit // (hence the ScopedNameVisitor.accept() call). while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT - && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor)) { + && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor, true)) { XmlSchemaType memberSchemaType = schemaType; CorbaTypeImpl memberCorbaType = corbaType; Modified: cxf/branches/2.6.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java?rev=1417634&r1=1417633&r2=1417634&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java (original) +++ cxf/branches/2.6.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Wed Dec 5 20:34:36 2012 @@ -422,4 +422,17 @@ public class IDLToWSDLTest extends ToolT } fail("Did not find foo element"); } + public void testCXF3329() throws Exception { + File input = new File(getClass().getResource("/idl/CXF3329.idl").toURI()); + String[] args = new String[] { + "-o", output.toString(), + input.toString() + }; + IDLToWSDL.run(args); + File fs = new File(output, "CXF3329.wsdl"); + assertTrue(fs.getName() + " was not created.", fs.exists()); + Document doc = StaxUtils.read(new FileInputStream(fs)); + String s = StaxUtils.toString(doc.getDocumentElement()); + assertTrue(s.contains("name=\"myStruct\"")); + } } Added: cxf/branches/2.6.x-fixes/tools/corba/src/test/resources/idl/CXF3329.idl URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/corba/src/test/resources/idl/CXF3329.idl?rev=1417634&view=auto ============================================================================== --- cxf/branches/2.6.x-fixes/tools/corba/src/test/resources/idl/CXF3329.idl (added) +++ cxf/branches/2.6.x-fixes/tools/corba/src/test/resources/idl/CXF3329.idl Wed Dec 5 20:34:36 2012 @@ -0,0 +1,9 @@ +module myModule +{ + struct myStruct + { + long myStruct; + long otherField; + sequence parent; + }; +}; \ No newline at end of file