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

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding


  if (this.binding instanceof ParameterizedFieldBinding) {
      ParameterizedFieldBinding parameterizedField = (ParameterizedFieldBinding) this.binding;
      this.codegenBinding = parameterizedField.originalField;
      // extra cast needed if field type was type variable
      if (this.codegenBinding.type.isTypeVariable()) {
          TypeVariableBinding variableReturnType = (TypeVariableBinding) this.codegenBinding.type;
          if (variableReturnType.firstBound != parameterizedField.type) { // no need for extra cast if same as first bound anyway
          this.genericCast = parameterizedField.type.erasure();
          }
      }
  } else {
View Full Code Here


    }
    String variableName = new String(name);
    int aliased = (aliases == null ? -1 : aliases.indexOf(variableName));
    if (aliased != -1) {
      if (aliased > sourceType.typeVariables.length || sourceType.typeVariables.length == 0) {
        TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(), null, 0);
        tvb.superclass = getJavaLangObject();
        tvb.fPackage = new PackageBinding(environment());
        return tvb;
        // error is going to be reported by someone else!
      }
      TypeVariableBinding tvb = sourceType.typeVariables()[aliased];
      tvb.fPackage = sourceType.fPackage;
      if (usedAliases == null)
        usedAliases = new HashMap<TypeVariableBinding, String>();
      usedAliases.put(tvb, variableName);
      return tvb;
    } else {
      TypeVariableBinding variableBinding = sourceType.getTypeVariable(name);
      if (variableBinding == null) { // GENERICITDFIX
        // Inside generic aspect, might want the type var attached to us
        variableBinding = parent.findTypeVariable(name, ((ClassScope) parent).referenceContext.binding);
      }
      return variableBinding;
View Full Code Here

  }

  public static String getName(TypeBinding binding) {
    if (binding instanceof TypeVariableBinding) {
      // The first bound may be null - so default to object?
      TypeVariableBinding tvb = (TypeVariableBinding) binding;
      if (tvb.firstBound != null) {
        return getName(tvb.firstBound);
      } else {
        return getName(tvb.superclass);
      }
View Full Code Here

    if (binding == null || binding.qualifiedSourceName() == null) {
      return ResolvedType.MISSING;
    }
    // first piece of generics support!
    if (binding instanceof TypeVariableBinding) {
      TypeVariableBinding tb = (TypeVariableBinding) binding;
      UnresolvedTypeVariableReferenceType utvrt = (UnresolvedTypeVariableReferenceType) fromTypeVariableBinding(tb);
      return utvrt;
    }

    // handle arrays since the component type may need special treatment too...
    if (binding instanceof ArrayBinding) {
      ArrayBinding aBinding = (ArrayBinding) binding;
      UnresolvedType componentType = fromBinding(aBinding.leafComponentType);
      return UnresolvedType.makeArray(componentType, aBinding.dimensions);
    }

    if (binding instanceof WildcardBinding) {
      WildcardBinding eWB = (WildcardBinding) binding;
      // Repair the bound
      // e.g. If the bound for the wildcard is a typevariable, e.g. '? extends E' then
      // the type variable in the unresolvedtype will be correct only in name. In that
      // case let's set it correctly based on the one in the eclipse WildcardBinding
      UnresolvedType theBound = null;
      if (eWB.bound instanceof TypeVariableBinding) {
        theBound = fromTypeVariableBinding((TypeVariableBinding) eWB.bound);
      } else {
        theBound = fromBinding(eWB.bound);
      }
      // if (eWB.boundKind == WildCard.SUPER) {
      //
      // }
      WildcardedUnresolvedType theType = (WildcardedUnresolvedType) TypeFactory.createTypeFromSignature(CharOperation
          .charToString(eWB.genericTypeSignature()));
      // if (theType.isGenericWildcard() && theType.isSuper()) theType.setLowerBound(theBound);
      // if (theType.isGenericWildcard() && theType.isExtends()) theType.setUpperBound(theBound);
      return theType;
    }

    if (binding instanceof ParameterizedTypeBinding) {
      if (binding instanceof RawTypeBinding) {
        // special case where no parameters are specified!
        return UnresolvedType.forRawTypeName(getName(binding));
      }
      ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;

      UnresolvedType[] arguments = null;

      if (ptb.arguments != null) { // null can mean this is an inner type of a Parameterized Type with no bounds of its own
        // (pr100227)
        arguments = new UnresolvedType[ptb.arguments.length];
        for (int i = 0; i < arguments.length; i++) {
          arguments[i] = fromBinding(ptb.arguments[i]);
        }
      }

      String baseTypeSignature = null;

      ResolvedType baseType = getWorld().resolve(UnresolvedType.forName(getName(binding)), true);
      if (!baseType.isMissing()) {
        // can legitimately be missing if a bound refers to a type we haven't added to the world yet...
        // pr168044 - sometimes (whilst resolving types) we are working with 'half finished' types and so (for example) the
        // underlying generic type for a raw type hasnt been set yet
        // if (!baseType.isGenericType() && arguments!=null) baseType = baseType.getGenericType();
        baseTypeSignature = baseType.getErasureSignature();
      } else {
        baseTypeSignature = UnresolvedType.forName(getName(binding)).getSignature();
      }

      // Create an unresolved parameterized type. We can't create a resolved one as the
      // act of resolution here may cause recursion problems since the parameters may
      // be type variables that we haven't fixed up yet.
      if (arguments == null) {
        arguments = new UnresolvedType[0];
      }
      // StringBuffer parameterizedSig = new StringBuffer();
      // parameterizedSig.append(ResolvedType.PARAMETERIZED_TYPE_IDENTIFIER);
      //
      // // String parameterizedSig = new
      // StringBuffer().append(ResolvedType.PARAMETERIZED_TYPE_IDENTIFIER).append(CharOperation
      // .charToString(binding.genericTypeSignature()).substring(1)).toString();
      // return TypeFactory.createUnresolvedParameterizedType(parameterizedSig,baseTypeSignature,arguments);
      return TypeFactory.createUnresolvedParameterizedType(baseTypeSignature, arguments);
    }

    // Convert the source type binding for a generic type into a generic UnresolvedType
    // notice we can easily determine the type variables from the eclipse object
    // and we can recover the generic signature from it too - so we pass those
    // to the forGenericType() method.
    if (binding.isGenericType() && !binding.isParameterizedType() && !binding.isRawType()) {
      TypeVariableBinding[] tvbs = binding.typeVariables();
      TypeVariable[] tVars = new TypeVariable[tvbs.length];
      for (int i = 0; i < tvbs.length; i++) {
        TypeVariableBinding eclipseV = tvbs[i];
        tVars[i] = ((TypeVariableReference) fromTypeVariableBinding(eclipseV)).getTypeVariable();
      }
      // TODO asc generics - temporary guard....
      if (!(binding instanceof SourceTypeBinding)) {
        throw new RuntimeException("Cant get the generic sig for " + binding.debugName());
View Full Code Here

  // }
  // return tvBinding;
  // }

  private TypeVariableBinding makeTypeVariableBindingFromAJTypeVariable(TypeVariable tv) {
    TypeVariableBinding tvBinding = (TypeVariableBinding) typeVariableToTypeBinding.get(tv.getName());
    if (currentType != null) {
      TypeVariableBinding tvb = currentType.getTypeVariable(tv.getName().toCharArray());
      if (tvb != null) {
        return tvb;
      }
    }
    if (tvBinding == null) {
      Binding declaringElement = null;
      // this will cause an infinite loop or NPE... not required yet luckily.
      // if (tVar.getDeclaringElement() instanceof Member) {
      // declaringElement = makeMethodBinding((ResolvedMember)tVar.getDeclaringElement());
      // } else {
      // declaringElement = makeTypeBinding((UnresolvedType)tVar.getDeclaringElement());
      // }
      tvBinding = new TypeVariableBinding(tv.getName().toCharArray(), declaringElement, tv.getRank());
      typeVariableToTypeBinding.put(tv.getName(), tvBinding);

      if (tv.getSuperclass() != null
          && (!tv.getSuperclass().getSignature().equals("Ljava/lang/Object;") || tv.getSuperInterfaces() != null)) {
        tvBinding.superclass = (ReferenceBinding) makeTypeBinding(tv.getSuperclass());
View Full Code Here

  // if method from parameterized type got found, use the original method at codegen time
  this.codegenBinding = this.binding.original();
  if (this.codegenBinding != this.binding) {
      // extra cast needed if method return type was type variable
      if (this.codegenBinding.returnType.isTypeVariable()) {
          TypeVariableBinding variableReturnType = (TypeVariableBinding) this.codegenBinding.returnType;
          if (variableReturnType.firstBound != this.binding.returnType) { // no need for extra cast if same as first bound anyway
          this.valueCast = this.binding.returnType;
          }
      }
  }
View Full Code Here

    if (shouldTreatAsPublic()) {
      MethodBinding binding = world.makeMethodBinding(munger.getSignature(), munger.getTypeVariableAliases());
      findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding);
      TypeVariableBinding[] typeVariables = binding.typeVariables;
      for (int i = 0; i < typeVariables.length; i++) {
        TypeVariableBinding tv = typeVariables[i];
        String name = new String(tv.sourceName);
        TypeVariableBinding[] tv2 = sourceMethod.binding.typeVariables;
        for (int j = 0; j < tv2.length; j++) {
          if (new String(tv2[j].sourceName).equals(name)) {
            typeVariables[i].declaringElement = binding;
View Full Code Here

    int otherLength = otherBindings.length;
    if (length != otherLength) {
      return false;
    }
    for (int i = 0; i < length; i++) {
      TypeVariableBinding typeVariableBinding = bindings[i];
      TypeVariableBinding typeVariableBinding2 = otherBindings[i];
      if (!isEqual(typeVariableBinding, typeVariableBinding2)) {
        return false;
      }
    }
    return true;
View Full Code Here

            return isEqual(captureBinding.wildcard, captureBinding2.wildcard, visitedTypes)
              && isEqual(captureBinding.sourceType, captureBinding2.sourceType, visitedTypes);
          }
          return false;
        }
        TypeVariableBinding typeVariableBinding = (TypeVariableBinding) typeBinding;
        TypeVariableBinding typeVariableBinding2 = (TypeVariableBinding) typeBinding2;
        if (CharOperation.equals(typeVariableBinding.sourceName, typeVariableBinding2.sourceName)) {
          if (visitedTypes.contains(typeBinding)) return true;
          visitedTypes.add(typeBinding);

          return isEqual(typeVariableBinding.declaringElement, typeVariableBinding2.declaringElement, visitedTypes)
          && isEqual(typeVariableBinding.superclass(), typeVariableBinding2.superclass(), visitedTypes)
          && isEqual(typeVariableBinding.superInterfaces(), typeVariableBinding2.superInterfaces(), visitedTypes);
        }
        return false;
      case Binding.GENERIC_TYPE :
        if (!typeBinding2.isGenericType()) {
          return false;
View Full Code Here

   */
  public String getBinaryName() {
    if (this.binding.isCapture()) {
      return null; // no binary name for capture binding
    } else if (this.binding.isTypeVariable()) {
      TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
      org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding declaring = typeVariableBinding.declaringElement;
      StringBuffer binaryName = new StringBuffer();
      switch(declaring.kind()) {
        case org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding.METHOD :
          MethodBinding methodBinding = (MethodBinding) declaring;
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding

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.