@@ -211,10 +211,10 @@ protected HashSet<Container.Entry> getOuterEntries(Set<Container.Entry> matching
211211 }
212212
213213 protected void filter (Indexes indexes , String pattern , int flags , Set <Container .Entry > matchingEntries ) {
214- boolean declarations = ((flags & SearchInConstantPoolsView .SEARCH_TYPE_DECLARATION ) != 0 );
215- boolean references = ((flags & SearchInConstantPoolsView .SEARCH_TYPE_REFERENCE ) != 0 );
214+ boolean declarations = ((flags & SearchInConstantPoolsView .SEARCH_DECLARATION ) != 0 );
215+ boolean references = ((flags & SearchInConstantPoolsView .SEARCH_REFERENCE ) != 0 );
216216
217- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_TYPE ) != 0 ) {
217+ if ((flags & SearchInConstantPoolsView .SEARCH_TYPE ) != 0 ) {
218218 if (declarations )
219219 match (indexes , "typeDeclarations" , pattern ,
220220 SearchInConstantPoolsController ::matchTypeEntriesWithChar ,
@@ -225,7 +225,7 @@ protected void filter(Indexes indexes, String pattern, int flags, Set<Container.
225225 SearchInConstantPoolsController ::matchTypeEntriesWithString , matchingEntries );
226226 }
227227
228- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_CONSTRUCTOR ) != 0 ) {
228+ if ((flags & SearchInConstantPoolsView .SEARCH_CONSTRUCTOR ) != 0 ) {
229229 if (declarations )
230230 match (indexes , "constructorDeclarations" , pattern ,
231231 SearchInConstantPoolsController ::matchTypeEntriesWithChar ,
@@ -236,7 +236,7 @@ protected void filter(Indexes indexes, String pattern, int flags, Set<Container.
236236 SearchInConstantPoolsController ::matchTypeEntriesWithString , matchingEntries );
237237 }
238238
239- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_METHOD ) != 0 ) {
239+ if ((flags & SearchInConstantPoolsView .SEARCH_METHOD ) != 0 ) {
240240 if (declarations )
241241 match (indexes , "methodDeclarations" , pattern ,
242242 SearchInConstantPoolsController ::matchWithChar ,
@@ -247,7 +247,7 @@ protected void filter(Indexes indexes, String pattern, int flags, Set<Container.
247247 SearchInConstantPoolsController ::matchWithString , matchingEntries );
248248 }
249249
250- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_FIELD ) != 0 ) {
250+ if ((flags & SearchInConstantPoolsView .SEARCH_FIELD ) != 0 ) {
251251 if (declarations )
252252 match (indexes , "fieldDeclarations" , pattern ,
253253 SearchInConstantPoolsController ::matchWithChar ,
@@ -258,12 +258,23 @@ protected void filter(Indexes indexes, String pattern, int flags, Set<Container.
258258 SearchInConstantPoolsController ::matchWithString , matchingEntries );
259259 }
260260
261- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_STRING ) != 0 ) {
261+ if ((flags & SearchInConstantPoolsView .SEARCH_STRING ) != 0 ) {
262262 if (declarations || references )
263263 match (indexes , "strings" , pattern ,
264264 SearchInConstantPoolsController ::matchWithChar ,
265265 SearchInConstantPoolsController ::matchWithString , matchingEntries );
266266 }
267+
268+ if ((flags & SearchInConstantPoolsView .SEARCH_MODULE ) != 0 ) {
269+ if (declarations )
270+ match (indexes , "javaModuleDeclarations" , pattern ,
271+ SearchInConstantPoolsController ::matchWithChar ,
272+ SearchInConstantPoolsController ::matchWithString , matchingEntries );
273+ if (references )
274+ match (indexes , "javaModuleReferences" , pattern ,
275+ SearchInConstantPoolsController ::matchWithChar ,
276+ SearchInConstantPoolsController ::matchWithString , matchingEntries );
277+ }
267278 }
268279
269280 @ SuppressWarnings ("unchecked" )
@@ -275,29 +286,29 @@ protected void match(Indexes indexes, String indexName, String pattern,
275286
276287 if (patternLength > 0 ) {
277288 String key = String .valueOf (indexes .hashCode ()) + "***" + indexName + "***" + pattern ;
278- Map <String , Collection > matchedTypes = cache .get (key );
289+ Map <String , Collection > matchedEntries = cache .get (key );
279290
280- if (matchedTypes == null ) {
291+ if (matchedEntries == null ) {
281292 Map <String , Collection > index = indexes .getIndex (indexName );
282293
283294 if (patternLength == 1 ) {
284- matchedTypes = matchWithCharFunction .apply (pattern .charAt (0 ), index );
295+ matchedEntries = matchWithCharFunction .apply (pattern .charAt (0 ), index );
285296 } else {
286297 String lastKey = key .substring (0 , key .length () - 1 );
287298 Map <String , Collection > lastMatchedTypes = cache .get (lastKey );
288299 if (lastMatchedTypes != null ) {
289- matchedTypes = matchWithStringFunction .apply (pattern , lastMatchedTypes );
300+ matchedEntries = matchWithStringFunction .apply (pattern , lastMatchedTypes );
290301 } else {
291- matchedTypes = matchWithStringFunction .apply (pattern , index );
302+ matchedEntries = matchWithStringFunction .apply (pattern , index );
292303 }
293304 }
294305
295306 // Cache matchingEntries
296- cache .put (key , matchedTypes );
307+ cache .put (key , matchedEntries );
297308 }
298309
299- if (matchedTypes != null ) {
300- for (Collection <Container .Entry > entries : matchedTypes .values ()) {
310+ if (matchedEntries != null ) {
311+ for (Collection <Container .Entry > entries : matchedEntries .values ()) {
301312 matchingEntries .addAll (entries );
302313 }
303314 }
@@ -306,7 +317,7 @@ protected void match(Indexes indexes, String indexName, String pattern,
306317
307318 protected static Map <String , Collection > matchTypeEntriesWithChar (char c , Map <String , Collection > index ) {
308319 if ((c == '*' ) || (c == '?' )) {
309- return Collections . emptyMap () ;
320+ return index ;
310321 } else {
311322 Map <String , Collection > map = new HashMap <>();
312323
@@ -345,13 +356,13 @@ protected static Map<String, Collection> matchTypeEntriesWithString(String patte
345356
346357 protected static Map <String , Collection > matchWithChar (char c , Map <String , Collection > index ) {
347358 if ((c == '*' ) || (c == '?' )) {
348- return Collections . emptyMap () ;
359+ return index ;
349360 } else {
350361 Map <String , Collection > map = new HashMap <>();
351362
352- for (String typeName : index .keySet ()) {
353- if (!typeName .isEmpty () && (typeName .charAt (0 ) == c )) {
354- map .put (typeName , index .get (typeName ));
363+ for (String key : index .keySet ()) {
364+ if (!key .isEmpty () && (key .charAt (0 ) == c )) {
365+ map .put (key , index .get (key ));
355366 }
356367 }
357368
@@ -363,9 +374,9 @@ protected static Map<String, Collection> matchWithString(String pattern, Map<Str
363374 Pattern p = createPattern (pattern );
364375 Map <String , Collection > map = new HashMap <>();
365376
366- for (String typeName : index .keySet ()) {
367- if (p .matcher (typeName ).matches ()) {
368- map .put (typeName , index .get (typeName ));
377+ for (String key : index .keySet ()) {
378+ if (p .matcher (key ).matches ()) {
379+ map .put (key , index .get (key ));
369380 }
370381 }
371382
@@ -419,20 +430,22 @@ protected void onTypeSelected(URI uri, String pattern, int flags) {
419430 sbPattern .append (pattern );
420431 sbPattern .append ("&highlightFlags=" );
421432
422- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_DECLARATION ) != 0 )
433+ if ((flags & SearchInConstantPoolsView .SEARCH_DECLARATION ) != 0 )
423434 sbPattern .append ('d' );
424- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_REFERENCE ) != 0 )
435+ if ((flags & SearchInConstantPoolsView .SEARCH_REFERENCE ) != 0 )
425436 sbPattern .append ('r' );
426- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_TYPE ) != 0 )
437+ if ((flags & SearchInConstantPoolsView .SEARCH_TYPE ) != 0 )
427438 sbPattern .append ('t' );
428- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_CONSTRUCTOR ) != 0 )
439+ if ((flags & SearchInConstantPoolsView .SEARCH_CONSTRUCTOR ) != 0 )
429440 sbPattern .append ('c' );
430- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_METHOD ) != 0 )
441+ if ((flags & SearchInConstantPoolsView .SEARCH_METHOD ) != 0 )
431442 sbPattern .append ('m' );
432- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_FIELD ) != 0 )
443+ if ((flags & SearchInConstantPoolsView .SEARCH_FIELD ) != 0 )
433444 sbPattern .append ('f' );
434- if ((flags & SearchInConstantPoolsView .SEARCH_TYPE_STRING ) != 0 )
445+ if ((flags & SearchInConstantPoolsView .SEARCH_STRING ) != 0 )
435446 sbPattern .append ('s' );
447+ if ((flags & SearchInConstantPoolsView .SEARCH_MODULE ) != 0 )
448+ sbPattern .append ('M' );
436449
437450 // TODO In a future release, add 'highlightScope' to display search results in correct type and inner-type
438451 // def type = TypeFactoryService.instance.get(entry)?.make(api, entry, null)
0 commit comments