Examples of Fix


Examples of com.google.errorprone.fixes.Fix

    JCEnhancedForLoop enhancedForLoop = (JCEnhancedForLoop) tree;
    IdentifierTree identifier =
        getIncrementedIdentifer(extractSingleStatement(enhancedForLoop.body));
    if (identifier != null) {
      ExpressionTree expression = tree.getExpression();
      Fix fix;
      if (isSubtypeOf("java.util.Collection").matches(expression, state)) {
        String replacement = identifier + " += " + expression + ".size();";
        fix = SuggestedFix.replace(tree, replacement);
      } else if (isArrayType().matches(expression, state)) {
        String replacement = identifier + " += " + expression + ".length;";
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

    JCTree nonLiteralOperand = (JCTree) binaryTreeMatches.get(1);
    boolean byteMatch = state.getTypes().isSameType(nonLiteralOperand.type,
        state.getSymtab().byteType);

    boolean willEvaluateTo = (tree.getKind() != Kind.EQUAL_TO);
    Fix fix;
    String customDiagnosticMessage;
    if (byteMatch) {
      String replacement = Byte.toString(((Number) literal.getValue()).byteValue());

      // Correct for poor javac 6 literal parsing.
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

    }

    // figure out where to insert the static modifier
    // if there is other modifier, prepend 'static ' in front of class
    // else insert 'static ' AFTER public/private/protected and BEFORE final
    Fix fix;

    ModifiersTree mods = tree.getModifiers();
    if (mods.getFlags().isEmpty()) {
      fix = SuggestedFix.prefixWith(tree, "static ");
    } else {
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

      fixedExpression.append("!");
    }
    fixedExpression.append(
        "Objects.equal(" + leftOperand + ", " + rightOperand + ")");

    Fix fix = SuggestedFix.builder()
        .replace(tree, fixedExpression.toString())
        .addImport("com.google.common.base.Objects")
        .build();
    return describeMatch(tree, fix);
  }
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

        && ASTHelpers.sameVariable(tree.getLeftOperand(), tree.getRightOperand()))) {
      return Description.NO_MATCH;
    }

    StringBuilder fixedExpression = new StringBuilder();
    Fix fix = null;

    ExpressionTree leftOperand = tree.getLeftOperand();
    ExpressionTree rightOperand = tree.getRightOperand();
    Type leftType = ((JCTree) leftOperand).type;
    Types types = state.getTypes();
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

    }

    Type returnType = ASTHelpers.getReturnType(
        ((JCMethodInvocation) methodInvocationTree).getMethodSelect());

    Fix fix;
    if (identifierStr != null && !"this".equals(identifierStr) && returnType != null &&
        state.getTypes().isAssignable(returnType, identifierType)) {
      // Fix by assigning the assigning the result of the call to the root receiver reference.
      fix = SuggestedFix.prefixWith(methodInvocationTree, identifierStr + " = ");
    } else {
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

     * concatenation-and-assignment with Arrays.toString(array). Also adds
     * the necessary import statement for java.util.Arrays.
     */
    String receiver = t.getVariable().toString();
    String expression = t.getExpression().toString();
    Fix fix = SuggestedFix.builder()
        .replace(t, receiver + " += Arrays.toString(" + expression + ")")
        .addImport("java.util.Arrays")
        .build();
    return describeMatch(t, fix);
  }
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

      throw new AssertionError("Impossible IOException");
    }

    String replacement = sw.toString().replace("@Override()", "@Override");

    Fix fix = SuggestedFix.replace(methodInvocation, replacement);

    return describeMatch(methodInvocation, fix);
  }
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

      return Description.NO_MATCH;
    }
    // We don't have start position for a method symbol, so we replace everything between result
    // type and body.
    JCMethodDecl decl = (JCMethodDecl) methodTree;
    Fix fix = SuggestedFix.replace(
        decl.restype.getStartPosition() + 4, decl.body.getStartPosition(), " " + fixedName + "() ");
    return describeMatch(methodTree, fix);
  }
View Full Code Here

Examples of com.google.errorprone.fixes.Fix

    // the statement that is the parent of the self-assignment expression
    Tree parent = state.getPath().getParentPath().getLeaf();

    // default fix is to delete assignment
    Fix fix = SuggestedFix.delete(parent);

    ExpressionTree lhs = assignmentTree.getVariable();
    ExpressionTree rhs = assignmentTree.getExpression();

    // if this is a method invocation, they must be calling checkNotNull()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.