public Binding reduceRecursive() {
      final BindingImpl binding = (BindingImpl) create();

      for (final PsiTypeVariable var : myBoundVariables) {
        final int index = var.getIndex();
        final PsiType type = myBindings.get(index);

        if (type != null) {
          class Verifier extends PsiExtendedTypeVisitor<Void> {
            boolean myFlag = false;

            @Override
            public Void visitTypeVariable(final PsiTypeVariable var) {
              if (var.getIndex() == index) {
                myFlag = true;
              }

              return null;
            }
          }

          final Verifier verifier = new Verifier();

          type.accept(verifier);

          if (verifier.myFlag) {
            myBindings.put(index, Bottom.BOTTOM);
            binding.myBindings.put(index, Bottom.BOTTOM);
          } else {
            binding.myBindings.put(index, type);
          }
        } else {
          binding.myBindings.put(index, type);
        }
      }

      for (final PsiTypeVariable var : myBoundVariables) {
        final int index = var.getIndex();
        final PsiType type = myBindings.get(index);

        if (type != null) {
          myBindings.put(index, binding.apply(type));
        }
      }

      return this;
    }
Example #2
0
  @SuppressWarnings("unchecked")
  public DescriptionImpl(
      final URI baseURI,
      final TDefinitions definition,
      final NamespaceMapperImpl namespaceMapper,
      final SchemaLocatorImpl schemaLocator,
      final Map<FeatureConstants, Object> features,
      Map<URI, AbsItfDescription> descriptionImports,
      Map<URI, AbsItfSchema> schemaImports,
      WSDLReaderImpl reader)
      throws WSDLException, WSDLImportException {

    super(baseURI, definition, namespaceMapper, schemaLocator, features);

    // get the documentation
    this.documentation =
        new org.ow2.easywsdl.wsdl.impl.wsdl11.DocumentationImpl(
            this.model.getDocumentation(), this);

    // get the reader
    if (reader == null) {
      this.reader = new WSDLReaderImpl();
    } else {
      this.reader = reader;
    }

    boolean find = false;
    for (final TDocumented part : this.model.getAnyTopLevelOptionalElement()) {
      // get imports
      if (part instanceof TImport) {
        final Import impt =
            new org.ow2.easywsdl.wsdl.impl.wsdl11.ImportImpl(
                (TImport) part,
                this,
                descriptionImports,
                schemaImports,
                this.documentURI,
                this.reader);
        this.imports.add(impt);
        find = true;
      }
    }
    if (!find) {
      Iterator<Object> it = this.model.getAny().iterator();
      while (it.hasNext()) {
        Object part = it.next();

        // get import
        if (part instanceof Element) {
          if ((((Element) part).getLocalName().equals("import"))
              && verifWSDL11Ns(((Element) part).getNamespaceURI())) {
            TImport tImpt =
                ImportImpl.replaceDOMElementByTImport(this, (Element) part, this.reader);
            it = this.model.getAny().iterator();
            final Import impt =
                new org.ow2.easywsdl.wsdl.impl.wsdl11.ImportImpl(
                    (TImport) tImpt,
                    this,
                    descriptionImports,
                    schemaImports,
                    this.documentURI,
                    this.reader);
            this.imports.add(impt);
          }
        }
      }
    }

    this.addImportElementsInAllList();
    this.addIncludeElementsInAllList();

    find = false;
    for (final TDocumented part : this.model.getAnyTopLevelOptionalElement()) {
      // get types
      if (part instanceof TTypes) {
        this.types =
            new org.ow2.easywsdl.wsdl.impl.wsdl11.TypesImpl(
                (TTypes) part, this, schemaImports, this.reader);
        find = true;
        break;
      }
    }
    if (!find) {
      Iterator<Object> it = this.model.getAny().iterator();
      while (it.hasNext()) {
        Object part = it.next();

        // get import
        if (part instanceof Element) {

          if ((((Element) part).getLocalName().equals("types"))
              && verifWSDL11Ns(((Element) part).getNamespaceURI())) {
            if (reader == null) {
              reader = new WSDLReaderImpl();
            }
            TTypes tTypes = TypesImpl.replaceDOMElementByTTypes(this, (Element) part, reader);
            it = this.model.getAny().iterator();
            this.types =
                new org.ow2.easywsdl.wsdl.impl.wsdl11.TypesImpl(
                    (TTypes) tTypes, this, schemaImports, this.reader);
          }
        }
      }
    }

    this.messages = this.findAllMessages(this);

    find = false;
    for (final TDocumented part : this.model.getAnyTopLevelOptionalElement()) {
      // get interfaces
      if (part instanceof TPortType) {
        final InterfaceType itf =
            new org.ow2.easywsdl.wsdl.impl.wsdl11.InterfaceTypeImpl((TPortType) part, this);
        this.interfaces.add(itf);
        find = true;
      }
    }
    if (!find) {
      Iterator<Object> it = this.model.getAny().iterator();
      while (it.hasNext()) {
        Object part = it.next();

        // get import
        if (part instanceof Element) {
          if ((((Element) part).getLocalName().equals("portType"))
              && verifWSDL11Ns(((Element) part).getNamespaceURI())) {
            if (reader == null) {
              reader = new WSDLReaderImpl();
            }
            TPortType tPortType =
                InterfaceTypeImpl.replaceDOMElementByTPortType(this, (Element) part, reader);
            it = this.model.getAny().iterator();
            final InterfaceType itf =
                new org.ow2.easywsdl.wsdl.impl.wsdl11.InterfaceTypeImpl(
                    (TPortType) tPortType, this);
            this.interfaces.add(itf);
          }
        }
      }
    }

    find = false;
    for (final TDocumented part : this.model.getAnyTopLevelOptionalElement()) {
      // get bindings
      if (part instanceof TBinding) {
        final Binding b = new org.ow2.easywsdl.wsdl.impl.wsdl11.BindingImpl((TBinding) part, this);
        this.bindings.add(b);
        find = true;
      }
    }
    if (!find) {
      Iterator<Object> it = this.model.getAny().iterator();
      while (it.hasNext()) {
        Object part = it.next();

        // get import
        if (part instanceof Element) {
          if ((((Element) part).getLocalName().equals("binding"))
              && verifWSDL11Ns(((Element) part).getNamespaceURI())) {
            if (reader == null) {
              reader = new WSDLReaderImpl();
            }
            TBinding tBinding =
                BindingImpl.replaceDOMElementByTBinding(this, (Element) part, reader);
            it = this.model.getAny().iterator();
            final Binding b =
                new org.ow2.easywsdl.wsdl.impl.wsdl11.BindingImpl((TBinding) tBinding, this);
            this.bindings.add(b);
          }
        }
      }
    }

    find = false;
    for (final TDocumented part : this.model.getAnyTopLevelOptionalElement()) {
      // get services
      if (part instanceof TService) {
        final Service s = new org.ow2.easywsdl.wsdl.impl.wsdl11.ServiceImpl((TService) part, this);
        this.services.add(s);
        find = true;
      }
    }
    if (!find) {
      Iterator<Object> it = this.model.getAny().iterator();
      while (it.hasNext()) {
        Object part = it.next();

        // get import
        if (part instanceof Element) {
          if ((((Element) part).getLocalName().equals("service"))
              && verifWSDL11Ns(((Element) part).getNamespaceURI())) {
            if (reader == null) {
              reader = new WSDLReaderImpl();
            }
            TService tService =
                ServiceImpl.replaceDOMElementByTService(this, (Element) part, reader);
            it = this.model.getAny().iterator();
            final Service s =
                new org.ow2.easywsdl.wsdl.impl.wsdl11.ServiceImpl((TService) tService, this);
            this.services.add(s);
          }
        }
      }
    }
  }
    public Binding compose(final Binding b) {
      LOG.assertTrue(b instanceof BindingImpl);

      final BindingImpl b1 = this;
      final BindingImpl b2 = (BindingImpl) b;

      final BindingImpl b3 = new BindingImpl();

      for (PsiTypeVariable boundVariable : myBoundVariables) {
        final int i = boundVariable.getIndex();

        final PsiType b1i = b1.myBindings.get(i);
        final PsiType b2i = b2.myBindings.get(i);

        final int flag = (b1i == null ? 0 : 1) + (b2i == null ? 0 : 2);

        switch (flag) {
          case 0:
            break;

          case 1: /* b1(i)\b2(i) */
            {
              final PsiType type = b2.apply(b1i);

              if (type == null) {
                return null;
              }

              b3.myBindings.put(i, type);
              b3.myCyclic = type instanceof PsiTypeVariable;
            }
            break;

          case 2: /* b2(i)\b1(i) */
            {
              final PsiType type = b1.apply(b2i);

              if (type == null) {
                return null;
              }

              b3.myBindings.put(i, type);
              b3.myCyclic = type instanceof PsiTypeVariable;
            }
            break;

          case 3: /* b2(i) \cap b1(i) */
            {
              final Binding common = rise(b1i, b2i, null);

              if (common == null) {
                return null;
              }

              final PsiType type = common.apply(b1i);
              if (type == null) {
                return null;
              }

              if (type == null) {
                return null;
              }

              b3.myBindings.put(i, type);
              b3.myCyclic = type instanceof PsiTypeVariable;
            }
        }
      }

      return b3;
    }