private static int removeExtraSemicolon(ParameterInfo info, int offset, StringBuilder result, MatchResult match) {
    if (!info.isStatementContext()) {
      return offset;
    }
    final int index = offset + info.getStartIndex();
    if (result.charAt(index) != ';') {
      return offset;
    }
    final PsiElement matchElement;
    if (match == null) matchElement = null;
    else if (match.isMultipleMatch()) matchElement = match.getChildren().get(match.size() - 1).getMatch();
    else matchElement = match.getMatch();

    if (matchElement == null || matchElement instanceof PsiComment ||
        result.charAt(index - 1) == '}' &&
        !(matchElement instanceof PsiDeclarationStatement) && // array init in dcl
        !(matchElement instanceof PsiNewExpression) && // array initializer
        !(matchElement instanceof PsiArrayInitializerExpression)) {
      result.deleteCharAt(index);
      --offset;
    }
    return offset;
  }
private static int removeExtraSemicolon(ParameterInfo info, int offset, StringBuilder result, MatchResult match)