@@ -122,7 +122,7 @@ public void configure(Map<String, Object> configuration) {
122
122
minWordLength = Math .max (minWordLength , DEFAULT_MIN_WORD_LENGTH );
123
123
}
124
124
125
- private Set <String > getWordsToIgnore () {
125
+ private List <String > getWordsToIgnore () {
126
126
var delimiter = "," ;
127
127
String exceptions = SPACES_PATTERN .matcher (info .getResourceString ("diagnosticExceptions" )).replaceAll ("" );
128
128
if (!userWordsToIgnore .isEmpty ()) {
@@ -134,7 +134,7 @@ private Set<String> getWordsToIgnore() {
134
134
}
135
135
136
136
return Arrays .stream (exceptions .split (delimiter ))
137
- .collect (Collectors .toSet ());
137
+ .collect (Collectors .toList ());
138
138
}
139
139
140
140
private static JLanguageTool acquireLanguageTool (String lang ) {
@@ -148,7 +148,7 @@ private static void releaseLanguageTool(String lang, JLanguageTool languageTool)
148
148
private Map <String , List <Token >> getTokensMap (
149
149
DocumentContext documentContext
150
150
) {
151
- Set <String > wordsToIgnore = getWordsToIgnore ();
151
+ List <String > wordsToIgnore = getWordsToIgnore ();
152
152
Map <String , List <Token >> tokensMap = new HashMap <>();
153
153
154
154
Trees .findAllRuleNodes (documentContext .getAst (), rulesToFind ).stream ()
@@ -160,18 +160,12 @@ private Map<String, List<Token>> getTokensMap(
160
160
String curText = QUOTE_PATTERN .matcher (token .getText ()).replaceAll ("" ).trim ();
161
161
String [] camelCaseSplitWords = StringUtils .splitByCharacterTypeCamelCase (curText );
162
162
163
- var camelCaseSplitWordsStream = Arrays .stream (camelCaseSplitWords );
164
-
165
- if (caseInsensitive ) {
166
- camelCaseSplitWordsStream = camelCaseSplitWordsStream
167
- .distinct ()
168
- .map (String ::toLowerCase );
169
- }
170
-
171
- camelCaseSplitWordsStream
163
+ Arrays .stream (camelCaseSplitWords )
172
164
.filter (Predicate .not (String ::isBlank ))
173
165
.filter (element -> element .length () >= minWordLength )
174
- .filter (Predicate .not (wordsToIgnore ::contains ))
166
+ .filter (element -> wordsToIgnore .stream ().noneMatch (word
167
+ -> (caseInsensitive && word .equalsIgnoreCase (element ))
168
+ || (!caseInsensitive && word .equals (element ))))
175
169
.forEach (element -> tokensMap .computeIfAbsent (element , newElement -> new ArrayList <>()).add (token ));
176
170
}
177
171
);
0 commit comments