|
61 | 61 | import java.util.Map; |
62 | 62 | import java.util.Set; |
63 | 63 | import java.util.function.Supplier; |
| 64 | +import java.util.logging.Level; |
| 65 | +import java.util.logging.Logger; |
64 | 66 |
|
65 | 67 | import javax.lang.model.element.Element; |
66 | 68 | import javax.lang.model.element.ElementKind; |
@@ -489,7 +491,7 @@ public Iterable<? extends TypeElement> getGlobalTypes(ElementAcceptor acceptor) |
489 | 491 | for (CompilationUnitTree unit : Collections.singletonList(info.getCompilationUnit())) { |
490 | 492 | TreePath path = new TreePath(unit); |
491 | 493 | Scope scope = trees.getScope(path); |
492 | | - while (scope instanceof JavacScope && !((JavacScope)scope).isStarImportScope()) { |
| 494 | + while (scope instanceof JavacScope && ((JavacScope)scope).getScopeType() == ORDINARY_SCOPE_TYPE) { |
493 | 495 | for (Element local : scope.getLocalElements()) { |
494 | 496 | if (local.getKind().isClass() || local.getKind().isInterface()) { |
495 | 497 | if (acceptor.accept(local, null)) { |
@@ -521,6 +523,21 @@ public Iterable<? extends TypeElement> getGlobalTypes(ElementAcceptor acceptor) |
521 | 523 | return membersList; |
522 | 524 | } |
523 | 525 |
|
| 526 | + private static final Object ORDINARY_SCOPE_TYPE; |
| 527 | + private static final Logger LOG = Logger.getLogger(ElementUtilities.class.getName()); |
| 528 | + |
| 529 | + static { |
| 530 | + Object ordinary = null; |
| 531 | + |
| 532 | + try { |
| 533 | + ordinary = Enum.valueOf((Class<Enum>) Class.forName("com.sun.tools.javac.api.JavacScope$ScopeType"), "ORDINARY"); |
| 534 | + } catch (ClassNotFoundException ex) { |
| 535 | + LOG.log(Level.FINE, null, ex); |
| 536 | + } |
| 537 | + |
| 538 | + ORDINARY_SCOPE_TYPE = ordinary; |
| 539 | + } |
| 540 | + |
524 | 541 | /**Filter {@link Element}s |
525 | 542 | */ |
526 | 543 | public static interface ElementAcceptor { |
|
0 commit comments