cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1417633 - in /cxf/trunk/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:31:58 GMT
Author: dkulp
Date: Wed Dec  5 20:31:56 2012
New Revision: 1417633

URL: http://svn.apache.org/viewvc?rev=1417633&view=rev
Log:
[CXF-3329] Fix issues with struct member name being same as struct/scope name

Added:
    cxf/trunk/tools/corba/src/test/resources/idl/CXF3329.idl
Modified:
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
    cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java?rev=1417633&r1=1417632&r2=1417633&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
Wed Dec  5 20:31:56 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/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java?rev=1417633&r1=1417632&r2=1417633&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
Wed Dec  5 20:31:56 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/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java?rev=1417633&r1=1417632&r2=1417633&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java (original)
+++ cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Wed
Dec  5 20:31:56 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/trunk/tools/corba/src/test/resources/idl/CXF3329.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/CXF3329.idl?rev=1417633&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/CXF3329.idl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/CXF3329.idl Wed Dec  5 20:31:56 2012
@@ -0,0 +1,9 @@
+module myModule
+{
+	struct myStruct
+	{
+		long myStruct;
+		long otherField;
+		sequence<myStruct> parent;
+	};
+};
\ No newline at end of file



Mime
View raw message