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

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


  public ITypeBinding[] getTypeArguments() {
    if (this.typeArguments != null) {
      return this.typeArguments;
    }
    if (this.binding.isParameterizedTypeWithActualArguments()) {
      ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding;
      final org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] arguments = parameterizedTypeBinding.arguments;
      int argumentsLength = arguments.length;
      ITypeBinding[] newTypeArguments = new ITypeBinding[argumentsLength];
      for (int i = 0; i < argumentsLength; i++) {
        ITypeBinding typeBinding = this.resolver.getTypeBinding(arguments[i]);
View Full Code Here


    if (isClass() || isInterface() || isEnum()) {
      ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
      if (referenceBinding.isRawType()) {
        return !((RawTypeBinding) referenceBinding).genericType().isBinaryBinding();
      } else if (referenceBinding.isParameterizedType()) {
        ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) referenceBinding;
        org.eclipse.jdt.internal.compiler.lookup.TypeBinding erasure = parameterizedTypeBinding.erasure();
        if (erasure instanceof ReferenceBinding) {
          return !((ReferenceBinding) erasure).isBinaryBinding();
        }
        return false;
      } else {
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

      return;
    }
    classFile.visitedTypes.add(typeBinding);
    if (typeBinding.isParameterizedType()
        && ((typeBinding.tagBits & TagBits.ContainsNestedTypeReferences) != 0)) {
      ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) typeBinding;
      ReferenceBinding genericType = parameterizedTypeBinding.genericType();
      if ((genericType.tagBits & TagBits.ContainsNestedTypeReferences) != 0) {
        recordNestedType(classFile, genericType);
      }
      TypeBinding[] arguments = parameterizedTypeBinding.arguments;
      if (arguments != null) {
View Full Code Here

   */
  @Override
  public List<? extends TypeMirror> getTypeArguments() {
    ReferenceBinding binding = (ReferenceBinding)_binding;
    if (binding.isParameterizedType()) {
      ParameterizedTypeBinding ptb = (ParameterizedTypeBinding)_binding;
      TypeBinding[] arguments = ptb.arguments;
      int length = arguments == null ? 0 : arguments.length;
      if (length == 0) return Collections.emptyList();
      List<TypeMirror> args = new ArrayList<TypeMirror>(length);
      for (TypeBinding arg : arguments) {
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

  @Override
  public List<? extends TypeMirror> getTypeArguments() {
    ReferenceBinding binding = (ReferenceBinding)_binding;
    if (binding.isParameterizedType()) {
      ParameterizedTypeBinding ptb = (ParameterizedTypeBinding)_binding;
      TypeBinding[] arguments = ptb.arguments;
      int length = arguments == null ? 0 : arguments.length;
      if (length == 0) return Collections.emptyList();
      List<TypeMirror> args = new ArrayList<TypeMirror>(length);
      for (TypeBinding arg : arguments) {
View Full Code Here

  }

  private ReferenceBinding findGroundTargetType(BlockScope blockScope, ReferenceBinding targetType, boolean argumentTypesElided) {
    if (!targetType.isValidBinding())
      return null;
    ParameterizedTypeBinding withWildCards = InferenceContext18.parameterizedWithWildcard(targetType);
    if (withWildCards != null) {
      if (!argumentTypesElided)
        return new InferenceContext18(blockScope).inferFunctionalInterfaceParameterization(this, blockScope, withWildCards);
      else
        return findGroundTargetTypeForElidedLambda(blockScope, withWildCards);
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

        }
        TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
        return new String(typeVariableBinding.sourceName);

      case Binding.PARAMETERIZED_TYPE :
        ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding;
        buffer = new StringBuffer();
        buffer.append(parameterizedTypeBinding.sourceName());
        ITypeBinding[] tArguments = getTypeArguments();
        final int typeArgumentsLength = tArguments.length;
        if (typeArgumentsLength != 0) {
          buffer.append('<');
          for (int i = 0; i < typeArgumentsLength; i++) {
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.