Skip to main content
summaryrefslogtreecommitdiffstats
blob: 6c4410bd0757e414683c70b18a3658881269752e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package org.eclipse.wst.wsdl.ui.internal.visitor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.wst.wsdl.Message;
import org.eclipse.wst.wsdl.MessageReference;
import org.eclipse.wst.wsdl.Part;
import org.eclipse.wst.wsdl.ui.internal.adapters.visitor.W11XSDVisitorForFields;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDElementDeclaration;
import org.eclipse.xsd.XSDTypeDefinition;

public class WSDLVisitorForParameters
{
    public List concreteComponents = new ArrayList();
    public List thingsToListenTo = new ArrayList();

    public void visitMessageReference(MessageReference messageReference)
    {
      if (messageReference.getEMessage() != null)
      {
        visitMessage(messageReference.getEMessage());
      }
    }
    
    public void visitMessage(Message message)
    {
      // for now we assume that the first part is the only one that
      // should be used to deduce the parameters
      // TODO (cs) we need to revist this, multiple parts need to be considered
      //
        if (message != null) {
            thingsToListenTo.add(message);
            for (Iterator i = message.getEParts().iterator(); i.hasNext(); )
            { 
              visitPart((Part)i.next());
            }
        }
    }

    void visitPart(Part part)
    {
      thingsToListenTo.add(part);      
      if (part.getElementDeclaration() != null)
      {
        visitXSDElementDeclaration(part.getElementDeclaration());
      }
      else
      // if (part.getTypeDefinition() instanceof XSDSimpleTypeDefinition)
      {
        concreteComponents.add(part);
      }
    }

    void visitXSDElementDeclaration(XSDElementDeclaration ed)
    {
      XSDTypeDefinition td = ed.getTypeDefinition();
      if (td != null)
      {  
        if (td.getName() != null)
        {
          concreteComponents.add(ed);
        }
        else if (td instanceof XSDComplexTypeDefinition)
        {
          // we're dealing with an anonymous locally defined type
          // se we need to visit it's children
          thingsToListenTo.add(ed);
          visitXSDComplextTypeDefinition((XSDComplexTypeDefinition) td);
        }
      }
    }

    void visitXSDComplextTypeDefinition(XSDComplexTypeDefinition td)
    {
      // TODO (cs) revisit to see if it makes sense for the WSDL editor to redisplay
      // the 'Fields' (in XSD editor lingo) as paramters
      // perhaps the WSDL Editor should simply reuse the XSD Editor's
      // ComplexType edit part when displaying these sections?
      W11XSDVisitorForFields fieldVisitor = new W11XSDVisitorForFields();
      fieldVisitor.visitComplexTypeDefinition(td);
      concreteComponents.addAll(fieldVisitor.getConcreteComponentList());
      thingsToListenTo.addAll(fieldVisitor.getThingsWeNeedToListenTo());
    }
  }

Back to the top