private static String getMessage(TokenWithTypeInfo token1, TokenWithTypeInfo token2) { return String.format( MESSAGE, token2.getType(), token2.getValue(), token1.getType(), token1.getValue(), token1.getLine()); }
private void lookForDuplications(List<Token> fieldNames, List<Token> methodNames) { List<TokenWithTypeInfo> allTokensWithInfo = mergeLists(fieldNames, methodNames); Collections.sort(allTokensWithInfo, new LineComparator()); for (int i = 1; i < allTokensWithInfo.size(); i++) { for (int j = i - 1; j >= 0; j--) { TokenWithTypeInfo token1 = allTokensWithInfo.get(j); TokenWithTypeInfo token2 = allTokensWithInfo.get(i); if (differOnlyByCapitalization(token1.getValue(), token2.getValue())) { addIssue(token2.token, getMessage(token1, token2)) .secondary(new AstNode(token1.token), "Original"); break; } } } }
@Override public int compare(TokenWithTypeInfo t1, TokenWithTypeInfo t2) { return Integer.compare(t1.getLine(), t2.getLine()); }