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

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


  private boolean isUnsafeLongAnnotation(Annotation annot, ClassScope scope) {
    if (annot.type != null) {
      TypeBinding resolved = annot.type.resolveType(scope);
      if (resolved != null) {
        if (resolved instanceof ReferenceBinding) {
          ReferenceBinding rb = (ReferenceBinding) resolved;
          if (CharOperation.equals(rb.compoundName,
              UNSAFE_LONG_ANNOTATION_CHARS)) {
            return true;
          }
        }
View Full Code Here


      /*
       * TODO(bobv): OMG WTF LOL. Okay, but seriously, the LHS of a JSNI ref for
       * a primitive type should be the keyword, e.g. "int.class".
       */
      ReferenceBinding clazz = findClass(className);
      boolean isPrimitive = (clazz == null) && className.length() == 1
          && "ZBCDFIJSV".indexOf(className.charAt(0)) >= 0;

      if (isArray || isPrimitive) {
        if (!jsniRef.isField() || !jsniRef.memberName().equals("class")) {
          emitError("Referencing member '" + jsniRef.className() + "."
              + jsniRef.memberName()
              + "': 'class' is the only legal reference for "
              + (isArray ? "array" : "primitive") + " types");
          return;
        }
      }

      if (isPrimitive) {
        return;
      }

      // TODO(bobv): uncomment this.
      // ReferenceBinding clazz = findClass(className);
      if (looksLikeAnonymousClass(jsniRef)
          || (clazz != null && clazz.isAnonymousType())) {
        emitError("Referencing class '" + className
            + ": JSNI references to anonymous classes are illegal");
      } else if (clazz != null) {
        if (clazz.isDeprecated()) {
          emitWarning("deprecation", "Referencing deprecated class '"
              + className + "'");
        }

        if (jsniRef.isMethod()) {
View Full Code Here

      }
      JsniCollector.reportJsniWarning(errorInfo, method, msg);
    }

    private ReferenceBinding findClass(String className) {
      ReferenceBinding binding = typeResolver.resolveType(className);
      assert !(binding instanceof ProblemReferenceBinding);
      assert !(binding instanceof UnresolvedReferenceBinding);
      return binding;
    }
View Full Code Here

        if (fields.length > 0) {
          GWTProblem.recordError(rescue, cud, noFieldsAllowed(), null);
        }
      } else if (typeBinding instanceof ReferenceBinding) {
        ReferenceBinding ref = (ReferenceBinding) typeBinding;

        if (isArray) {
          // No methods or fields on array types (3)
          if (methods.length > 0) {
            GWTProblem.recordError(rescue, cud, noMethodsAllowed(), null);
          }

          if (fields.length > 0) {
            GWTProblem.recordError(rescue, cud, noFieldsAllowed(), null);
          }
        } else {
          // Check methods on reference types (3)
          for (String method : methods) {
            if (method.contains("@")) {
              GWTProblem.recordError(rescue, cud, nameAndTypesOnly(), null);
              continue;
            }
            JsniRef jsni = JsniRef.parse("@foo::" + method);
            if (jsni == null) {
              GWTProblem.recordError(rescue, cud, badMethodSignature(method),
                  null);
              continue;
            }

            if (jsni.memberName().equals(
                String.valueOf(ref.compoundName[ref.compoundName.length - 1]))) {
              // Constructor
            } else {
              MethodBinding[] methodBindings = ref.getMethods(jsni.memberName().toCharArray());
              if (methodBindings == null || methodBindings.length == 0) {
                GWTProblem.recordError(rescue, cud, noMethod(className,
                    jsni.memberName()), null);
                continue;
              }
            }
          }

          // Check fields on reference types (3)
          for (String field : fields) {
            if (ref.getField(field.toCharArray(), false) == null) {
              GWTProblem.recordError(rescue, cud, unknownField(field), null);
            }
          }
        }
      }
View Full Code Here

    return options;
  }

  public static ReferenceBinding resolveType(
      LookupEnvironment lookupEnvironment, String typeName) {
    ReferenceBinding type = null;

    int p = typeName.indexOf('$');
    if (p > 0) {
      // resolve an outer type before trying to get the cached inner
      String cupName = typeName.substring(0, p);
View Full Code Here

      int pc = codeStream.position;
      codeStream.aload_0();

      MethodBinding codegenBinding = this.binding.original();
      ReferenceBinding targetType = codegenBinding.declaringClass;

      // special name&ordinal argument generation for enum constructors
      if (targetType.erasure().id == TypeIds.T_JavaLangEnum || targetType.isEnum()) {
        codeStream.aload_1(); // pass along name param as name arg
        codeStream.iload_2(); // pass along ordinal param as ordinal arg
      }
      // handling innerclass constructor invocation
      // handling innerclass instance allocation - enclosing instance arguments
      if (targetType.isNestedType()) {
        codeStream.generateSyntheticEnclosingInstanceValues(
          currentScope,
          targetType,
          (this.bits & ASTNode.DiscardEnclosingInstance) != 0 ? null : this.qualification,
          this);
      }
      // generate arguments
      generateArguments(this.binding, this.arguments, currentScope, codeStream);

      // handling innerclass instance allocation - outer local arguments
      if (targetType.isNestedType()) {
        codeStream.generateSyntheticOuterArgumentValues(
          currentScope,
          targetType,
          this);
      }
View Full Code Here

   * Dependency mechanism is used whenever dealing with source target
   * types, since by the time we reach them, we might not yet know their
   * exact need.
   */
  void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
    ReferenceBinding superTypeErasure = (ReferenceBinding) this.binding.declaringClass.erasure();

    if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0)  {
    // perform some emulation work in case there is some and we are inside a local type only
    if (superTypeErasure.isNestedType()
      && currentScope.enclosingSourceType().isLocalType()) {

      if (superTypeErasure.isLocalType()) {
        ((LocalTypeBinding) superTypeErasure).addInnerEmulationDependent(currentScope, this.qualification != null);
      } else {
        // locally propagate, since we already now the desired shape for sure
        currentScope.propagateInnerEmulation(superTypeErasure, this.qualification != null);
      }
View Full Code Here

      // if constructor from parameterized type got found, use the original constructor at codegen time
      MethodBinding codegenBinding = this.binding.original();

      // perform some emulation work in case there is some and we are inside a local type only
      if (this.binding.isPrivate() && this.accessMode != ExplicitConstructorCall.This) {
        ReferenceBinding declaringClass = codegenBinding.declaringClass;
        // from 1.4 on, local type constructor can lose their private flag to ease emulation
        if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
          // constructor will not be dumped as private, no emulation required thus
          codegenBinding.tagBits |= TagBits.ClearPrivateModifier;
        } else {
View Full Code Here

          }
        }
        return;
      }
      methodScope.isConstructorCall = true;
      ReferenceBinding receiverType = scope.enclosingReceiverType();
      boolean rcvHasError = false;
      if (this.accessMode != ExplicitConstructorCall.This) {
        receiverType = receiverType.superclass();
        TypeReference superclassRef = scope.referenceType().superclass;
        if (superclassRef != null && superclassRef.resolvedType != null && !superclassRef.resolvedType.isValidBinding()) {
          rcvHasError = true;
        }
      }
      if (receiverType != null) {
        // prevent (explicit) super constructor invocation from within enum
        if (this.accessMode == ExplicitConstructorCall.Super && receiverType.erasure().id == TypeIds.T_JavaLangEnum) {
          scope.problemReporter().cannotInvokeSuperConstructorInEnum(this, methodScope.referenceMethod().binding);
        }
        // qualification should be from the type of the enclosingType
        if (this.qualification != null) {
          if (this.accessMode != ExplicitConstructorCall.Super) {
            scope.problemReporter().unnecessaryEnclosingInstanceSpecification(
              this.qualification,
              receiverType);
          }
          if (!rcvHasError) {
            ReferenceBinding enclosingType = receiverType.enclosingType();
            if (enclosingType == null) {
              scope.problemReporter().unnecessaryEnclosingInstanceSpecification(this.qualification, receiverType);
              this.bits |= ASTNode.DiscardEnclosingInstance;
            } else {
              TypeBinding qTb = this.qualification.resolveTypeExpecting(scope, enclosingType);
View Full Code Here

*/

public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
  if (fieldBinding.isPublic()) return true;

  ReferenceBinding invocationType = (ReferenceBinding) receiverType;
  if (invocationType == fieldBinding.declaringClass) return true;

  if (fieldBinding.isProtected()) {
    // answer true if the invocationType is the declaringClass or they are in the same package
    // OR the invocationType is a subclass of the declaringClass
    //    AND the receiverType is the invocationType or its subclass
    //    OR the field is a static field accessed directly through a type
    if (invocationType == fieldBinding.declaringClass) return true;
    if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
    if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
      if (invocationSite.isSuperAccess()) return true;
      // receiverType can be an array binding in one case... see if you can change it
      if (receiverType instanceof ArrayBinding)
        return false;
      if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
        return true;
      if (fieldBinding.isStatic())
        return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
    }
    return false;
  }

  if (fieldBinding.isPrivate()) {
    // answer true if the receiverType is the declaringClass
    // AND the invocationType and the declaringClass have a common enclosingType
    if (receiverType != fieldBinding.declaringClass) return false;

    if (invocationType != fieldBinding.declaringClass) {
      ReferenceBinding outerInvocationType = invocationType;
      ReferenceBinding temp = outerInvocationType.enclosingType();
      while (temp != null) {
        outerInvocationType = temp;
        temp = temp.enclosingType();
      }

      ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
      temp = outerDeclaringClass.enclosingType();
      while (temp != null) {
        outerDeclaringClass = temp;
        temp = temp.enclosingType();
      }
      if (outerInvocationType != outerDeclaringClass) return false;
    }
    return true;
  }

  // isDefault()
  if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;

  // receiverType can be an array binding in one case... see if you can change it
  if (receiverType instanceof ArrayBinding)
    return false;
  ReferenceBinding type = (ReferenceBinding) receiverType;
  PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
  TypeBinding originalDeclaringClass = fieldBinding.declaringClass .original();
  do {
    if (type.isCapture()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=285002
      if (originalDeclaringClass == type.erasure().original()) return true
    } else {
      if (originalDeclaringClass == type.original()) return true;
    }
    if (declaringPackage != type.fPackage) return false;
  } while ((type = type.superclass()) != null);
  return false;
}
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

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.