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'); }
/** * 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); }
private static void printHelpTopicSuppress() { System.out.println(wrap(TextFormat.RAW.convertTo(getSuppressHelp(), TextFormat.TEXT))); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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 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"); }
@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; } }
@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; } }
/** * Given an error message created by this lint check, return the corresponding featureName * that it suggests should be added. * (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 featureName, or null if not recognized */ @SuppressWarnings("unused") // Used by the IDE @Nullable public static String getHardwareFeature( @NonNull String errorMessage, @NonNull TextFormat format) { List<String> parameters = LintUtils.getFormattedParameters( RAW.convertTo(USES_HARDWARE_ERROR_MESSAGE_FORMAT, format), errorMessage); if (parameters.size() == 1) { return parameters.get(0); } return null; } }
/** * Given an error message created by this lint check, return the corresponding featureName * that it suggests should be added. * (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 featureName, or null if not recognized */ @SuppressWarnings("unused") // Used by the IDE @Nullable public static String getHardwareFeature(@NonNull String errorMessage, @NonNull TextFormat format) { List<String> parameters = LintUtils.getFormattedParameters( RAW.convertTo(USES_HARDWARE_ERROR_MESSAGE_FORMAT, format), errorMessage); if (parameters.size() == 1) { return parameters.get(0); } return null; } }
private void writeSuppressIssuesCard() { append("\n<a name=\"SuppressInfo\"></a>\n"); writeCard(() -> { append(TextFormat.RAW.convertTo(Main.getSuppressHelp(), TextFormat.HTML)); this.append('\n'); }, "Suppressing Warnings and Errors"); }
message = format.convertTo(message, TextFormat.RAW); Warning warning = new Warning(issue, message, severity, context.getProject()); warnings.add(warning);
message = format.convertTo(message, TextFormat.TEXT);
message = format.convertTo(message, TextFormat.TEXT);