Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding


      maybeDispatch(expression, ((ArrayBinding) binding).leafComponentType);
    } else if (binding instanceof BinaryTypeBinding) {
      onBinaryTypeRef((BinaryTypeBinding) binding, cud, expression);
    } else if (binding instanceof ParameterizedTypeBinding) {
      // Make sure that we depend on the generic version of the class.
      ParameterizedTypeBinding ptBinding = (ParameterizedTypeBinding) binding;
      maybeDispatch(expression, ptBinding.genericType());
    } else if (binding instanceof RawTypeBinding) {
      // Make sure that we depend on the generic version of the class.
      RawTypeBinding rawTypeBinding = (RawTypeBinding) binding;
      maybeDispatch(expression, rawTypeBinding.genericType());
    } else {
View Full Code Here


  public JNode get(Binding binding) {
    if (binding instanceof TypeVariableBinding) {
      TypeVariableBinding tvb = (TypeVariableBinding) binding;
      return get(tvb.erasure());
    } else if (binding instanceof ParameterizedTypeBinding) {
      ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;
      return get(ptb.erasure());
    } else if (binding instanceof ParameterizedMethodBinding) {
      ParameterizedMethodBinding pmb = (ParameterizedMethodBinding) binding;
      return get(pmb.original());
    } else if (binding instanceof ParameterizedFieldBinding) {
      ParameterizedFieldBinding pfb = (ParameterizedFieldBinding) binding;
View Full Code Here

      }
    }

    // Check for parameterized.
    if (binding instanceof ParameterizedTypeBinding) {
      ParameterizedTypeBinding ptBinding = (ParameterizedTypeBinding) binding;

      /*
       * NOTE: it is possible for ParameterizedTypeBinding.arguments to be null.
       * This can happen if a generic class has a non-static, non-generic, inner
       * class that references a TypeParameter from its enclosing generic type.
       * You would think that typeVariables() would do the right thing but it
       * does not.
       */
      TypeBinding[] arguments = ptBinding.arguments;
      int nArguments = arguments != null ? arguments.length : 0;
      JClassType[] typeArguments = new JClassType[nArguments];
      boolean failed = false;
      for (int i = 0; i < typeArguments.length; ++i) {
        typeArguments[i] = (JClassType) resolveType(logger, arguments[i]);
        if (typeArguments[i] == null) {
          failed = true;
        }
      }

      JClassType enclosingType = null;
      if (ptBinding.enclosingType() != null) {
        enclosingType = (JClassType) resolveType(logger,
            ptBinding.enclosingType());
        if (enclosingType == null) {
          failed = true;
        }
      }

      /*
       * NOTE: In the case where a generic type has a nested, non-static,
       * non-generic type. The type for the binding will not be a generic type.
       */
      JType resolveType = resolveType(logger, ptBinding.genericType());
      if (resolveType == null) {
        failed = true;
      }

      if (!failed) {
View Full Code Here

    TypeBinding[] typeBindings = parameterizedMethodBinding.isRaw ? null : parameterizedMethodBinding.typeArguments;
    updateMatch(typeBindings, locator, this.pattern.constructorArguments, this.pattern.hasConstructorParameters());

    // Update match regarding declaring class type arguments
    if (constructorBinding.declaringClass.isParameterizedType() || constructorBinding.declaringClass.isRawType()) {
      ParameterizedTypeBinding parameterizedBinding = (ParameterizedTypeBinding)constructorBinding.declaringClass;
      if (!this.pattern.hasTypeArguments() && this.pattern.hasConstructorArguments() || parameterizedBinding.isParameterizedWithOwnVariables()) {
        // special case for constructor pattern which defines arguments but no type
        // in this case, we only use refined accuracy for constructor
      } else if (this.pattern.hasTypeArguments() && !this.pattern.hasConstructorArguments()) {
        // special case for constructor pattern which defines no constructor arguments but has type ones
        // in this case, we do not use refined accuracy
        updateMatch(parameterizedBinding, this.pattern.getTypeArguments(), this.pattern.hasTypeParameters(), 0, locator);
      } else {
        updateMatch(parameterizedBinding, this.pattern.getTypeArguments(), this.pattern.hasTypeParameters(), 0, locator);
      }
    } else if (this.pattern.hasTypeArguments()) {
      this.match.setRule(SearchPattern.R_ERASURE_MATCH);
    }

    // Update match regarding constructor parameters
    // TODO ? (frederic)
  } else if (constructorBinding instanceof ParameterizedMethodBinding) {
    // Update match regarding declaring class type arguments
    if (constructorBinding.declaringClass.isParameterizedType() || constructorBinding.declaringClass.isRawType()) {
      ParameterizedTypeBinding parameterizedBinding = (ParameterizedTypeBinding)constructorBinding.declaringClass;
      if (!this.pattern.hasTypeArguments() && this.pattern.hasConstructorArguments()) {
        // special case for constructor pattern which defines arguments but no type
        updateMatch(parameterizedBinding, new char[][][] {this.pattern.constructorArguments}, this.pattern.hasTypeParameters(), 0, locator);
      } else if (!parameterizedBinding.isParameterizedWithOwnVariables()) {
        updateMatch(parameterizedBinding, this.pattern.getTypeArguments(), this.pattern.hasTypeParameters(), 0, locator);
      }
    } else if (this.pattern.hasTypeArguments()) {
      this.match.setRule(SearchPattern.R_ERASURE_MATCH);
    }
View Full Code Here

                this.bits |= ASTNode.UnsafeCast;
                return true;
              }
              // [JLS 5.5] S has no subtype X != T, such that |X| == |T|
              // if I2<T,U> extends I1<T>, then cast from I1<T> to I2<T,U> is unchecked
              ParameterizedTypeBinding paramCastType = (ParameterizedTypeBinding) castType;
              ParameterizedTypeBinding paramMatch = (ParameterizedTypeBinding) match;
              // easy case if less parameters on match
              TypeBinding[] castArguments = paramCastType.arguments;
              int length = castArguments == null ? 0 : castArguments.length;
              if (paramMatch.arguments == null || length > paramMatch.arguments.length) {
                this.bits |= ASTNode.UnsafeCast;
              } else if ((paramCastType.tagBits & (TagBits.HasDirectWildcard|TagBits.HasTypeVariable)) != 0) {
                // verify alternate cast type, substituting different type arguments
                nextAlternateArgument: for (int i = 0; i < length; i++) {
                  switch (castArguments[i].kind()) {
                    case Binding.WILDCARD_TYPE :
                    case Binding.TYPE_PARAMETER :
                      break; // check substituting with other
                    default:
                      continue nextAlternateArgument; // no alternative possible
                  }
                  TypeBinding[] alternateArguments;
                  // need to clone for each iteration to avoid env paramtype cache interference
                  System.arraycopy(paramCastType.arguments, 0, alternateArguments = new TypeBinding[length], 0, length);
                  alternateArguments[i] = scope.getJavaLangObject();
                  LookupEnvironment environment = scope.environment();
                  ParameterizedTypeBinding alternateCastType = environment.createParameterizedType((ReferenceBinding)castType.erasure(), alternateArguments, castType.enclosingType());
                  if (alternateCastType.findSuperTypeOriginatingFrom(expressionType) == match) {
                    this.bits |= ASTNode.UnsafeCast;
                    break;
                  }
                }
              }
View Full Code Here

      CompilationUnitScope from = findUnitScope(referencedFrom);
      onBinaryTypeRef((BinaryTypeBinding) binding, from.referenceContext,
          expression);
    } else if (binding instanceof ParameterizedTypeBinding) {
      // Make sure that we depend on the generic version of the class.
      ParameterizedTypeBinding ptBinding = (ParameterizedTypeBinding) binding;
      maybeDispatch(referencedFrom, expression, ptBinding.genericType());
    } else if (binding instanceof RawTypeBinding) {
      // Make sure that we depend on the generic version of the class.
      RawTypeBinding rawTypeBinding = (RawTypeBinding) binding;
      maybeDispatch(referencedFrom, expression, rawTypeBinding.genericType());
    } else {
View Full Code Here

      }
    }

    // Check for parameterized.
    if (binding instanceof ParameterizedTypeBinding) {
      ParameterizedTypeBinding ptBinding = (ParameterizedTypeBinding) binding;

      /*
       * NOTE: it is possible for ParameterizedTypeBinding.arguments to be null.
       * This can happen if a generic class has a non-static, non-generic, inner
       * class that references a TypeParameter from its enclosing generic type.
       * You would think that typeVariables() would do the right thing but it
       * does not.
       */
      TypeBinding[] arguments = ptBinding.arguments;
      int nArguments = arguments != null ? arguments.length : 0;
      JClassType[] typeArguments = new JClassType[nArguments];
      boolean failed = false;
      for (int i = 0; i < typeArguments.length; ++i) {
        typeArguments[i] = (JClassType) resolveType(logger, arguments[i]);
        if (typeArguments[i] == null) {
          failed = true;
        }
      }

      JClassType enclosingType = null;
      if (ptBinding.enclosingType() != null) {
        enclosingType = (JClassType) resolveType(logger,
            ptBinding.enclosingType());
        if (enclosingType == null) {
          failed = true;
        }
      }

      /*
       * NOTE: In the case where a generic type has a nested, non-static,
       * non-generic type. The type for the binding will not be a generic type.
       */
      JType resolveType = resolveType(logger, ptBinding.genericType());
      if (resolveType == null) {
        failed = true;
      }

      if (!failed) {
View Full Code Here

  public JNode get(Binding binding) {
    if (binding instanceof TypeVariableBinding) {
      TypeVariableBinding tvb = (TypeVariableBinding) binding;
      return get(tvb.erasure());
    } else if (binding instanceof ParameterizedTypeBinding) {
      ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;
      return get(ptb.erasure());
    } else if (binding instanceof ParameterizedMethodBinding) {
      ParameterizedMethodBinding pmb = (ParameterizedMethodBinding) binding;
      return get(pmb.original());
    } else if (binding instanceof ParameterizedFieldBinding) {
      ParameterizedFieldBinding pfb = (ParameterizedFieldBinding) binding;
View Full Code Here

      maybeDispatch(expression, ((ArrayBinding) binding).leafComponentType);
    } else if (binding instanceof BinaryTypeBinding) {
      onBinaryTypeRef((BinaryTypeBinding) binding, cud, expression);
    } else if (binding instanceof ParameterizedTypeBinding) {
      // Make sure that we depend on the generic version of the class.
      ParameterizedTypeBinding ptBinding = (ParameterizedTypeBinding) binding;
      maybeDispatch(expression, ptBinding.genericType());
    } else if (binding instanceof RawTypeBinding) {
      // Make sure that we depend on the generic version of the class.
      RawTypeBinding rawTypeBinding = (RawTypeBinding) binding;
      maybeDispatch(expression, rawTypeBinding.genericType());
    } else {
View Full Code Here

      }
    }

    // Check for parameterized.
    if (binding instanceof ParameterizedTypeBinding) {
      ParameterizedTypeBinding ptBinding = (ParameterizedTypeBinding) binding;

      /*
       * NOTE: it is possible for ParameterizedTypeBinding.arguments to be null.
       * This can happen if a generic class has a non-static, non-generic, inner
       * class that references a TypeParameter from its enclosing generic type.
       * You would think that typeVariables() would do the right thing but it
       * does not.
       */
      TypeBinding[] arguments = ptBinding.arguments;
      int nArguments = arguments != null ? arguments.length : 0;
      JClassType[] typeArguments = new JClassType[nArguments];
      boolean failed = false;
      for (int i = 0; i < typeArguments.length; ++i) {
        typeArguments[i] = (JClassType) resolveType(logger, arguments[i]);
        if (typeArguments[i] == null) {
          failed = true;
        }
      }

      JClassType enclosingType = null;
      if (ptBinding.enclosingType() != null) {
        enclosingType = (JClassType) resolveType(logger,
            ptBinding.enclosingType());
        if (enclosingType == null) {
          failed = true;
        }
      }

      /*
       * NOTE: In the case where a generic type has a nested, non-static,
       * non-generic type. The type for the binding will not be a generic type.
       */
      JType resolveType = resolveType(logger, ptBinding.genericType());
      if (resolveType == null) {
        failed = true;
      }

      if (!failed) {
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.