2323import com .google .common .collect .ImmutableList ;
2424
2525import javax .annotation .Nullable ;
26+
2627import java .util .List ;
2728import java .util .Map ;
2829
@@ -134,23 +135,23 @@ private Resolution findVar(Env env, String name) {
134135 Resolution bestSoFar = unresolved ();
135136
136137 Env env1 = env ;
137- while (env1 .outer () != null ) {
138+ while (env1 .outer != null ) {
138139 Resolution sym = new Resolution ();
139- for (JavaSymbol symbol : env1 .scope () .lookup (name )) {
140+ for (JavaSymbol symbol : env1 .scope .lookup (name )) {
140141 if (symbol .kind == JavaSymbol .VAR ) {
141142 sym .symbol = symbol ;
142143 }
143144 }
144145 if (sym .symbol == null ) {
145- sym = findField (env1 , env1 .enclosingClass () , name , env1 .enclosingClass () );
146+ sym = findField (env1 , env1 .enclosingClass , name , env1 .enclosingClass );
146147 }
147148 if (sym .symbol .kind < JavaSymbol .ERRONEOUS ) {
148149 // symbol exists
149150 return sym ;
150151 } else if (sym .symbol .kind < bestSoFar .symbol .kind ) {
151152 bestSoFar = sym ;
152153 }
153- env1 = env1 .outer () ;
154+ env1 = env1 .outer ;
154155 }
155156
156157 JavaSymbol symbol = findInStaticImport (env , name , JavaSymbol .VAR );
@@ -170,12 +171,12 @@ private JavaSymbol findInStaticImport(Env env, String name, int kind) {
170171 JavaSymbol bestSoFar = symbolNotFound ;
171172 //imports
172173 //Ok because clash of name between type and var/method result in compile error: JLS8 7.5.3
173- for (JavaSymbol symbol : env .namedImports () .lookup (name )) {
174+ for (JavaSymbol symbol : env .namedImports .lookup (name )) {
174175 if ((kind & symbol .kind ) != 0 ) {
175176 return symbol ;
176177 }
177178 }
178- for (JavaSymbol symbol : env .staticStarImports () .lookup (name )) {
179+ for (JavaSymbol symbol : env .staticStarImports .lookup (name )) {
179180 if ((kind & symbol .kind ) != 0 ) {
180181 return symbol ;
181182 }
@@ -212,14 +213,14 @@ private JavaSymbol findMemberType(Env env, JavaSymbol.TypeJavaSymbol site, Strin
212213 */
213214 private JavaSymbol findType (Env env , String name ) {
214215 JavaSymbol bestSoFar = symbolNotFound ;
215- for (Env env1 = env ; env1 != null ; env1 = env1 .outer () ) {
216- for (JavaSymbol symbol : env1 .scope () .lookup (name )) {
216+ for (Env env1 = env ; env1 != null ; env1 = env1 .outer ) {
217+ for (JavaSymbol symbol : env1 .scope .lookup (name )) {
217218 if (symbol .kind == JavaSymbol .TYP ) {
218219 return symbol ;
219220 }
220221 }
221222 if (env1 .outer != null ) {
222- JavaSymbol symbol = findMemberType (env1 , env1 .enclosingClass () , name , env1 .enclosingClass () );
223+ JavaSymbol symbol = findMemberType (env1 , env1 .enclosingClass , name , env1 .enclosingClass );
223224 if (symbol .kind < JavaSymbol .ERRONEOUS ) {
224225 // symbol exists
225226 return symbol ;
@@ -237,25 +238,25 @@ private JavaSymbol findType(Env env, String name) {
237238
238239 //JLS8 6.4.1 Shadowing rules
239240 //named imports
240- for (JavaSymbol symbol : env .namedImports () .lookup (name )) {
241+ for (JavaSymbol symbol : env .namedImports .lookup (name )) {
241242 if (symbol .kind == JavaSymbol .TYP ) {
242243 return symbol ;
243244 }
244245 }
245246 //package types
246- JavaSymbol sym = findIdentInPackage (env .packge () , name , JavaSymbol .TYP );
247+ JavaSymbol sym = findIdentInPackage (env .packge , name , JavaSymbol .TYP );
247248 if (sym .kind < bestSoFar .kind ) {
248249 return sym ;
249250 }
250251 //on demand imports
251- for (JavaSymbol symbol : env .starImports () .lookup (name )) {
252+ for (JavaSymbol symbol : env .starImports .lookup (name )) {
252253 if (symbol .kind == JavaSymbol .TYP ) {
253254 return symbol ;
254255 }
255256 }
256257 //java.lang
257258 JavaSymbol .PackageJavaSymbol javaLang = bytecodeCompleter .enterPackage ("java.lang" );
258- for (JavaSymbol symbol : javaLang .members ().lookup (name )) {
259+ for (JavaSymbol symbol : javaLang .completedMembers ().lookup (name )) {
259260 if (symbol .kind == JavaSymbol .TYP ) {
260261 return symbol ;
261262 }
@@ -354,8 +355,8 @@ public Resolution findIdentInType(Env env, JavaSymbol.TypeJavaSymbol site, Strin
354355 public Resolution findMethod (Env env , String name , List <JavaType > argTypes , List <JavaType > typeParamTypes ) {
355356 Resolution bestSoFar = unresolved ();
356357 Env env1 = env ;
357- while (env1 .outer () != null ) {
358- Resolution res = findMethod (env1 , env1 .enclosingClass () .getType (), name , argTypes , typeParamTypes );
358+ while (env1 .outer != null ) {
359+ Resolution res = findMethod (env1 , env1 .enclosingClass .getType (), name , argTypes , typeParamTypes );
359360 if (res .symbol .kind < JavaSymbol .ERRONEOUS ) {
360361 // symbol exists
361362 return res ;
@@ -541,16 +542,16 @@ boolean isAccessible(Env env, JavaSymbol.TypeJavaSymbol c) {
541542 final boolean result ;
542543 switch (c .flags () & Flags .ACCESS_FLAGS ) {
543544 case Flags .PRIVATE :
544- result = env .enclosingClass () .outermostClass () == c .owner ().outermostClass ();
545+ result = env .enclosingClass .outermostClass () == c .owner ().outermostClass ();
545546 break ;
546547 case 0 :
547- result = env .packge () == c .packge ();
548+ result = env .packge == c .packge ();
548549 break ;
549550 case Flags .PUBLIC :
550551 result = true ;
551552 break ;
552553 case Flags .PROTECTED :
553- result = env .packge () == c .packge () || isInnerSubClass (env .enclosingClass () , c .owner ());
554+ result = env .packge == c .packge () || isInnerSubClass (env .enclosingClass , c .owner ());
554555 break ;
555556 default :
556557 throw new IllegalStateException ();
@@ -607,18 +608,18 @@ private boolean isAccessible(Env env, JavaSymbol.TypeJavaSymbol site, JavaSymbol
607608 case Flags .PRIVATE :
608609 //if enclosing class is null, we are checking accessibility for imports so we return false.
609610 // no check of overriding, because private members cannot be overridden
610- return env .enclosingClass != null && (env .enclosingClass () .outermostClass () == symbol .owner ().outermostClass ())
611+ return env .enclosingClass != null && (env .enclosingClass .outermostClass () == symbol .owner ().outermostClass ())
611612 && isInheritedIn (symbol , site );
612613 case 0 :
613- return (env .packge () == symbol .packge ())
614+ return (env .packge == symbol .packge ())
614615 && isAccessible (env , site )
615616 && isInheritedIn (symbol , site )
616617 && notOverriddenIn (site , symbol );
617618 case Flags .PUBLIC :
618619 return isAccessible (env , site )
619620 && notOverriddenIn (site , symbol );
620621 case Flags .PROTECTED :
621- return ((env .packge () == symbol .packge ()) || isProtectedAccessible (symbol , env .enclosingClass , site ))
622+ return ((env .packge == symbol .packge ()) || isProtectedAccessible (symbol , env .enclosingClass , site ))
622623 && isAccessible (env , site )
623624 && notOverriddenIn (site , symbol );
624625 default :
@@ -716,46 +717,19 @@ static class Env {
716717 /**
717718 * The environment enclosing the current class.
718719 */
720+ @ Nullable
719721 Env outer ;
720722
721723 JavaSymbol .PackageJavaSymbol packge ;
722724
725+ @ Nullable
723726 JavaSymbol .TypeJavaSymbol enclosingClass ;
724727
725728 Scope scope ;
726729 Scope namedImports ;
727730 Scope starImports ;
728731 Scope staticStarImports ;
729732
730- @ Nullable
731- Env outer () {
732- return outer ;
733- }
734-
735- JavaSymbol .TypeJavaSymbol enclosingClass () {
736- return enclosingClass ;
737- }
738-
739- public JavaSymbol .PackageJavaSymbol packge () {
740- return packge ;
741- }
742-
743- Scope namedImports () {
744- return namedImports ;
745- }
746-
747- Scope starImports () {
748- return starImports ;
749- }
750-
751- public Scope staticStarImports () {
752- return staticStarImports ;
753- }
754-
755- Scope scope () {
756- return scope ;
757- }
758-
759733 public Env dup () {
760734 Env env = new Env ();
761735 env .next = this ;
0 commit comments