/** * Given an error message produced by this lint detector for the {@link #SWITCH_TYPE_DEF} issue * type, returns the list of missing enum cases. <p> Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the list of enum cases, or null if not recognized */ @Nullable public static List<String> getMissingCases(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); String substring = findSubstring(errorMessage, " missing case ", null); if (substring == null) { substring = findSubstring(errorMessage, "expected one of: ", null); } if (substring != null) { return Splitter.on(",").trimResults().splitToList(substring); } return null; }
/** * Given an error message produced by this lint detector, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); String attribute = LintUtils.findSubstring(errorMessage, " should use ", " "); if (attribute == null) { attribute = LintUtils.findSubstring(errorMessage, " should use ", null); } return attribute; } }
/** * Given an error message produced by this lint detector, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); String attribute = LintUtils.findSubstring(errorMessage, " should use ", " "); if (attribute == null) { attribute = LintUtils.findSubstring(errorMessage, " should use ", null); } return attribute; } }
/** * Returns the resource type expected for a {@link #TYPE_MISMATCH} error reported by * this lint detector. Intended for IDE quickfix implementations. * * @param message the error message created by this lint detector * @param format the format of the error message */ public static String getExpectedType(@NonNull String message, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(message), "value of type @", "/"); } }
/** * Returns the resource type expected for a {@link #TYPE_MISMATCH} error reported by * this lint detector. Intended for IDE quickfix implementations. * * @param message the error message created by this lint detector * @param format the format of the error message */ public static String getExpectedType(@NonNull String message, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(message), "value of type @", "/"); } }
/** * Returns the escaped string value suggested by the error message which should have * been computed by this lint detector. * * @param message the error message created by this lint detector * @param format the format of the error message * @return the suggested escaped value */ @Nullable public static String getSuggestedEscape(@NonNull String message, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(message), "; use ", null); } }
/** * Returns the escaped string value suggested by the error message which should have * been computed by this lint detector. * * @param message the error message created by this lint detector * @param format the format of the error message * @return the suggested escaped value */ @Nullable public static String getSuggestedEscape(@NonNull String message, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(message), "; use ", null); } }
/** * Given an error message produced by this lint detector for the given issue type, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, "call \"", "\""); } }
/** * Given an error message produced by this lint detector for the given issue type, * returns the old value to be replaced in the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding old value, or null if not recognized */ @Nullable public static String getOldValue(@NonNull String errorMessage, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(errorMessage), " tag <", ">"); }
/** * Given an error message produced by this lint detector for the given issue type, * returns the old value to be replaced in the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding old value, or null if not recognized */ @Nullable public static String getOldValue(@NonNull String errorMessage, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(errorMessage), " tag <", ">"); }
/** * Given an error message created by this lint check, return the corresponding * resource field name for the resource that is described as unused. * (Intended to support quickfix implementations for this lint check.) * * @param errorMessage the error message originally produced by this detector * @param format the format of the error message * @return the corresponding resource field name, e.g. {@code R.string.foo} */ @Nullable public static String getUnusedResource(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return findSubstring(errorMessage, "The resource ", " appears "); }
/** * Given an error message produced by this lint detector for the given issue type, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull String errorMessage, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(errorMessage), " should be <", ">"); } }
/** * Given an error message produced by this lint detector for the given issue type, * returns the old value to be replaced in the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding old value, or null if not recognized */ @Nullable public static String getOldValue(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, "than \"", "\""); }
/** * Given an error message produced by this lint detector for the given issue type, * returns the old value to be replaced in the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding old value, or null if not recognized */ @Nullable public static String getOldValue(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, "than \"", "\""); }
/** * Given an error message produced by this lint detector for the given issue type, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull String errorMessage, @NonNull TextFormat format) { return LintUtils.findSubstring(format.toText(errorMessage), " should be <", ">"); } }
/** * Given an error message produced by this lint detector for the given issue type, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, "call \"", "\""); } }
/** * Given an error message produced by this lint detector, returns the suggested * super class fully qualified name. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding super class name, or null if not found */ @Nullable public static String getSuggestedSuperClass(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return findSubstring(errorMessage, "extend ", " instead"); } }
/** * Given an error message produced by this lint detector for the given issue type, * returns the old value to be replaced in the source code. * <p> * Intended for IDE quickfix implementations. * * @param issue the corresponding issue * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding old value, or null if not recognized */ @Nullable public static String getOldValue(@NonNull Issue issue, @NonNull String errorMessage, @NonNull TextFormat format) { if (issue == INNERCLASS) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, " replace \"", "\""); } return null; }
/** * Given an error message produced by this lint detector for the given issue type, * returns the old value to be replaced in the source code. * <p> * Intended for IDE quickfix implementations. * * @param issue the corresponding issue * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding old value, or null if not recognized */ @Nullable public static String getOldValue(@NonNull Issue issue, @NonNull String errorMessage, @NonNull TextFormat format) { if (issue == INNERCLASS) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, " replace \"", "\""); } return null; }
/** * Given an error message produced by this lint detector for the given issue type, * returns the new value to be put into the source code. * <p> * Intended for IDE quickfix implementations. * * @param issue the corresponding issue * @param errorMessage the error message associated with the error * @param format the format of the error message * @return the corresponding new value, or null if not recognized */ @Nullable public static String getNewValue(@NonNull Issue issue, @NonNull String errorMessage, @NonNull TextFormat format) { if (issue == INNERCLASS) { errorMessage = format.toText(errorMessage); return LintUtils.findSubstring(errorMessage, " with \"", "\""); } return null; } }