Source:
public void beginTree(DetailAST aRootAST) { if (!run){ return; } if (!getFileContents().getFileName().matches(".*\\.java")) { return; } if (getFileContents().getFileName().contains("generated-sources")) { return; } int i = 0; boolean startAnnotation = false; for (String lineText : getLines()) { ++i; if (lineText.matches("^\\s*@.*")) { int parenthesesStart = lineText.indexOf("("); while (parenthesesStart != -1 && getFileContents().hasIntersectionWithComment(i, parenthesesStart, i, parenthesesStart)){ parenthesesStart = lineText.indexOf("(", parenthesesStart + 1); } if (parenthesesStart != -1){ startAnnotation = true; } } List<QuotedString> stringList = new LinkedList<>(); Matcher matcher = patternString.matcher(lineText); while (matcher.find()) { if (getFileContents().hasIntersectionWithComment(i, matcher.start(), i, matcher.end())) { continue; } stringList.add(new QuotedString(matcher.group(), matcher .start(), matcher.end())); } if (startAnnotation) { int endAnno = hasEndAnno(lineText, i, stringList); if (endAnno != -1) { startAnnotation = false; List<QuotedString> tmpStringList = new LinkedList<>(); for (QuotedString quotedString : stringList) { if (quotedString.startIndex > endAnno) { tmpStringList.add(quotedString); } } stringList = tmpStringList; } else { continue; } } int j = 0; for (QuotedString str : stringList) { ++j; Pattern patternNls = Pattern.compile("\\$NON-NLS-" + j + "\\$"); Matcher matcherNls = patternNls.matcher(lineText); int matchNum = 0; while (matcherNls.find()) { ++matchNum; } if (matchNum != 1) { log(i, "String on line " + i + " is non-localized." + "\n Please localize it via Constants/Messages interface or add } } } }

Target:
public void beginTree(DetailAST aRootAST) { if (!run){ return; } if (!getFileContents().getFileName().matches(".*\\.java")) { return; } int i = 0; boolean startAnnotation = false; for (String lineText : getLines()) { ++i; if (lineText.matches("^\\s*@.*")) { int parenthesesStart = lineText.indexOf("("); while (parenthesesStart != -1 && getFileContents().hasIntersectionWithComment(i, parenthesesStart, i, parenthesesStart)){ parenthesesStart = lineText.indexOf("(", parenthesesStart + 1); } if (parenthesesStart != -1){ startAnnotation = true; } } List<QuotedString> stringList = new LinkedList<>(); Matcher matcher = patternString.matcher(lineText); while (matcher.find()) { if (getFileContents().hasIntersectionWithComment(i, matcher.start(), i, matcher.end())) { continue; } stringList.add(new QuotedString(matcher.group(), matcher.start(), matcher.end())); } if (startAnnotation) { int endAnno = hasEndAnno(lineText, i, stringList); if (endAnno != -1) { startAnnotation = false; List<QuotedString> tmpStringList = new LinkedList<>(); for (QuotedString quotedString : stringList) { if (quotedString.startIndex > endAnno) { tmpStringList.add(quotedString); } } stringList = tmpStringList; } else { continue; } } int j = 0; for (QuotedString str : stringList) { ++j; Pattern patternNls = Pattern.compile("\\$NON-NLS-" + j + "\\$"); Matcher matcherNls = patternNls.matcher(lineText); int matchNum = 0; while (matcherNls.find()) { ++matchNum; } if (matchNum != 1) { log(i, "String on line " + i + " (at index " + str.startIndex + ") is non-localized.\n" + "Please localize it via Constants/Messages interface " + "or use } } } }