コード例 #1
0
 @Override
 public void endVisit(JsBinaryOperation expr, JsContext ctx) {
   if (expr.getOperator() != JsBinaryOperator.ASG
       || !(expr.getArg1() instanceof JsNameRef)
       || !(expr.getArg2() instanceof JsNameRef)) {
     return;
   }
   assignments.put(expr.getArg1().toString(), ((JsNameRef) expr.getArg2()).getName());
 }
コード例 #2
0
ファイル: JsniReferenceResolver.java プロジェクト: qffan/gwt
    @Override
    public void endVisit(JsBinaryOperation x, JsContext ctx) {
      // Look for the patern a.f = o.@C::m();
      if (!x.getOperator().isAssignment()) {
        return;
      }
      if (!(x.getArg1() instanceof JsNameRef) || !(x.getArg2() instanceof JsNameRef)) {
        return;
      }

      JsNameRef lhs = (JsNameRef) x.getArg1();
      JsNameRef rhs = (JsNameRef) x.getArg2();

      if (!rhs.isJsniReference() || !(jsniRefs.get(rhs.getIdent()) instanceof MethodBinding)) {
        // Not a reference to a JSNI method.
        return;
      }

      if (rhs.getQualifier() == null) {
        // Unqualified JSNI reference is OK.
        return;
      }

      if (lhs.getQualifier() == null) {
        // 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());
    }
コード例 #3
0
 private Node transform(JsBinaryOperation x) {
   JsBinaryOperator op = x.getOperator();
   Node n = new Node(getTokenForOp(op), transform(x.getArg1()), transform(x.getArg2()));
   return applySourceInfo(n, x);
 }