class LTMessageChecker {

  private static final boolean SPELLCHECK_ONLY = false;
  private static final List<String> ruleExceptions = Arrays.asList("DE_CASE", "UPPERCASE_SENTENCE_START");
  
  public static void main(String[] args) throws Exception {
    if (args.length != 1) {
      System.out.println("Usage: " + LTMessageChecker.class.getSimpleName() + " <langCode> | ALL");
      System.exit(1);
    }
    LTMessageChecker check = new LTMessageChecker();
    long start = System.currentTimeMillis();
    if (args[0].equalsIgnoreCase("all")) {
      for (Language lang : Languages.get()) {
        check.run(lang);
      }
    } else {
      check.run(Languages.getLanguageForShortCode(args[0]));
    }
    float time = (float) ((System.currentTimeMillis() - start) / 1000.0);
    print("Total checking time: " + String.format("%.2f", time) + " seconds");
  }

  private static void print(String s) {
    System.out.println("LTM: " + s);
  }

  private void run(Language lang)
      throws IOException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {<FILL_FUNCTION_BODY>}
  
  void checkText(String textToCheck, JLanguageTool lt, Language lang, Rule r, ContextTools contextTools,
      boolean isCorrection) throws IOException {
    if (!textToCheck.isEmpty()) {
      List<RuleMatch> matches = lt.check(textToCheck);
      if (matches.size() > 0) {
        List<RuleMatch> matchesToShow = new ArrayList<>();
        for (RuleMatch match : matches) {
          String ruleId = match.getRule().getId();
          // exceptions for corrections
          if (isCorrection && ruleExceptions.contains(ruleId)) {
            continue;
          }
          if (!ruleId.equals(r.getId())) {
            matchesToShow.add(match);
          }
        }
        if (matchesToShow.size() > 0) {
          print("Source: " + r.getFullId());
          for (RuleMatch match : matchesToShow) {
            print(lang.toAdvancedTypography(match.getMessage()));
            print(contextTools.getContext(match.getFromPos(), match.getToPos(), textToCheck));
            print("");
          }
        }
      }
    }
  }

}


    long start = System.currentTimeMillis();
    JLanguageTool lt = new JLanguageTool(lang);
    ContextTools contextTools = new ContextTools();
    contextTools.setErrorMarker("**", "**");
    contextTools.setEscapeHtml(false);
    print("Checking language: " + lang.getName() + " (" + lang.getShortCodeWithCountryAndVariant() + ")");
    print("Version: " + JLanguageTool.VERSION + " (" + JLanguageTool.BUILD_DATE + ", " + JLanguageTool.GIT_SHORT_ID + ")");
    if (SPELLCHECK_ONLY) {
      int enabledRules = 0;
      print("NOTE: Running spell check only");
      for (Rule r : lt.getAllRules()) {
        if (!r.isDictionaryBasedSpellingRule()) {
          lt.disableRule(r.getId());
        } else {
          enabledRules++;
        }
      }
      if (enabledRules == 0) {
        System.out.println("Error: No rule found to enable. Make sure to use a language code like 'en-US' (not just 'en') that supports spell checking.");
        System.exit(1);
      }
    }
    for (Rule r : lt.getAllRules()) {
      String message = "";
      try {
        Method m = r.getClass().getMethod("getMessage", null);
        message = (String) m.invoke(r);
      } catch (NoSuchMethodException e) {
        // do nothing
      }
      String shortMessage = "";
      try {
        Method m = r.getClass().getMethod("getShortMessage", null);
        shortMessage = (String) m.invoke(r);
      } catch (NoSuchMethodException e) {
        // do nothing
      }
      if (!message.isEmpty()) {
        message = lang.toAdvancedTypography(message);
        message = message.replaceAll("<suggestion>", lang.getOpeningDoubleQuote()).replaceAll("</suggestion>",
            lang.getClosingDoubleQuote());
        message = message.replaceAll("<[^>]+>", "");
      }
      String corrections = "";
      for (IncorrectExample ie : r.getIncorrectExamples()) {
        corrections = corrections + String.join("; ", ie.getCorrections()) + "; ";
      }
      // don't require upper case sentence start in description (?)
      // Advanced typography in rule description is not used in production. Here is used to avoid too many positives.
      String ruleDescription = lang.toAdvancedTypography(StringTools.uppercaseFirstChar(r.getDescription()));
      String textToCheck = message + "\n\n" + shortMessage + "\n\n" + ruleDescription;
      checkText(textToCheck, lt, lang, r, contextTools, false);
      checkText(corrections, lt, lang, r, contextTools, true);
    }
    float time = (float) ((System.currentTimeMillis() - start) / 1000.0);
    print("Checked " + lang.getName() + " (" + lang.getShortCodeWithCountryAndVariant() + ") in "
        + String.format("%.2f", time) + " seconds");
  
<no_super_class>