@@ -390,41 +390,46 @@ public IBinding getBinding(final Symbol owner, final com.sun.tools.javac.code.Ty
390390 }
391391 return null ;
392392 }
393+
394+ private IBinding filterCollectionFindKey (Collection <? extends IBinding > vals , String key ) {
395+ return vals .stream ()
396+ .filter (b -> key .equals (b .getKey ()))
397+ .findAny ()
398+ .orElse (null );
399+ }
400+
393401 public IBinding getBinding (String key ) {
402+ // This is now very very inefficient. Yuck.
394403 IBinding binding ;
395- binding = this .annotationBindings .get ( key );
404+ binding = filterCollectionFindKey ( this .annotationBindings .values (), key );
396405 if (binding != null ) {
397406 return binding ;
398407 }
399- binding = this .memberValuePairBindings .get ( key );
408+ binding = filterCollectionFindKey ( this .memberValuePairBindings .values (), key );
400409 if (binding != null ) {
401410 return binding ;
402411 }
403- binding = this .methodBindings .values ()
404- .stream ()
405- .filter (methodBindings -> key .equals (methodBindings .getKey ()))
406- .findAny ()
407- .orElse (null );
412+ binding = filterCollectionFindKey (this .methodBindings .values (), key );
408413 if (binding != null ) {
409414 return binding ;
410415 }
411- binding = this .moduleBindings .get ( key );
416+ binding = filterCollectionFindKey ( this .moduleBindings .values (), key );
412417 if (binding != null ) {
413418 return binding ;
414419 }
415- binding = this .packageBindings .get ( key );
420+ binding = filterCollectionFindKey ( this .packageBindings .values (), key );
416421 if (binding != null ) {
417422 return binding ;
418423 }
419- binding = new ArrayList <> (this .typeBinding .values ())
420- . stream ()
421- . filter ( typeBinding -> key . equals ( typeBinding . getKey ()))
422- . findAny ()
423- . orElse ( null );
424+ binding = filterCollectionFindKey (this .typeBinding .values (), key );
425+ if ( binding != null ) {
426+ return binding ;
427+ }
428+ binding = filterCollectionFindKey ( this . typeVariableBindings . values (), key );
424429 if (binding != null ) {
425430 return binding ;
426431 }
427- return this .variableBindings .get ( key );
432+ return filterCollectionFindKey ( this .variableBindings .values (), key );
428433 }
429434 }
430435 public final Bindings bindings = new Bindings ();
0 commit comments