Examples of FieldBinding


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

  private static AnnotationValue generateElementValueForNonConstantExpression(Expression defaultValue,
      TypeBinding defaultValueBinding) {
    if (defaultValueBinding != null) {
      if (defaultValueBinding.isEnum()) {
        FieldBinding fieldBinding = null;
        if (defaultValue instanceof QualifiedNameReference) {
          QualifiedNameReference nameReference = (QualifiedNameReference) defaultValue;
          fieldBinding = (FieldBinding) nameReference.binding;
        } else if (defaultValue instanceof SingleNameReference) {
          SingleNameReference nameReference = (SingleNameReference) defaultValue;
View Full Code Here

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

      // check missing blank final field initializations
      flowInfo = flowInfo.mergedWith(staticInitializerFlowContext.initsOnReturn);
      FieldBinding[] fields = scope.enclosingSourceType().fields();
      for (int i = 0, count = fields.length; i < count; i++) {
        FieldBinding field;
        if ((field = fields[i]).isStatic()
          && field.isFinal()
          && (!flowInfo.isDefinitelyAssigned(fields[i]))) {
          scope.problemReporter().uninitializedBlankFinalField(
            field,
            scope.referenceType().declarationOf(field.original()));
          // can complain against the field decl, since only one <clinit>
        }
      }
      // check static initializers thrown exceptions
      staticInitializerFlowContext.checkInitializerExceptions(
View Full Code Here

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

      }

      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)
View Full Code Here

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

            switch(problemFieldBinding.problemId()) {
              case ProblemReasons.NotVisible :
              case ProblemReasons.NonStaticReferenceInStaticContext :
              case ProblemReasons.NonStaticReferenceInConstructorInvocation :
                ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
                FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name, true /*resolve*/);
                if (exactBinding != null) {
                  IVariableBinding variableBinding2 = (IVariableBinding) this.bindingTables.compilerBindingsToASTBindings.get(exactBinding);
                  if (variableBinding2 != null) {
                    return variableBinding2;
                  }
View Full Code Here

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

          switch(problemFieldBinding.problemId()) {
            case ProblemReasons.NotVisible :
            case ProblemReasons.NonStaticReferenceInStaticContext :
            case ProblemReasons.NonStaticReferenceInConstructorInvocation :
              ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
              FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name, true /*resolve*/);
              if (exactBinding != null) {
                IVariableBinding variableBinding2 = (IVariableBinding) this.bindingTables.compilerBindingsToASTBindings.get(exactBinding);
                if (variableBinding2 != null) {
                  return variableBinding2;
                }
View Full Code Here

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

        } else {
          // in this case we want to get the next field declaring's class
          if (qualifiedNameReference.otherBindings == null) {
            return null;
          }
          FieldBinding fieldBinding = qualifiedNameReference.otherBindings[0];
          if (fieldBinding == null) return null;
          org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = fieldBinding.declaringClass;
          if (type == null) { // array length scenario
            // use type from first binding (no capture needed for array type)
            switch (qualifiedNameReference.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.RestrictiveFlagMASK) {
              case Binding.FIELD:
                type = ((FieldBinding) qualifiedNameReference.binding).type;
                break;
              case Binding.LOCAL:
                type = ((LocalVariableBinding) qualifiedNameReference.binding).type;
                break;
            }
          }
          return this.getTypeBinding(type);
        }
      } else {
        /* This is the case for a name which is part of a qualified name that
         * cannot be resolved. See PR 13063.
         */
        if (qualifiedNameReference.otherBindings == null) return null;
        final int otherBindingsLength = qualifiedNameReference.otherBindings.length;
        if (otherBindingsLength == (index - indexOfFirstFieldBinding)) {
          return this.getTypeBinding(qualifiedNameReference.resolvedType);
        }
        FieldBinding fieldBinding = qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding];
        if (fieldBinding == null) return null;
        org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = fieldBinding.declaringClass;
        if (type == null) { // array length scenario
          // use type from previous binding (no capture needed for array type)
          fieldBinding = qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding - 1];
View Full Code Here

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

              switch(problemFieldBinding.problemId()) {
                case ProblemReasons.NotVisible :
                case ProblemReasons.NonStaticReferenceInStaticContext :
                  ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
                  if (declaringClass != null) {
                    FieldBinding exactBinding = declaringClass.getField(tokens[tokens.length - 1], true /*resolve*/);
                    if (exactBinding != null) {
                      if (exactBinding.type != null) {
                        IVariableBinding variableBinding = (IVariableBinding) this.bindingTables.compilerBindingsToASTBindings.get(exactBinding);
                        if (variableBinding != null) {
                          return variableBinding;
                        }
                        variableBinding = new VariableBinding(this, exactBinding);
                        this.bindingTables.compilerBindingsToASTBindings.put(exactBinding, variableBinding);
                        return variableBinding;
                      }
                    }
                  }
                  break;
              }
            }
          }
        }
      } else {
        /* This is the case for a name which is part of a qualified name that
         * cannot be resolved. See PR 13063.
         */
        if (qualifiedNameReference.otherBindings == null || (index - indexOfFirstFieldBinding - 1) < 0) {
          return null;
        } else {
          return this.getVariableBinding(qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding - 1]);
        }
      }
    } else if (node instanceof QualifiedTypeReference) {
      QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) node;
      if (qualifiedTypeReference.resolvedType == null) {
        return null;
      }
      if (index == qualifiedTypeReference.tokens.length) {
        if (!qualifiedTypeReference.resolvedType.isValidBinding() && qualifiedTypeReference instanceof JavadocQualifiedTypeReference) {
          JavadocQualifiedTypeReference typeRef = (JavadocQualifiedTypeReference) node;
          if (typeRef.packageBinding != null) {
            return getPackageBinding(typeRef.packageBinding);
          }
        }
        return this.getTypeBinding(qualifiedTypeReference.resolvedType.leafComponentType());
      } else {
        if (index >= 0) {
          BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
          Binding binding = null;
          try {
            if (internalScope == null) {
              if (this.scope == null) return null;
              binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, index));
            } else {
              binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, index));
            }
          } catch (AbortCompilation e) {
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          }
          if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
            return this.getPackageBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
            // it is a type
            return this.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
          } else {
            return null;
          }
        }
      }
    } else if (node instanceof ImportReference) {
      ImportReference importReference = (ImportReference) node;
      int importReferenceLength = importReference.tokens.length;
      if (index >= 0) {
        Binding binding = null;
        if (this.scope == null) return null;
        if (importReferenceLength == index) {
          try {
            binding = this.scope.getImport(CharOperation.subarray(importReference.tokens, 0, index), (importReference.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand) != 0, importReference.isStatic());
          } catch (AbortCompilation e) {
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          }
        } else {
          try {
            binding = this.scope.getImport(CharOperation.subarray(importReference.tokens, 0, index), true, importReference.isStatic());
          } catch (AbortCompilation e) {
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          }
        }
        if (binding != null) {
          if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
            return this.getPackageBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
            // it is a type
            return this.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding) {
            // it is a type
            return this.getVariableBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding) {
            // it is a type
            return this.getMethodBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding)binding);
          } else {
            return null;
          }
        }
      }
    } else if (node instanceof CompilationUnitDeclaration) {
      CompilationUnitDeclaration compilationUnitDeclaration = (CompilationUnitDeclaration) node;
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
      if (types == null || types.length == 0) {
        return null;
      }
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type = types[0];
      if (type != null) {
        ITypeBinding typeBinding = this.getTypeBinding(type.binding);
        if (typeBinding != null) {
          return typeBinding.getPackage();
        }
      }
    } else if (node instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) node;
      IMethodBinding methodBinding = this.getMethodBinding(methodDeclaration.binding);
      if (methodBinding != null) {
        return methodBinding;
      }
    } else if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node;
      ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
      if (typeBinding != null) {
        return typeBinding;
      }
    } if (node instanceof SingleNameReference) {
      SingleNameReference singleNameReference = (SingleNameReference) node;
      if (singleNameReference.isTypeReference()) {
        return this.getTypeBinding(singleNameReference.resolvedType);
      } else {
        // this is a variable or a field
        Binding binding = singleNameReference.binding;
        if (binding != null) {
          if (binding.isValidBinding()) {
            return this.getVariableBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
          } else {
            /*
             * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
             */
            if (binding instanceof ProblemFieldBinding) {
              ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) binding;
              switch(problemFieldBinding.problemId()) {
                case ProblemReasons.NotVisible :
                case ProblemReasons.NonStaticReferenceInStaticContext :
                case ProblemReasons.NonStaticReferenceInConstructorInvocation :
                  ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
                  FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name, true /*resolve*/);
                  if (exactBinding != null) {
                    if (exactBinding.type != null) {
                      IVariableBinding variableBinding2 = (IVariableBinding) this.bindingTables.compilerBindingsToASTBindings.get(exactBinding);
                      if (variableBinding2 != null) {
                        return variableBinding2;
View Full Code Here

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

      if (defaultValueBinding.isEnum()) {
        if (contentsOffset + 5 >= this.contents.length) {
          resizeContents(5);
        }
        contents[contentsOffset++] = (byte) 'e';
        FieldBinding fieldBinding = null;
        if (defaultValue instanceof QualifiedNameReference) {
          QualifiedNameReference nameReference = (QualifiedNameReference) defaultValue;
          fieldBinding = (FieldBinding) nameReference.binding;
        } else if (defaultValue instanceof SingleNameReference) {
          SingleNameReference nameReference = (SingleNameReference) defaultValue;
View Full Code Here

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

public FlowInfo analyseAssignment(BlockScope currentScope,   FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound) {
  // determine the rank until which we now we do not need any actual value for the field access
  int otherBindingsCount = this.otherBindings == null ? 0 : this.otherBindings.length;
  boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic();
  boolean complyTo14 = currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4;
  FieldBinding lastFieldBinding = null;
  switch (this.bits & ASTNode.RestrictiveFlagMASK) {
    case Binding.FIELD : // reading a field
      lastFieldBinding = (FieldBinding) this.binding;
      if (needValue || complyTo14) {
        manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, this.actualReceiverType, 0, flowInfo);
      }
      if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding
        ReferenceBinding declaringClass = lastFieldBinding.declaringClass;
        // check if accessing enum static field in initializer         
        if (declaringClass.isEnum()) {
          MethodScope methodScope = currentScope.methodScope();
          SourceTypeBinding sourceType = methodScope.enclosingSourceType();
          if (lastFieldBinding.isStatic()
              && (sourceType == declaringClass || sourceType.superclass == declaringClass) // enum constant body
              && lastFieldBinding.constant() == Constant.NotAConstant
              && !methodScope.isStatic
              && methodScope.isInsideInitializerOrConstructor()) {
            currentScope.problemReporter().enumStaticFieldUsedDuringInitialization(lastFieldBinding, this);
          }
        }       
      }
      // check if final blank field
      if (lastFieldBinding.isBlankFinal()
            && this.otherBindings != null // the last field binding is only assigned
           && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
        if (!flowInfo.isDefinitelyAssigned(lastFieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(
            lastFieldBinding,
            this);
        }
      }
      break;
    case Binding.LOCAL :
      // first binding is a local variable
      LocalVariableBinding localBinding;
      if (!flowInfo
        .isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
        currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
      }
      if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)  {
        localBinding.useFlag = LocalVariableBinding.USED;
      } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
        localBinding.useFlag = LocalVariableBinding.FAKE_USED;
      }
      checkNPE(currentScope, flowContext, flowInfo, true);
  }
 
  if (needValue) {
    manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
    // only for first binding
  }
  // all intermediate field accesses are read accesses
  if (this.otherBindings != null) {
    for (int i = 0; i < otherBindingsCount-1; i++) {
      lastFieldBinding = this.otherBindings[i];
      needValue = !this.otherBindings[i+1].isStatic();
      if (needValue || complyTo14) {
        manageSyntheticAccessIfNecessary(
          currentScope,
          lastFieldBinding,
          i == 0
            ? ((VariableBinding)this.binding).type
            : this.otherBindings[i-1].type,
          i + 1,
          flowInfo);
      }
    }
    lastFieldBinding = this.otherBindings[otherBindingsCount-1];
  }

  if (isCompound) {
    if (otherBindingsCount == 0
        && lastFieldBinding.isBlankFinal()
        && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)
        && (!flowInfo.isDefinitelyAssigned(lastFieldBinding))) {
      currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
    }
    TypeBinding lastReceiverType;
    switch (otherBindingsCount) {
      case 0 :
        lastReceiverType = this.actualReceiverType;
        break;
      case 1 :
        lastReceiverType = ((VariableBinding)this.binding).type;
        break;
      default:
        lastReceiverType = this.otherBindings[otherBindingsCount-2].type;
        break;
    }
    manageSyntheticAccessIfNecessary(
      currentScope,
      lastFieldBinding,
      lastReceiverType,
      otherBindingsCount,
      flowInfo);
  }
 
  if (assignment.expression != null) {
    flowInfo =
      assignment
        .expression
        .analyseCode(currentScope, flowContext, flowInfo)
        .unconditionalInits();
  }
 
  // the last field access is a write access
  if (lastFieldBinding.isFinal()) {
    // in a context where it can be assigned?
    if (otherBindingsCount == 0
        && this.indexOfFirstFieldBinding == 1
        && lastFieldBinding.isBlankFinal()
        && !isCompound
        && currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)) {
      if (flowInfo.isPotentiallyAssigned(lastFieldBinding)) {
        currentScope.problemReporter().duplicateInitializationOfBlankFinalField(lastFieldBinding, this);
      } else {
View Full Code Here

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

    case Binding.FIELD : // reading a field
      if (needValue || complyTo14) {
        manageSyntheticAccessIfNecessary(currentScope, (FieldBinding) this.binding, this.actualReceiverType, 0, flowInfo);
      }
      if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding
        FieldBinding fieldBinding = (FieldBinding) this.binding;
        ReferenceBinding declaringClass = fieldBinding.declaringClass;
        // check if accessing enum static field in initializer         
        if (declaringClass.isEnum()) {
          MethodScope methodScope = currentScope.methodScope();
          SourceTypeBinding sourceType = methodScope.enclosingSourceType();
          if (fieldBinding.isStatic()
              && (sourceType == declaringClass || sourceType.superclass == declaringClass) // enum constant body
              && fieldBinding.constant() == Constant.NotAConstant
              && !methodScope.isStatic
              && methodScope.isInsideInitializerOrConstructor()) {
            currentScope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this);
          }
        }       
        // check if reading a final blank field
        if (fieldBinding.isBlankFinal()
            && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)
            && !flowInfo.isDefinitelyAssigned(fieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
        }
      }
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.