@Test public void anonymous_class_scope() throws Exception { Scope classScope = getScopeFor(Kind.ANONYMOUS_CLASS); assertThat(classScope.getSymbol("$field1")).isNotNull(); assertThat(classScope.getSymbol("method")).isNotNull(); }
@Nullable public Symbol getSymbol(String name, Kind... kinds) { List<Kind> kindList = Arrays.asList(kinds); List<Symbol> result = new ArrayList<>(); for (Symbol s : symbols) { if (s.called(name)) { if (kindList.isEmpty() || kindList.contains(s.kind())) { result.add(s); } else if (s.is(Kind.PARAMETER) && kindList.equals(Collections.singletonList(Kind.VARIABLE))) { return null; } } } if (result.isEmpty()) { if (superClassScope != null) { return superClassScope.getSymbol(name, kinds); } else if (captureOuterScope) { return outer.getSymbol(name, kinds); } } return result.size() == 1 ? result.get(0) : null; }
Scope { @Nullable public Symbol getSymbol(String name, Kind... kinds) { List<Kind> kindList = Arrays.asList(kinds); List<Symbol> result = new ArrayList<>(); for (Symbol s : symbols) { if (s.called(name)) { if (kindList.isEmpty() || kindList.contains(s.kind())) { result.add(s); } else if (s.is(Kind.PARAMETER) && kindList.equals(Collections.singletonList(Kind.VARIABLE))) { return null; } } } if (result.isEmpty()) { if (superClassScope != null) { return superClassScope.getSymbol(name, kinds); } else if (captureOuterScope) { return outer.getSymbol(name, kinds); } } return result.size() == 1 ? result.get(0) : null; } }
Scope { @Nullable public Symbol getSymbol(String name, Kind... kinds) { List<Kind> kindList = Arrays.asList(kinds); List<Symbol> result = new ArrayList<>(); for (Symbol s : symbols) { if (s.called(name)) { if (kindList.isEmpty() || kindList.contains(s.kind())) { result.add(s); } else if (s.is(Kind.PARAMETER) && kindList.equals(Collections.singletonList(Kind.VARIABLE))) { return null; } } } if (result.isEmpty()) { if (superClassScope != null) { return superClassScope.getSymbol(name, kinds); } else if (captureOuterScope) { return outer.getSymbol(name, kinds); } } return result.size() == 1 ? result.get(0) : null; } Scope(Scope outer, Tree tree, boolean captureOuterScope);  Scope(CompilationUnitTree compilationUnitTree); }
Scope { @Nullable public Symbol getSymbol(String name, Kind... kinds) { List<Kind> kindList = Arrays.asList(kinds); List<Symbol> result = new ArrayList<>(); for (Symbol s : symbols) { if (s.called(name)) { if (kindList.isEmpty() || kindList.contains(s.kind())) { result.add(s); } else if (s.is(Kind.PARAMETER) && kindList.equals(Collections.singletonList(Kind.VARIABLE))) { return null; } } } if (result.isEmpty()) { if (superClassScope != null) { return superClassScope.getSymbol(name, kinds); } else if (captureOuterScope) { return outer.getSymbol(name, kinds); } } return result.size() == 1 ? result.get(0) : null; } Scope(Scope outer, Tree tree, boolean captureOuterScope);  Scope(CompilationUnitTree compilationUnitTree); Tree tree(); Scope outer(); List<Symbol> getSymbols(Symbol.Kind kind); boolean isGlobal(); void addSymbol(Symbol symbol); @Nullable Symbol getSymbol(String name, Kind... kinds); boolean hasUnresolvedCompact(); }
Scope { @Nullable public Symbol getSymbol(String name, Kind... kinds) { List<Kind> kindList = Arrays.asList(kinds); List<Symbol> result = new ArrayList<>(); for (Symbol s : symbols) { if (s.called(name)) { if (kindList.isEmpty() || kindList.contains(s.kind())) { result.add(s); } else if (s.is(Kind.PARAMETER) && kindList.equals(Collections.singletonList(Kind.VARIABLE))) { return null; } } } if (result.isEmpty()) { if (superClassScope != null) { return superClassScope.getSymbol(name, kinds); } else if (captureOuterScope) { return outer.getSymbol(name, kinds); } } return result.size() == 1 ? result.get(0) : null; } Scope(Scope outer, Tree tree, boolean captureOuterScope);  Scope(CompilationUnitTree compilationUnitTree); Tree tree(); Scope outer(); List<Symbol> getSymbols(Symbol.Kind kind); boolean isGlobal(); void addSymbol(Symbol symbol); @Nullable Symbol getSymbol(String name, Kind... kinds); boolean hasUnresolvedCompact();  }