private static void printMatches ( List < RuleMatch > ruleMatches , int prevMatches , String contents , int contextSize ) { int i = 1 ; ContextTools contextTools = new ContextTools ( ) ; contextTools . setContextSize ( contextSize ) ; for ( RuleMatch match : ruleMatches ) { Rule rule = match . getRule ( ) ; String output = i + prevMatches + ".) Line " + ( match . getLine ( ) + 1 ) + ", column " + match . getColumn ( ) + ", Rule ID: " + rule . getId ( ) ; if ( rule instanceof AbstractPatternRule ) { AbstractPatternRule pRule = ( AbstractPatternRule ) rule ; if ( pRule . getSubId ( ) != null ) { output += "[" + pRule . getSubId ( ) + "]" ; } } System . out . println ( output ) ; String msg = match . getMessage ( ) ; msg = msg . replaceAll ( "</?suggestion>" , "'" ) ; System . out . println ( "Message: " + msg ) ; List < String > replacements = match . getSuggestedReplacements ( ) ; if ( ! replacements . isEmpty ( ) ) { System . out . println ( "Suggestion: " + String . join ( "; " , replacements ) ) ; } System . out . println ( contextTools . getPlainTextContext ( match . getFromPos ( ) , match . getToPos ( ) , contents ) ) ; if ( match . getUrl ( ) != null ) { System . out . println ( "More info: " + match . getUrl ( ) ) ; } else if ( rule . getUrl ( ) != null ) { System . out . println ( "More info: " + rule . getUrl ( ) ) ; } if ( i < ruleMatches . size ( ) ) { System . out . println ( ) ; } i ++ ; } }
Displays matches in a simple text format .