Package com.google.gwt.dev.util

Examples of com.google.gwt.dev.util.JsniRef


       */
      if (jsniMemberRef.equals("toString")) {
        jsniMemberRef = "@java.lang.Object::toString()";
      }

      JsniRef parsed = JsniRef.parse(jsniMemberRef);
      if (parsed == null) {
        logger.log(TreeLogger.WARN, "Malformed JSNI reference '"
            + jsniMemberRef + "'; expect subsequent failures",
            new NoSuchFieldError(jsniMemberRef));
        return -1;
      }

      // Do the lookup by class name.
      String className = parsed.className();
      DispatchClassInfo dispClassInfo = getClassInfoFromClassName(className);
      if (dispClassInfo != null) {
        String memberName = parsed.memberSignature();

        /*
         * Disallow the use of JSNI references to SingleJsoImpl interface
         * methods. This policy is due to web-mode dispatch implementation
         * details; resolving the JSNI reference wouldn't be just be a name
View Full Code Here


    FindJsniRefVisitor v = new FindJsniRefVisitor();
    cud.traverse(v, cud.scope);
    Set<String> jsniRefs = v.getJsniRefs();
    Set<String> dependentTypeNames = new HashSet<String>();
    for (String jsniRef : jsniRefs) {
      JsniRef parsed = JsniRef.parse(jsniRef);
      if (parsed != null) {
        // If we fail to parse, don't add a class reference.
        dependentTypeNames.add(parsed.className());
      }
    }
    return dependentTypeNames.toArray(Empty.STRINGS);
  }
View Full Code Here

    if (symbolData != null) {
      // jsniIdent, className, memberName, sourceUri, sourceLine
      String[] parts = symbolData.split(",");
      assert parts.length == 5 : "Expected 5, have " + parts.length;

      JsniRef ref = JsniRef.parse(parts[0].substring(0,
          parts[0].lastIndexOf(')') + 1));
      toReturn = new Object[]{
          ref.className(), ref.memberName(), stw.fileName, stw.lineNumber};

    } else {
      // Use the raw data from the client
      toReturn = new Object[]{
          stw.className, stw.methodName, stw.fileName, stw.lineNumber};
View Full Code Here

        List<String> toRescue = new ArrayList<String>();
        Collections.addAll(toRescue, fields);
        Collections.addAll(toRescue, methods);

        for (String name : toRescue) {
          JsniRef ref = JsniRef.parse("@" + classType.getName() + "::" + name);
          final String[] errors = {null};
          HasEnclosingType node = JsniRefLookup.findJsniRefTarget(ref, program,
              new JsniRefLookup.ErrorReporter() {
                public void reportError(String error) {
                  errors[0] = error;
View Full Code Here

        }
      }

      private HasEnclosingType findJsniRefTarget(final SourceInfo info,
          String ident) {
        JsniRef parsed = JsniRef.parse(ident);
        if (parsed == null) {
          JsniCollector.reportJsniError(info, methodDecl,
              "Badly formatted native reference '" + ident + "'");
          return null;
        }
View Full Code Here

        }
      }

      private HasEnclosingType findJsniRefTarget(final SourceInfo info,
          String ident) {
        JsniRef parsed = JsniRef.parse(ident);
        if (parsed == null) {
          reportJsniError(info, methodDecl,
              "Badly formatted native reference '" + ident + "'");
          return null;
        }
View Full Code Here

        List<String> toRescue = new ArrayList<String>();
        Collections.addAll(toRescue, fields);
        Collections.addAll(toRescue, methods);

        for (String name : toRescue) {
          JsniRef ref = JsniRef.parse("@" + classType.getName() + "::" + name);
          final String[] errors = {null};
          HasEnclosingType node = JsniRefLookup.findJsniRefTarget(ref, program,
              new JsniRefLookup.ErrorReporter() {
                public void reportError(String error) {
                  errors[0] = error;
View Full Code Here

      FindJsniRefVisitor sloppyRefsVisitor = new FindJsniRefVisitor();
      sloppyRefsVisitor.beSloppy();
      meth.traverse(sloppyRefsVisitor, scope);

      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>();
            if (jsniRef.isMethod()) {
              checkMethodRef(clazz, jsniRef, refErrors, warnings);
            } else {
              checkFieldRef(clazz, jsniRef, refErrors, warnings);
            }
            if (!refErrors.isEmpty()) {
              errors.put(jsniRefString, refErrors);
            }
          } else if (!jsniRef.className().equals("null")) {
            /*
             * TODO(scottb): re-enable this when we no longer get a bunch of
             * false failures. Currently we can't resolve top level types (like
             * boolean_Array_Rank_1_FieldSerializer), and we also don't resolve
             * array and primitive refs, like @Z[]::class.
View Full Code Here

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

    FindJsniRefVisitor v = new FindJsniRefVisitor();
    cud.traverse(v, cud.scope);
    Set<String> jsniRefs = v.getJsniRefs();
    Set<String> dependentTypeNames = new HashSet<String>();
    for (String jsniRef : jsniRefs) {
      JsniRef parsed = JsniRef.parse(jsniRef);
      if (parsed != null) {
        // If we fail to parse, don't add a class reference.
        dependentTypeNames.add(parsed.className());
      }
    }
    return dependentTypeNames.toArray(Empty.STRINGS);
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.util.JsniRef

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.