Package com.google.gwt.dev.util

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


   *
   * @param methodSignature
   *            the method jsni signature which body will be searched for field references.
   */
  private String[] getJsniFieldReferences(String methodSignature) {
    JsniRef parsed = JsniRef.parse(methodSignature);
    if (parsed != null) {
      String lookupClassName = parsed.className().replace('.', '/');
      CompilationUnit compilationUnit = classLoader.getUnitForClassName(lookupClassName);
      if (compilationUnit != null) {
        for (JsniMethod jsniMethod : compilationUnit.getJsniMethods()) {
          if (jsniMethod.name().equals(methodSignature)) {
            String source = jsniMethod.function().toSource();
View Full Code Here


          memberSignature = code.substring(atIndex, closeIndex);
        }
        // check for 'name.@XXX' and skip it
        if (code.charAt(atIndex - 1) != '.') {
          // do additional check using Jsni.parse() method
          JsniRef parsedSignature = JsniRef.parse(memberSignature);
          if (parsedSignature != null && parsedSignature.isField()) {
            String fieldName = parsedSignature.memberName();
            int referenceIndex = fieldName.indexOf('.');
            if (referenceIndex != -1) {
              fieldName = fieldName.substring(0, referenceIndex);
            }
            fieldRefs.add("@" + parsedSignature.className() + "::" + fieldName);
          }
        }
        code = code.substring(closeIndex, code.length());
      }
    }
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();

        /*
         * 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

    @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

      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

    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

       */
      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

        // Assignment to unqualified variable is OK.
        return;
      }

      // Here we have a qualified JSNI method reference assigned to a field.
      JsniRef jsniRef = JsniRef.parse(rhs.getIdent());
      emitWarning("unsafe", WARN_NOT_CAPTURING_QUALIFIER, x.getSourceInfo(), jsniRef,
          rhs.getQualifier().toSource());
    }
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.