class DonarTempsSuggestionsFilter extends RuleFilter {

  static private CatalanSynthesizer synth = CatalanSynthesizer.INSTANCE;

  @Override
  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, int patternTokenPos,
                                   AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) throws IOException {<FILL_FUNCTION_BODY>}

  private String getLanguageVariantCode(RuleMatch match) {
    PatternRule pr = (PatternRule) match.getRule();
    return pr.getLanguage().getShortCodeWithCountryAndVariant();
  }
}

    int posWord = 0;
    AnalyzedTokenReadings[] tokens = match.getSentence().getTokensWithoutWhitespace();
    while (posWord < tokens.length
        && (tokens[posWord].getStartPos() < match.getFromPos() || tokens[posWord].isSentenceStart())) {
      posWord++;
    }
    String pronomPostag = tokens[posWord].readingWithTagRegex("P.*").getPOSTag();
    String pronomGenderNumber = pronomPostag.substring(2, 3) + pronomPostag.substring(4, 5);
    int indexFirstVerb = posWord + 1;
    int indexMainVerb = indexFirstVerb;
    while (!tokens[indexMainVerb].hasAnyLemma("donar")) {
      indexMainVerb++;
    }
    String verbPostag = tokens[indexMainVerb].readingWithTagRegex("V.*").getPOSTag();

    // haver-hi temps
    AnalyzedToken at = new AnalyzedToken("", "", "haver");
    String[] synthForms = synth.synthesize(at, "VA" + verbPostag.substring(2, 8),
        getLanguageVariantCode(match));
    StringBuilder suggestion1 = new StringBuilder();
    if (synthForms.length > 0) {
      int index = indexFirstVerb;
      suggestion1.append("hi");
      while (index < indexMainVerb) {
        if (tokens[index].isWhitespaceBefore() || suggestion1.length()==2) {
          suggestion1.append(" ");
        }
        suggestion1.append(tokens[index].getToken());
        index++;
      }
      suggestion1.append(" "+ synthForms[0] + " temps");
    }
    List<String> replacements = new ArrayList<>();
    String sugg1 = suggestion1.toString().replace("de haver", "d'haver");
    sugg1 = StringTools.preserveCase(sugg1, tokens[posWord].getToken());
    if (!sugg1.isEmpty()) {
      replacements.add(sugg1);
    }

    // tenir temps
    StringBuilder suggestion2 = new StringBuilder();
    int index = indexFirstVerb;
    if (index == indexMainVerb) {
      String[] synthForms2 = synth.synthesize(new AnalyzedToken("", "", "tenir"),
        verbPostag.substring(0, 4) + pronomGenderNumber + verbPostag.substring(6, 8), getLanguageVariantCode(match));
      if (synthForms2.length > 0) {
        suggestion2.append(synthForms2[0] + " temps");
      }
    } else {
      AnalyzedToken at2 = tokens[indexFirstVerb].getAnalyzedToken(0);
      String[] synthForms2 = synth.synthesize( at2,
        at2.getPOSTag().substring(0, 4) + pronomGenderNumber + at2.getPOSTag().substring(6, 8), getLanguageVariantCode(match));
      if (synthForms2.length > 0) {
        suggestion2.append(synthForms2[0]);
        index++;
        while (index < indexMainVerb) {
          if (tokens[index].isWhitespaceBefore()) {
            suggestion2.append(" ");
          }
          suggestion2.append(tokens[index].getToken());
          index++;
        }
        String[] synthForms3 = synth.synthesize( new AnalyzedToken("", "", "tenir"),
          tokens[indexMainVerb].getAnalyzedToken(0).getPOSTag(), getLanguageVariantCode(match));
        if (synthForms3.length > 0) {
          suggestion2.append(" " + synthForms3[0] + " temps");
        } else {
          suggestion2 = new StringBuilder();
        }
      }
    }
    String sugg2 = suggestion2.toString();
    sugg2 = StringTools.preserveCase(sugg2, tokens[posWord].getToken());
    if (!sugg2.isEmpty()) {
      replacements.add(sugg2);
    }
    if (replacements.isEmpty()) {
      return null;
    }
    RuleMatch ruleMatch = new RuleMatch(match.getRule(), match.getSentence(), tokens[posWord].getStartPos(),
        tokens[indexMainVerb + 1].getEndPos(), match.getMessage(), match.getShortMessage());
    ruleMatch.setType(match.getType());
    ruleMatch.setSuggestedReplacements(replacements);
    return ruleMatch;
  
<methods>public non-sealed void <init>() ,public abstract org.languagetool.rules.RuleMatch acceptRuleMatch(org.languagetool.rules.RuleMatch, Map<java.lang.String,java.lang.String>, int, org.languagetool.AnalyzedTokenReadings[], List<java.lang.Integer>) throws java.io.IOException,public boolean matches(Map<java.lang.String,java.lang.String>, org.languagetool.AnalyzedTokenReadings[], int, List<java.lang.Integer>) throws java.io.IOException<variables>