Examples of TypeBinding


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

    // check if they used stupid names for type variables
    if (aliasCount>0) {
      for (int i = 0; i < aliasCount; i++) {
        String array_element = (String)typeVariableAliases.get(i);
        SingleTypeReference str = new SingleTypeReference(array_element.toCharArray(),0);
        TypeBinding tb = str.getTypeBindingPublic(classScope);
        if (tb!=null && !(tb instanceof ProblemReferenceBinding)) {// && !(tb instanceof TypeVariableBinding)) {
          scope.problemReporter().signalError(sourceStart,sourceEnd,
              "Intertype declarations can only be made on the generic type, not on a parameterized type. The name '"+
              array_element+"' cannot be used as a type parameter, since it refers to a real type.");
          ignoreFurtherInvestigation = true;
View Full Code Here

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

        boolean usingNonTypeVariableInITD = false;
        // Check if any of them are not type variables
        for (int i = 0; i < pref.typeArguments.length; i++) {
          TypeReference[] refs = pref.typeArguments[i];
          for (int j = 0; refs!=null && j < refs.length; j++) {
            TypeBinding tb = refs[j].getTypeBindingPublic(scope.parent);
            if (!tb.isTypeVariable() && !(tb instanceof ProblemReferenceBinding)) {
              usingNonTypeVariableInITD = true;
            }
           
          }
        }
View Full Code Here

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

    enclosingType = world.fromEclipse(scope.enclosingSourceType());
  }

  public UnresolvedType lookupType(String name, IHasPosition location) {
    char[][] splitName = WildTypePattern.splitNames(name, true);
    TypeBinding b = scope.getType(splitName, splitName.length);
    // FIXME ??? need reasonable error handling...
    if (!b.isValidBinding()) {
      return ResolvedType.MISSING;
    }

    if (referenceFromAnnotationStylePointcut) { // pr265360
      // it must be fully qualified in the pointcut text or in the same
      // package as the type containing the pointcut
      char[] qualifiedPackageName = b.qualifiedPackageName();
      if (!CharOperation.equals(qualifiedPackageName, javaLang)) {
        String packagePrefix = new String(qualifiedPackageName);
        if (!name.startsWith(packagePrefix)) {
          if (validPackage != null && CharOperation.equals(validPackage, qualifiedPackageName)) {
            // it is OK, found in same package as the aspect
View Full Code Here

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

    }
  }

  private static AnnotationValue generateElementValue(Expression defaultValue, TypeBinding memberValuePairReturnType) {
    Constant constant = defaultValue.constant;
    TypeBinding defaultValueBinding = defaultValue.resolvedType;
    if (defaultValueBinding == null) {
      throw new MissingImplementationException(
          "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value [" + defaultValue
              + "]");
    } else {
      if (memberValuePairReturnType.isArrayType() && !defaultValueBinding.isArrayType()) {
        if (constant != null && constant != Constant.NotAConstant) {
          throw new MissingImplementationException(
              "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value ["
                  + defaultValue + "]");
          // generateElementValue(attributeOffset, defaultValue,
View Full Code Here

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

  switchStatement.cases[switchStatement.caseCount++] = this;
  // tag constant name with enum type for privileged access to its members
  if (switchExpressionType != null && switchExpressionType.isEnum() && (this.constantExpression instanceof SingleNameReference)) {
    ((SingleNameReference) this.constantExpression).setActualReceiverType((ReferenceBinding)switchExpressionType);
  }
  TypeBinding caseType = this.constantExpression.resolveType(scope);
  if (caseType == null || switchExpressionType == null) return Constant.NotAConstant;
  if (this.constantExpression.isConstantValueOfTypeAssignableToType(caseType, switchExpressionType)
      || caseType.isCompatibleWith(switchExpressionType)) {
    if (caseType.isEnum()) {
      if (((this.constantExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) != 0) {
        scope.problemReporter().enumConstantsCannotBeSurroundedByParenthesis(this.constantExpression);
      }

      if (this.constantExpression instanceof NameReference
          && (this.constantExpression.bits & ASTNode.RestrictiveFlagMASK) == Binding.FIELD) {
        NameReference reference = (NameReference) this.constantExpression;
        FieldBinding field = reference.fieldBinding();
        if ((field.modifiers & ClassFileConstants.AccEnum) == 0) {
           scope.problemReporter().enumSwitchCannotTargetField(reference, field);
        } else   if (reference instanceof QualifiedNameReference) {
           scope.problemReporter().cannotUseQualifiedEnumConstantInCaseLabel(reference, field);
        }
        return IntConstant.fromValue(field.original().id + 1); // (ordinal value + 1) zero should not be returned see bug 141810
      }
    } else {
      return this.constantExpression.constant;
    }
  } else if (scope.isBoxingCompatibleWith(caseType, switchExpressionType)
          || (caseType.isBaseType()  // narrowing then boxing ?
              && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5 // autoboxing
              && !switchExpressionType.isBaseType()
              && this.constantExpression.isConstantValueOfTypeAssignableToType(caseType, scope.environment().computeBoxingType(switchExpressionType)))) {
    // constantExpression.computeConversion(scope, caseType, switchExpressionType); - do not report boxing/unboxing conversion
    return this.constantExpression.constant;
View Full Code Here

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

      ReferenceType rt = (ReferenceType) aspectType;
      if (rt.isParameterizedType() || rt.isRawType()) {
        aspectType = rt.getGenericType();
      }
    }
    TypeBinding tb = factory.makeTypeBinding(aspectType);

    // Hideousness follows:

    // There are multiple situations to consider here and they relate to the
    // combinations of
    // where the annotation is coming from and where the annotation is going
    // to be put:
    //
    // 1. Straight full build, all from source - the annotation is from a
    // dec@type and
    // is being put on some type. Both types are real SourceTypeBindings.
    // WORKS
    // 2. Incremental build, changing the affected type - the annotation is
    // from a
    // dec@type in a BinaryTypeBinding (so has to be accessed via bcel) and
    // the
    // affected type is a real SourceTypeBinding. Mostly works (pr128665)
    // 3. ?

    SourceTypeBinding stb = (SourceTypeBinding) tb;
    Annotation[] toAdd = null;
    long abits = 0;

    AbstractMethodDeclaration methodDecl = null;
    // Might have to retrieve the annotation through BCEL and construct an
    // eclipse one for it.
    if (stb instanceof BinaryTypeBinding) {
      toAdd = retrieveAnnotationFromBinaryTypeBinding(decA, stb);
      if (toAdd != null && toAdd.length > 0 && toAdd[0].resolvedType != null) {
        abits = toAdd[0].resolvedType.getAnnotationTagBits();
      }
    } else if (stb != null) {
      // much nicer, its a real SourceTypeBinding so we can stay in
      // eclipse land
      // if (decA.getAnnotationMethod() != null) {
      char[] declareSelector = decA.getAnnotationMethod().toCharArray();

      ReferenceBinding rb = stb;
      String declaringAspectName = decA.getDeclaringType().getRawName();
      while (rb != null && !new String(CharOperation.concatWith(rb.compoundName, '.')).equals(declaringAspectName)) {
        rb = rb.superclass();
      }
      MethodBinding[] mbs = rb.getMethods(declareSelector);

      ReferenceBinding declaringBinding = mbs[0].declaringClass;
      if (declaringBinding instanceof ParameterizedTypeBinding) {
        // Unwrap - this means we don't allow the type of the annotation to be parameterized, may need to revisit that
        declaringBinding = ((ParameterizedTypeBinding) declaringBinding).type;
      }
      if (declaringBinding instanceof BinaryTypeBinding) {
        toAdd = retrieveAnnotationFromBinaryTypeBinding(decA, declaringBinding);
        if (toAdd != null && toAdd.length > 0 && toAdd[0].resolvedType != null) {
          abits = toAdd[0].resolvedType.getAnnotationTagBits();
        }
      } else {
        abits = mbs[0].getAnnotationTagBits(); // ensure resolved
        TypeDeclaration typeDecl = ((SourceTypeBinding) declaringBinding).scope.referenceContext;
        methodDecl = typeDecl.declarationOf(mbs[0]);
        toAdd = methodDecl.annotations; // this is what to add
        toAdd[0] = createAnnotationCopy(toAdd[0]);
        if (toAdd[0].resolvedType != null) {
          abits = toAdd[0].resolvedType.getAnnotationTagBits();
          // }
        }
      }
    }

    // This happens if there is another error in the code - that should be reported separately
    if (toAdd == null || toAdd[0] == null || toAdd[0].type == null) {
      CompilationAndWeavingContext.leavingPhase(tok);
      return false;
    }
    if (sourceType instanceof BinaryTypeBinding) {
      // In this case we can't access the source type binding to add a new
      // annotation, so let's put something
      // on the weaver type temporarily
      ResolvedType theTargetType = factory.fromEclipse(sourceType);
      TypeBinding theAnnotationType = toAdd[0].resolvedType;
      // The annotation type may be null if it could not be resolved (eg. the relevant import has not been added yet)
      // In this case an error will be put out about the annotation but not if we crash here
      if (theAnnotationType == null) {
        return false;
      }
      String sig = new String(theAnnotationType.signature());
      UnresolvedType bcelAnnotationType = UnresolvedType.forSignature(sig);
      String name = bcelAnnotationType.getName();
      if (theTargetType.hasAnnotation(bcelAnnotationType)) {
        CompilationAndWeavingContext.leavingPhase(tok);
        return false;
View Full Code Here

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

   * looking for it - when the class actually gets to disk it wont have this new annotation on it and during weave time we will do
   * the right thing copying across values too.
   */
  private static Annotation createAnnotationFromBcelAnnotation(AnnotationAJ annX, int pos, EclipseFactory factory) {
    String name = annX.getTypeName();
    TypeBinding tb = factory.makeTypeBinding(annX.getType());
    // String theName = annX.getSignature().getBaseName();
    char[][] typeName = CharOperation.splitOn('.', name.replace('$', '.').toCharArray()); // pr149293 - not bulletproof...
    long[] positions = new long[typeName.length];
    for (int i = 0; i < positions.length; i++) {
      positions[i] = pos;
View Full Code Here

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

   
  // determine the rank until which we now we do not need any actual value for the field access
  int otherBindingsCount = this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length;
  boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic();
  FieldBinding lastFieldBinding = null;
  TypeBinding lastGenericCast = null;
 
  switch (this.bits & RestrictiveFlagMASK) {
    case Binding.FIELD :
      lastFieldBinding = (FieldBinding) this.codegenBinding;
      lastGenericCast = this.genericCast;
      // if first field is actually constant, we can inline it
      if (lastFieldBinding.constant() != Constant.NotAConstant) {
        break;
      }
      if (needValue) {
        if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
          if (!lastFieldBinding.isStatic()) {
            if ((this.bits & DepthMASK) != 0) {
              ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & DepthMASK) >> DepthSHIFT);
              Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
              codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
            } else {
              generateReceiver(codeStream);
            }
          }
        } else {
          if (!lastFieldBinding.isStatic()) {
            if ((this.bits & DepthMASK) != 0) {
              // internal error, per construction we should have found it
              // not yet supported
              currentScope.problemReporter().needImplementation();
            } else {
              generateReceiver(codeStream);
            }
          } else {
            codeStream.aconst_null();
          }
        }       
      }
      break;
    case Binding.LOCAL : // reading the first local variable
      if (!needValue) break; // no value needed
      LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
      // regular local variable read
      Constant localConstant = localBinding.constant();
      if (localConstant != Constant.NotAConstant) {
        codeStream.generateConstant(localConstant, 0);
        // no implicit conversion
      } else {
        // outer local?
        if ((bits & DepthMASK) != 0) {
          // outer local can be reached either through a synthetic arg or a synthetic field
          VariableBinding[] path = currentScope.getEmulationPath(localBinding);
          codeStream.generateOuterAccess(path, this, localBinding, currentScope);
        } else {
          codeStream.load(localBinding);
        }
      }
  }

  // all intermediate field accesses are read accesses
  // only the last field binding is a write access
  if (this.otherCodegenBindings != null) {
    for (int i = 0; i < otherBindingsCount; i++) {
      FieldBinding nextField = this.otherCodegenBindings[i];
      TypeBinding nextGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[i];
      if (lastFieldBinding != null) {
        needValue = !nextField.isStatic();
        if (needValue) {
          if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
            Constant fieldConstant = lastFieldBinding.constant();
View Full Code Here

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

    if (isFieldUseDeprecated((FieldBinding) this.binding, scope, (this.bits & IsStrictlyAssigned) !=0 && this.indexOfFirstFieldBinding == length)) {
      scope.problemReporter().deprecatedField((FieldBinding) this.binding, this);
    }
  }

  TypeBinding type = ((VariableBinding) this.binding).type;
  int index = this.indexOfFirstFieldBinding;
  if (index == length) { //  restrictiveFlag == FIELD
    this.constant = ((FieldBinding) this.binding).constant();
    return type;
  }
View Full Code Here

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

    }
    this.codegenBinding = this.binding = fieldBinding;
    return checkFieldAccess(scope);
  }

  TypeBinding result;
  if (this.binding instanceof ProblemFieldBinding
    && ((ProblemFieldBinding) this.binding).problemId() == NotVisible) {
    result = resolveTypeVisibility(scope);
    if (result == null) {
      return super.reportError(scope);
    }
    if (result.isValidBinding()) {
      return result;
    }
  }

  return super.reportError(scope);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.