Package com.google.gwt.dev.util

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


      String stringLiteral = ((JStringLiteral) arg0).getValue();

      HasName named = null;

      JDeclaredType refType;
      JsniRef ref = JsniRef.parse(stringLiteral);

      if (ref != null) {
        final List<String> errors = new ArrayList<String>();
        HasEnclosingType node = JsniRefLookup.findJsniRefTarget(ref, program,
            new JsniRefLookup.ErrorReporter() {
View Full Code Here


      TreeLogger branch) throws UnableToCompleteException {
    Map<JMethod, List<Integer>> methodToSplitPoint = reverseByEnclosingMethod(program.getRunAsyncReplacements());
    Map<String, List<Integer>> nameToSplitPoint = reverseByName(program.getRunAsyncReplacements());

    if (refString.startsWith("@")) {
      JsniRef jsniRef = JsniRef.parse(refString);
      if (jsniRef == null) {
        branch.log(TreeLogger.ERROR, "Badly formatted JSNI reference in "
            + PROP_INITIAL_SEQUENCE + ": " + refString);
        throw new UnableToCompleteException();
      }
View Full Code Here

    @Override
    public void endVisit(JsNameRef x, JsContext<JsExpression> ctx) {
      this.errorInfo = x.getSourceInfo();
      String ident = x.getIdent();
      if (ident.charAt(0) == '@') {
        JsniRef jsniRef = JsniRef.parse(ident);
        if (jsniRef == null) {
          emitError("Malformed JSNI identifier '" + ident + "'");
        } else {
          checkRef(jsniRef);
        }
View Full Code Here

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

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

      JsniRef parsed = JsniRef.parse(jsniMemberRef);
      if (parsed == null) {
        logger.log(TreeLogger.ERROR, "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 (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();
        int memberId = dispClassInfo.getMemberId(memberName);
        if (memberId < 0) {
          logger.log(TreeLogger.WARN, "Member '" + memberName
              + "' in JSNI reference '" + jsniMemberRef
              + "' could not be found; expect subsequent failures",
View Full Code Here

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

      for (String jsniRefString : sloppyRefsVisitor.getJsniRefs()) {
        JsniRef jsniRef = JsniRef.parse(jsniRefString);
        if (jsniRef != null) {
          Set<String> refErrors = new LinkedHashSet<String>();
          if (jsniRef.isMethod()) {
            checkMethodRef(jsniRef, refErrors);
          } else {
            checkFieldRef(jsniRef, refErrors);
          }
          if (!refErrors.isEmpty()) {
View Full Code Here

          processNameRef(x, ctx);
        }
      }

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

        String className = parsed.className();
        JReferenceType type = null;
        if (!className.equals("null")) {
          type = program.getFromTypeMap(className);
          if (type == null) {
            reportJsniError(info, methodDecl,
                "Unresolvable native reference to type '" + className + "'");
            return null;
          }
        }

        if (!parsed.isMethod()) {
          // look for a field
          String fieldName = parsed.memberName();
          if (type == null) {
            if (fieldName.equals("nullField")) {
              return program.getNullField();
            }
          } else {
            for (int i = 0; i < type.fields.size(); ++i) {
              JField field = type.fields.get(i);
              if (field.getName().equals(fieldName)) {
                return field;
              }
            }
          }

          reportJsniError(info, methodDecl,
              "Unresolvable native reference to field '" + fieldName
                  + "' in type '" + className + "'");
          return null;
        } else {
          // look for a method
          TreeSet<String> almostMatches = new TreeSet<String>();
          String methodName = parsed.memberName();
          String jsniSig = parsed.memberSignature();
          if (type == null) {
            if (jsniSig.equals("nullMethod()")) {
              return program.getNullMethod();
            }
          } else {
View Full Code Here

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

      for (String jsniRefString : sloppyRefsVisitor.getJsniRefs()) {
        JsniRef jsniRef = JsniRef.parse(jsniRefString);
        if (jsniRef != null) {
          ReferenceBinding clazz = findClass(jsniRef);
          if (looksLikeAnonymousClass(jsniRef)
              || (clazz != null && clazz.isAnonymousType())) {
            GWTProblem.recordInCud(ProblemSeverities.Warning, meth, cud,
                "Referencing class '" + jsniRef.className()
                    + ": JSNI references to anonymous classes are deprecated",
                null);
          } else if (clazz != null) {
            Set<String> refErrors = new LinkedHashSet<String>();
            if (jsniRef.isMethod()) {
              checkMethodRef(clazz, jsniRef, refErrors);
            } else {
              checkFieldRef(clazz, jsniRef, refErrors);
            }
            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

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.