private void writeSuppressInfo() throws IOException { //getSuppressHelp writer.write("\n<a name=\"SuppressInfo\"></a>\n"); writer.write("<div class=\"category\">"); writer.write("Suppressing Warnings and Errors"); writer.write("<div class=\"categorySeparator\"></div>\n"); writer.write("</div>\n"); writer.write(TextFormat.RAW.convertTo(Main.getSuppressHelp(), TextFormat.HTML)); writer.write('\n'); }
public static int getRequiredVersion(@NonNull Issue issue, @NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); if (issue == UNSUPPORTED || issue == INLINED) { Pattern pattern = Pattern.compile("\\s(\\d+)\\s"); Matcher matcher = pattern.matcher(errorMessage); if (matcher.find()) { return Integer.parseInt(matcher.group(1)); } } return -1; }
if (end != -1 && (end == n - 1 || !Character.isLetter(text.charAt(end + 1)))) { if (i > flushIndex) { appendEscapedText(sb, text, html, flushIndex, i, escapeUnicode); appendEscapedText(sb, text, html, i + 1, end, escapeUnicode); sb.append('<').append('/').append(tag).append('>'); } else { appendEscapedText(sb, text, html, i + 1, end, escapeUnicode); appendEscapedText(sb, text, html, flushIndex, i, escapeUnicode); appendEscapedText(sb, text, html, flushIndex, n, escapeUnicode);
case HTML: case HTML_WITH_UNICODE: return to.fromRaw(message); return message; case HTML_WITH_UNICODE: return removeNumericEntities(message); case RAW: case TEXT: { return to.fromHtml(message); case RAW: case TEXT: { return to.fromHtml(message);
private static void printHelpTopicSuppress() { System.out.println(wrap(TextFormat.RAW.convertTo(getSuppressHelp(), TextFormat.TEXT))); }
public static int getRequiredVersion(@NonNull Issue issue, @NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); if (issue == UNSUPPORTED || issue == INLINED) { Pattern pattern = Pattern.compile("\\s(\\d+)\\s"); //$NON-NLS-1$ Matcher matcher = pattern.matcher(errorMessage); if (matcher.find()) { return Integer.parseInt(matcher.group(1)); } } return -1; }
/** * Briefly (in a couple of words) describes these errors * * @return a brief summary of the issue, never null, never empty */ @NonNull public String getBriefDescription(@NonNull TextFormat format) { return RAW.convertTo(briefDescription, format); }
/** * Given an error message produced by this lint detector for the given issue type, * determines whether this corresponds to the warning (produced by * {link {@link #reportBaselineIssues(LintDriver, Project)} above) that one or * more issues have been filtered out. * <p> * Intended for IDE quickfix implementations. */ @SuppressWarnings("unused") // Used from the IDE public static boolean isFilteredMessage(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return errorMessage.contains("were filtered out"); }
/** * Converts the given text to HTML * * @param text the text to format * @return the corresponding text formatted as HTML */ @NonNull public String toHtml(@NonNull String text) { return convertTo(text, HTML); }
/** * Given an error message produced by this lint detector for the given issue type, * determines whether this corresponds to the warning (produced by * {link {@link #reportBaselineIssues(LintDriver, Project)} above) that one or * more issues have been fixed (present in baseline but not in project.) * <p> * Intended for IDE quickfix implementations. */ @SuppressWarnings("unused") // Used from the IDE public static boolean isFixedMessage(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); return errorMessage.contains("perhaps they have been fixed"); }
/** * Converts the given text to plain text * * @param text the tetx to format * @return the corresponding text formatted as HTML */ @NonNull public String toText(@NonNull String text) { return convertTo(text, TEXT); }
/** * For an error message for an {@link #USE_VALUE_OF} issue reported by this detector, * returns the type being replaced. Intended to use for IDE quickfix implementations. */ @Nullable public static String getReplacedType(@NonNull String message, @NonNull TextFormat format) { message = format.toText(message); int index = message.indexOf('.'); if (index != -1 && message.startsWith("Use ")) { return message.substring(4, index); } return null; }
/** * Describes the error found by this rule, e.g. * "Buttons must define contentDescriptions". Preferably the explanation * should also contain a description of how the problem should be solved. * Additional info can be provided via {@link #getMoreInfo()}. * * @param format the format to write the format as * @return an explanation of the issue, never null, never empty */ @NonNull public String getExplanation(@NonNull TextFormat format) { return RAW.convertTo(explanation, format); }
/** * For an error message for an {@link #USE_VALUE_OF} issue reported by this detector, * returns the type being replaced. Intended to use for IDE quickfix implementations. */ @SuppressWarnings("unused") // Used by the IDE @Nullable public static String getReplacedType(@NonNull String message, @NonNull TextFormat format) { message = format.toText(message); int index = message.indexOf('.'); if (index != -1 && message.startsWith("Use ")) { return message.substring(4, index); } return null; }
/** * Given an error message produced by this lint detector for the given issue type, * returns whether it represents a suggestion update the library version. * <p> * Intended for IDE quickfix implementations. * * @param errorMessage the error message associated with the error * @param format the format of the error message * @return true if this is a suggestion to update the version */ @SuppressWarnings("unused") public static boolean isUpgradeDependencyError( @NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.convertTo(errorMessage, RAW); return errorMessage.contains(" of the constraint library, which is obsolete"); } }
/** * Returns the typo word in the error message from this detector * * @param errorMessage the error message produced earlier by this detector * @param format the format of the error message * @return the typo */ @Nullable public static String getTypo(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); // The words are all in quotes int index = errorMessage.indexOf('"'); int start = index + 1; index = errorMessage.indexOf('"', start); if (index != -1) { return errorMessage.substring(start, index); } return null; } }
/** * Returns true if the error message (which should have been produced by this detector) * corresponds to the method listed <b>on</b> a property method that it's missing a * Keep annotation. Used by IDE quickfixes to only add keep annotations on the actual * keep method, not on the error message (with the same inspection id) shown on the * object animator. * * @param message the original message produced by lint * @param textFormat the format it's been provided in * @return true if this is a message on a property method missing {@code @Keep} */ @SuppressWarnings("unused") // Referenced from IDE public static boolean isAddKeepErrorMessage(@NonNull String message, @NonNull TextFormat textFormat) { message = textFormat.convertTo(message, TextFormat.RAW); return message.contains("This method is accessed from an ObjectAnimator so"); }
public static List<String> getSuggestions(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage);
@Nullable private static String getMessagePart(@NonNull String errorMessage, int group, @NonNull TextFormat format) { List<String> parameters = LintUtils.getFormattedParameters( RAW.convertTo(ERROR_MESSAGE_FORMAT, format), errorMessage); if (parameters.size() == 2 && group <= 2) { return parameters.get(group - 1); } return null; } }
/** * Returns the typo word in the error message from this detector * * @param errorMessage the error message produced earlier by this detector * @param format the format of the error message * @return the typo */ @Nullable public static String getTypo(@NonNull String errorMessage, @NonNull TextFormat format) { errorMessage = format.toText(errorMessage); // The words are all in quotes int index = errorMessage.indexOf('"'); int start = index + 1; index = errorMessage.indexOf('"', start); if (index != -1) { return errorMessage.substring(start, index); } return null; } }