Package com.google.errorprone.fixes

Examples of com.google.errorprone.fixes.Fix


     * Fixes instances of calling toString() on an array.  If the array is the result of calling
     * e.getStackTrace(), replaces e.getStackTrace().toString() with Guava's
     * Throwables.getStackTraceAsString(e).
     * Otherwise, replaces a.toString() with Arrays.toString(a).
     */
    Fix fix;

    ExpressionTree receiverTree = ASTHelpers.getReceiver(methodTree);
    if (receiverTree instanceof MethodInvocationTree &&
        getStackTraceMatcher.matches((MethodInvocationTree) receiverTree, state)) {
      String throwable = ASTHelpers.getReceiver(receiverTree).toString();
View Full Code Here


    ExpressionTree lhs = ASTHelpers.getReceiver(methodInvocationTree);
    ExpressionTree rhs = methodInvocationTree.getArguments().get(0);
   
    // default fix for methods
    Fix fix = SuggestedFix.delete(parent);
    if (methodSelect(instanceMethod(Matchers.<ExpressionTree>anything(), "removeAll"))
        .matches(methodInvocationTree, state)) {
      fix = SuggestedFix.replace(methodInvocationTree, lhs + ".clear()");
    }
View Full Code Here

    }

    if (!locks.allLocks().contains(guard)) {
      String message = String.format("Expected %s to be held, instead found %s", guard, locks);
      // TODO(user) - this fix is a debugging aid, remove it before productionizing the check.
      Fix fix = SuggestedFix.prefixWith(tree, String.format("/* %s */", message));
      return Description.builder(tree, pattern)
          .setMessage(message)
          .addFix(fix)
          .build();
    }
View Full Code Here

    if (arrayMatcher.matches(t.getLeftOperand(), state)) {
      replacement = "Arrays.toString(" + leftOperand + ") + " + rightOperand;
    } else {
      replacement = leftOperand + " + Arrays.toString(" + rightOperand + ")";
    }
    Fix fix = SuggestedFix.builder()
        .replace(t, replacement)
        .addImport("java.util.Arrays")
        .build();
    return describeMatch(t, fix);
  }
View Full Code Here

    if (matchState == MatchState.NONE) {
      throw new IllegalStateException("describe() called without a match");
    }

    // If we don't find a good field to use, then just replace with "true"
    Fix fix = SuggestedFix.replace(methodInvocationTree, "true");

    if (matchState == MatchState.OBJECTS_EQUAL) {
      /**
       * Cases:
       *    1) Objects.equal(foo, foo) ==> Objects.equal(foo, other.foo)
View Full Code Here

TOP

Related Classes of com.google.errorprone.fixes.Fix

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.