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

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


           */
          org.aspectj.org.eclipse.jdt.internal.core.util.Util.log(e, "Could not retrieve declaring method"); //$NON-NLS-1$
        }
      }
    } else if (this.binding.isTypeVariable()) {
      TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
      Binding declaringElement = typeVariableBinding.declaringElement;
      if (declaringElement instanceof MethodBinding) {
        try {
          return this.resolver.getMethodBinding((MethodBinding)declaringElement);
        } catch (RuntimeException e) {
View Full Code Here


           */
          org.aspectj.org.eclipse.jdt.internal.core.util.Util.log(e, "Could not retrieve declaring class"); //$NON-NLS-1$
        }
      }
    } else if (this.binding.isTypeVariable()) {
      TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
      Binding declaringElement = typeVariableBinding.isCapture() ? ((CaptureBinding) typeVariableBinding).sourceType : typeVariableBinding.declaringElement;
      if (declaringElement instanceof ReferenceBinding) {
        try {
          return this.resolver.getTypeBinding((ReferenceBinding)declaringElement);
        } catch (RuntimeException e) {
          /* in case a method cannot be resolvable due to missing jars on the classpath
View Full Code Here

      case Binding.TYPE_PARAMETER :
        if (isCapture()) {
          return NO_NAME;
        }
        TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
        return new String(typeVariableBinding.sourceName);

      case Binding.PARAMETERIZED_TYPE :
        ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding;
        buffer = new StringBuffer();
View Full Code Here

      case Binding.TYPE_PARAMETER :
        if (isCapture()) {
          return NO_NAME;
        }
        TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
        return new String(typeVariableBinding.sourceName);

      case Binding.PARAMETERIZED_TYPE :
        buffer = new StringBuffer();
        if (isMember()) {
View Full Code Here

  public ITypeBinding[] getTypeBounds() {
    if (this.bounds != null) {
      return this.bounds;
    }
    if (this.binding instanceof TypeVariableBinding) {
      TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
      ReferenceBinding varSuperclass = typeVariableBinding.superclass();
      org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding firstClassOrArrayBound = typeVariableBinding.firstBound;
      int boundsLength = 0;
      if (firstClassOrArrayBound != null) {
        if (firstClassOrArrayBound == varSuperclass) {
          boundsLength++;
        } else if (firstClassOrArrayBound.isArrayType()) { // capture of ? extends/super arrayType
          boundsLength++;
        } else {
          firstClassOrArrayBound = null;
        }
      }
      ReferenceBinding[] superinterfaces = typeVariableBinding.superInterfaces();
      int superinterfacesLength = 0;
      if (superinterfaces != null) {
        superinterfacesLength = superinterfaces.length;
        boundsLength += superinterfacesLength;
      }
View Full Code Here

        return false;
      } else {
        return !referenceBinding.isBinaryBinding();
      }
    } else if (isTypeVariable()) {
      final TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding;
      final Binding declaringElement = typeVariableBinding.declaringElement;
      if (declaringElement instanceof MethodBinding) {
        MethodBinding methodBinding = (MethodBinding) declaringElement;
        return !methodBinding.declaringClass.isBinaryBinding();
      } else {
View Full Code Here

        this.methodBinding = methods[pos];
      }
    }
     TypeVariableBinding[] typeVariableBindings = this.methodBinding != null ? this.methodBinding.typeVariables() : this.typeBinding.typeVariables();
     for (int i = 0, length = typeVariableBindings.length; i < length; i++) {
      TypeVariableBinding typeVariableBinding = typeVariableBindings[i];
      if (CharOperation.equals(typeVariableName, typeVariableBinding.sourceName())) {
        this.typeBinding = typeVariableBinding;
        return;
      }
    }
  }
View Full Code Here

  public TypeVariableBinding findTypeVariable(char[] name, SourceTypeBinding sourceType) {
    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);
        return tvb;
        // error is going to be reported by someone else!
      }
      TypeVariableBinding tvb = sourceType.typeVariables()[aliased];
      if (usedAliases==null) usedAliases = new HashMap();
      usedAliases.put(tvb,variableName);
      return tvb;
    } else {
        return sourceType.getTypeVariable(name);
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;
      UnresolvedType theType = TypeFactory.createTypeFromSignature(CharOperation.charToString(eWB.genericTypeSignature()));
       
     
      // 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 (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...
        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];
      String parameterizedSig = ResolvedType.PARAMETERIZED_TYPE_IDENTIFIER+CharOperation.charToString(binding.genericTypeSignature()).substring(1);
      return TypeFactory.createUnresolvedParameterizedType(parameterizedSig,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

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.