11/*
2- * Copyright (c) 1999, 2018 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1999, 2021 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2929import java .lang .ref .WeakReference ;
3030import java .util .*;
3131import java .util .function .BiConsumer ;
32+ import java .util .function .Predicate ;
3233
3334import com .sun .tools .javac .code .Symbol .CompletionFailure ;
3435import com .sun .tools .javac .code .Symbol .TypeSymbol ;
@@ -70,7 +71,7 @@ public final Iterable<Symbol> getSymbols() {
7071
7172 /**Returns Symbols that match the given filter. Symbols from outward Scopes are included.
7273 */
73- public final Iterable <Symbol > getSymbols (Filter <Symbol > sf ) {
74+ public final Iterable <Symbol > getSymbols (Predicate <Symbol > sf ) {
7475 return getSymbols (sf , RECURSIVE );
7576 }
7677
@@ -84,7 +85,7 @@ public final Iterable<Symbol> getSymbols(LookupKind lookupKind) {
8485 /**Returns Symbols that match the given filter. Symbols from outward Scopes are included
8586 * iff lookupKind == RECURSIVE.
8687 */
87- public abstract Iterable <Symbol > getSymbols (Filter <Symbol > sf , LookupKind lookupKind );
88+ public abstract Iterable <Symbol > getSymbols (Predicate <Symbol > sf , LookupKind lookupKind );
8889
8990 /**Returns Symbols with the given name. Symbols from outward Scopes are included.
9091 */
@@ -95,7 +96,7 @@ public final Iterable<Symbol> getSymbolsByName(Name name) {
9596 /**Returns Symbols with the given name that match the given filter.
9697 * Symbols from outward Scopes are included.
9798 */
98- public final Iterable <Symbol > getSymbolsByName (final Name name , final Filter <Symbol > sf ) {
99+ public final Iterable <Symbol > getSymbolsByName (final Name name , final Predicate <Symbol > sf ) {
99100 return getSymbolsByName (name , sf , RECURSIVE );
100101 }
101102
@@ -109,7 +110,7 @@ public final Iterable<Symbol> getSymbolsByName(Name name, LookupKind lookupKind)
109110 /**Returns Symbols with the given name that match the given filter.
110111 * Symbols from outward Scopes are included iff lookupKind == RECURSIVE.
111112 */
112- public abstract Iterable <Symbol > getSymbolsByName (final Name name , final Filter <Symbol > sf ,
113+ public abstract Iterable <Symbol > getSymbolsByName (final Name name , final Predicate <Symbol > sf ,
113114 final LookupKind lookupKind );
114115
115116 /** Return the first Symbol from this or outward scopes with the given name.
@@ -122,15 +123,15 @@ public final Symbol findFirst(Name name) {
122123 /** Return the first Symbol from this or outward scopes with the given name that matches the
123124 * given filter. Returns null if none.
124125 */
125- public Symbol findFirst (Name name , Filter <Symbol > sf ) {
126+ public Symbol findFirst (Name name , Predicate <Symbol > sf ) {
126127 Iterator <Symbol > it = getSymbolsByName (name , sf ).iterator ();
127128 return it .hasNext () ? it .next () : null ;
128129 }
129130
130131 /** Returns true iff there are is at least one Symbol in this scope matching the given filter.
131132 * Does not inspect outward scopes.
132133 */
133- public boolean anyMatch (Filter <Symbol > filter ) {
134+ public boolean anyMatch (Predicate <Symbol > filter ) {
134135 return getSymbols (filter , NON_RECURSIVE ).iterator ().hasNext ();
135136 }
136137
@@ -160,7 +161,7 @@ public boolean isEmpty() {
160161 */
161162 public abstract boolean isStaticallyImported (Symbol byName );
162163
163- private static final Filter <Symbol > noFilter = null ;
164+ private static final Predicate <Symbol > noFilter = null ;
164165
165166 /** A list of scopes to be notified if items are to be removed from this scope.
166167 */
@@ -514,16 +515,16 @@ protected Entry lookup(Name name) {
514515 return lookup (name , noFilter );
515516 }
516517
517- protected Entry lookup (Name name , Filter <Symbol > sf ) {
518+ protected Entry lookup (Name name , Predicate <Symbol > sf ) {
518519 Entry e = table [getIndex (name )];
519520 if (e == null || e == sentinel )
520521 return sentinel ;
521- while (e .scope != null && (e .sym .name != name || (sf != null && !sf .accepts (e .sym ))))
522+ while (e .scope != null && (e .sym .name != name || (sf != null && !sf .test (e .sym ))))
522523 e = e .shadowed ;
523524 return e ;
524525 }
525526
526- public Symbol findFirst (Name name , Filter <Symbol > sf ) {
527+ public Symbol findFirst (Name name , Predicate <Symbol > sf ) {
527528 return lookup (name , sf ).sym ;
528529 }
529530
@@ -563,11 +564,11 @@ int getIndex (Name name) {
563564 }
564565 }
565566
566- public boolean anyMatch (Filter <Symbol > sf ) {
567+ public boolean anyMatch (Predicate <Symbol > sf ) {
567568 return getSymbols (sf , NON_RECURSIVE ).iterator ().hasNext ();
568569 }
569570
570- public Iterable <Symbol > getSymbols (final Filter <Symbol > sf ,
571+ public Iterable <Symbol > getSymbols (final Predicate <Symbol > sf ,
571572 final LookupKind lookupKind ) {
572573 return () -> new Iterator <Symbol >() {
573574 private ScopeImpl currScope = ScopeImpl .this ;
@@ -616,15 +617,15 @@ private void update() {
616617 }
617618
618619 void skipToNextMatchingEntry () {
619- while (currEntry != null && sf != null && !sf .accepts (currEntry .sym )) {
620+ while (currEntry != null && sf != null && !sf .test (currEntry .sym )) {
620621 currEntry = currEntry .nextSibling ;
621622 }
622623 }
623624 };
624625 }
625626
626627 public Iterable <Symbol > getSymbolsByName (final Name name ,
627- final Filter <Symbol > sf ,
628+ final Predicate <Symbol > sf ,
628629 final LookupKind lookupKind ) {
629630 return () -> new Iterator <Symbol >() {
630631 Entry currentEntry = lookup (name , sf );
@@ -729,8 +730,8 @@ public Entry next() {
729730 return shadowed ;
730731 }
731732
732- public Entry next (Filter <Symbol > sf ) {
733- if (shadowed .sym == null || sf == null || sf .accepts (shadowed .sym )) return shadowed ;
733+ public Entry next (Predicate <Symbol > sf ) {
734+ if (shadowed .sym == null || sf == null || sf .test (shadowed .sym )) return shadowed ;
734735 else return shadowed .next (sf );
735736 }
736737
@@ -815,7 +816,7 @@ private Scope appendScope(Scope newScope, Name name) {
815816 }
816817
817818 @ Override
818- public Iterable <Symbol > getSymbolsByName (Name name , Filter <Symbol > sf , LookupKind lookupKind ) {
819+ public Iterable <Symbol > getSymbolsByName (Name name , Predicate <Symbol > sf , LookupKind lookupKind ) {
819820 Scope [] scopes = name2Scopes .get (name );
820821 if (scopes == null )
821822 return Collections .emptyList ();
@@ -848,16 +849,16 @@ public SingleEntryScope(Symbol owner, Symbol sym, Scope origin) {
848849 }
849850
850851 @ Override
851- public Iterable <Symbol > getSymbols (Filter <Symbol > sf , LookupKind lookupKind ) {
852- return sf == null || sf .accepts (sym ) ? content : Collections .emptyList ();
852+ public Iterable <Symbol > getSymbols (Predicate <Symbol > sf , LookupKind lookupKind ) {
853+ return sf == null || sf .test (sym ) ? content : Collections .emptyList ();
853854 }
854855
855856 @ Override
856857 public Iterable <Symbol > getSymbolsByName (Name name ,
857- Filter <Symbol > sf ,
858+ Predicate <Symbol > sf ,
858859 LookupKind lookupKind ) {
859860 return sym .name == name &&
860- (sf == null || sf .accepts (sym )) ? content : Collections .emptyList ();
861+ (sf == null || sf .test (sym )) ? content : Collections .emptyList ();
861862 }
862863
863864 @ Override
@@ -928,7 +929,7 @@ public FilterImportScope(Types types,
928929 }
929930
930931 @ Override
931- public Iterable <Symbol > getSymbols (final Filter <Symbol > sf , final LookupKind lookupKind ) {
932+ public Iterable <Symbol > getSymbols (final Predicate <Symbol > sf , final LookupKind lookupKind ) {
932933 if (filterName != null )
933934 return getSymbolsByName (filterName , sf , lookupKind );
934935 try {
@@ -951,7 +952,7 @@ Iterable<Symbol> doLookup(TypeSymbol tsym) {
951952
952953 @ Override
953954 public Iterable <Symbol > getSymbolsByName (final Name name ,
954- final Filter <Symbol > sf ,
955+ final Predicate <Symbol > sf ,
955956 final LookupKind lookupKind ) {
956957 if (filterName != null && filterName != name )
957958 return Collections .emptyList ();
@@ -1075,7 +1076,7 @@ public String toString() {
10751076 }
10761077
10771078 @ Override
1078- public Iterable <Symbol > getSymbols (final Filter <Symbol > sf ,
1079+ public Iterable <Symbol > getSymbols (final Predicate <Symbol > sf ,
10791080 final LookupKind lookupKind ) {
10801081 return () -> Iterators .createCompoundIterator (subScopes ,
10811082 scope -> scope .getSymbols (sf ,
@@ -1085,7 +1086,7 @@ public Iterable<Symbol> getSymbols(final Filter<Symbol> sf,
10851086
10861087 @ Override
10871088 public Iterable <Symbol > getSymbolsByName (final Name name ,
1088- final Filter <Symbol > sf ,
1089+ final Predicate <Symbol > sf ,
10891090 final LookupKind lookupKind ) {
10901091 return () -> Iterators .createCompoundIterator (subScopes ,
10911092 scope -> scope .getSymbolsByName (name ,
0 commit comments