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

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


  private boolean isJsoSubclass(TypeBinding typeBinding) {
    if (!(typeBinding instanceof ReferenceBinding)) {
      return false;
    }
    ReferenceBinding binding = (ReferenceBinding) typeBinding;
    while (binding.superclass() != null) {
      if (JSO_CLASS.equals(String.valueOf(binding.superclass().constantPoolName()))) {
        return true;
      }
      binding = binding.superclass();
    }
    return false;
  }
View Full Code Here


      nodesToCuds.put(jsoType, cud);
      add(jsoImplsToInterfaces, jsoType, interfaceName);
    }

    private boolean hasSupertypeNamed(TypeDeclaration type, char[][] qType) {
      ReferenceBinding b = type.binding;
      while (b != null) {
        if (CharOperation.equals(b.compoundName, qType)) {
          return true;
        }
        b = b.superclass();
      }
      return false;
    }
View Full Code Here

      for (String jsniRefString : sloppyRefsVisitor.getJsniRefs()) {
        JsniRef jsniRef = JsniRef.parse(jsniRefString);
        Map<String, Set<String>> warnings = new LinkedHashMap<String, Set<String>>();

        if (jsniRef != null) {
          ReferenceBinding clazz = findClass(jsniRef);
          if (looksLikeAnonymousClass(jsniRef)
              || (clazz != null && clazz.isAnonymousType())) {
            add(warnings, "deprecation", "Referencing class '"
                + jsniRef.className()
                + ": JSNI references to anonymous classes are deprecated");

          } else if (clazz != null) {
            if (clazz.isDeprecated()) {
              add(warnings, "deprecation", "Referencing deprecated class '"
                  + jsniRef.className() + "'");
            }

            Set<String> refErrors = new LinkedHashSet<String>();
View Full Code Here

      // }
      if (binding instanceof ProblemReferenceBinding) {
        ProblemReferenceBinding prb = (ProblemReferenceBinding) binding;
        if (prb.problemId() == ProblemReasons.NotVisible) {
          // It's just a visibility problem, so try drilling down manually
          ReferenceBinding drilling = prb.closestReferenceMatch();
          for (int i = prb.compoundName.length; i < compoundName.length; i++) {
            drilling = drilling.getMemberType(compoundName[i]);
          }
          binding = drilling;
        }
      }
View Full Code Here

    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

        if (fields.length > 0) {
          GWTProblem.recordInCud(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.recordInCud(rescue, cud, noMethodsAllowed(), null);
          }

          if (fields.length > 0) {
            GWTProblem.recordInCud(rescue, cud, noFieldsAllowed(), null);
          }
        } else {
          // Check methods on reference types (3)
          for (String method : methods) {
            if (method.contains("@")) {
              GWTProblem.recordInCud(rescue, cud, nameAndTypesOnly(), null);
              continue;
            }
            JsniRef jsni = JsniRef.parse("@foo::" + method);
            if (jsni == null) {
              GWTProblem.recordInCud(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.recordInCud(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.recordInCud(rescue, cud, unknownField(field), null);
            }
          }
        }
      }
View Full Code Here

      this.cuds = cuds;
      compile(units);
    }

    private ReferenceBinding resolvePossiblyNestedType(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

      String typeName) {
    /*
     * This causes the compiler to find the additional type, possibly winding
     * its back to ask for the compilation unit from the source oracle.
     */
    ReferenceBinding type = resolvePossiblyNestedType(typeName);

    // Sanity check rebind results.
    if (type == null) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName + "' could not be found");
      return;
    }
    if (!type.isClass()) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName + "' must be a class");
      return;
    }
    if (type.isAbstract()) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName + "' cannot be abstract");
      return;
    }
    if (type.isNestedType() && !type.isStatic()) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName
              + "' cannot be a non-static nested class");
      return;
    }
    if (type.isLocalType()) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName + "' cannot be a local class");
      return;
    }
    // Look for a noArg ctor.
    MethodBinding noArgCtor = type.getExactConstructor(TypeBinding.NO_PARAMETERS);
    if (noArgCtor == null) {
      FindDeferredBindingSitesVisitor.reportRebindProblem(site,
          "Rebind result '" + typeName
              + "' has no default (zero argument) constructors");
      return;
View Full Code Here

        // original params are now frozen

        info.addCorrelation(program.getCorrelator().by(newMethod));

        int syntheticParamCount = 0;
        ReferenceBinding declaringClass = b.declaringClass;
        if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
          // add synthetic args for outer this and locals
          NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
          Set<String> alreadyNamedVariables = new HashSet<String>();
          if (nestedBinding.enclosingInstances != null) {
            for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
              SyntheticArgumentBinding arg = nestedBinding.enclosingInstances[i];
              String argName = String.valueOf(arg.name);
              if (alreadyNamedVariables.contains(argName)) {
                argName += "_" + i;
              }
              createParameter(arg, argName, newMethod);
              ++syntheticParamCount;
              alreadyNamedVariables.add(argName);
            }
          }

          if (nestedBinding.outerLocalVariables != null) {
            for (int i = 0; i < nestedBinding.outerLocalVariables.length; ++i) {
              SyntheticArgumentBinding arg = nestedBinding.outerLocalVariables[i];
              String argName = String.valueOf(arg.name);
              if (alreadyNamedVariables.contains(argName)) {
                argName += "_" + i;
              }
              createParameter(arg, argName, newMethod);
              ++syntheticParamCount;
              alreadyNamedVariables.add(argName);
            }
          }
        }

        typeMap.put(b, newMethod);

        // Now let's implicitly create a static function called 'new' that will
        // allow construction from JSNI methods
        if (!enclosingType.isAbstract()) {
          ReferenceBinding enclosingBinding = ctorDecl.binding.declaringClass.enclosingType();
          JReferenceType outerType = enclosingBinding == null ? null
              : (JReferenceType) typeMap.get(enclosingBinding);
          createSyntheticConstructor(newMethod,
              ctorDecl.binding.declaringClass.isStatic(), outerType);
        }
View Full Code Here

              createField(arg, type);
            }
          }
        }

        ReferenceBinding superClassBinding = binding.superclass();
        if (superClassBinding != null) {
          // TODO: handle separately?
          assert (binding.superclass().isClass() || binding.superclass().isEnum());
          JClassType superClass = (JClassType) typeMap.get(superClassBinding);
          type.setSuperClass(superClass);
        }

        ReferenceBinding[] superInterfaces = binding.superInterfaces();
        for (int i = 0; i < superInterfaces.length; ++i) {
          ReferenceBinding superInterfaceBinding = superInterfaces[i];
          assert (superInterfaceBinding.isInterface());
          JInterfaceType superInterface = (JInterfaceType) typeMap.get(superInterfaceBinding);
          type.addImplements(superInterface);
        }

        if (type instanceof JEnumType) {
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.