Analyzing Documentation Comments: Comparing Example1.java and Example2.java:

Example1.java Example2.java

62a63
> import javax.lang.model.element.ModuleElement;
63a65
> import javax.lang.model.util.Elements;
82c84
< public class Example1 {
---
> public class Example2 {
85c87
<             var ok = new Example1().run(args);
---
>             var ok = new Example2().run(args);
109c111
<                 if (ev.getKind() == TaskEvent.Kind.PARSE) {
---
>                 if (ev.getKind() == TaskEvent.Kind.ENTER) {
110a113,128
>                     var packageName = tree.getPackageName();
>                     if (packageName != null) {
>                         var pe = elements.getPackageElement(packageName.toString());
>                         if (pe != null) {
>                             var me = elements.getModuleOf(pe);
>                             if (me != null) {
>                                 var exported = me.getDirectives().stream()
>                                         .filter(d -> d.getKind() == ModuleElement.DirectiveKind.EXPORTS)
>                                         .map(ModuleElement.ExportsDirective.class::cast)
>                                         .anyMatch(ed -> ed.getPackage() == pe);
>                                 if (!exported) {
>                                     return;
>                                 }
>                             }
>                         }
>                     }
120a139
>         elements = t.getElements();
123c142
<         t.parse();
---
>         t.analyze();
138a158
>     private Elements elements;