14
14
15
15
package com .google .devtools .build .runfiles ;
16
16
17
- import static java .util .stream .Collectors .joining ;
18
- import static java .util .stream .Collectors .toList ;
19
17
20
18
import java .io .IOException ;
21
19
import java .io .PrintWriter ;
22
- import java .util .Collections ;
23
- import java .util .List ;
20
+ import java .util .ArrayDeque ;
21
+ import java .util .Deque ;
24
22
import java .util .Set ;
25
- import java .util .stream .Stream ;
26
23
import javax .annotation .processing .AbstractProcessor ;
27
24
import javax .annotation .processing .RoundEnvironment ;
28
25
import javax .annotation .processing .SupportedAnnotationTypes ;
29
26
import javax .annotation .processing .SupportedOptions ;
30
27
import javax .lang .model .SourceVersion ;
31
28
import javax .lang .model .element .Element ;
32
- import javax .lang .model .element .Name ;
33
29
import javax .lang .model .element .TypeElement ;
34
30
import javax .tools .Diagnostic .Kind ;
35
31
@@ -51,7 +47,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
51
47
.flatMap (element -> roundEnv .getElementsAnnotatedWith (element ).stream ())
52
48
.map (element -> (TypeElement ) element )
53
49
.forEach (this ::emitClass );
54
- return true ;
50
+ return false ;
55
51
}
56
52
57
53
private void emitClass (TypeElement annotatedClass ) {
@@ -80,18 +76,14 @@ private void emitClass(TypeElement annotatedClass) {
80
76
// AutoBazelRepository_Outer_Middle_Inner.
81
77
// Note: There can be collisions when local classes are involved, but since the definition of a
82
78
// class depends only on the containing Bazel target, this does not result in ambiguity.
83
- List <String > nestedClassNames =
84
- Stream .iterate (
85
- annotatedClass ,
86
- element -> element instanceof TypeElement ,
87
- Element ::getEnclosingElement )
88
- .map (Element ::getSimpleName )
89
- .map (Name ::toString )
90
- .collect (toList ());
91
- Collections .reverse (nestedClassNames );
92
- String generatedClassSimpleName =
93
- Stream .concat (Stream .of ("AutoBazelRepository" ), nestedClassNames .stream ())
94
- .collect (joining ("_" ));
79
+ Deque <String > classNameSegments = new ArrayDeque <>();
80
+ Element element = annotatedClass ;
81
+ while (element instanceof TypeElement ) {
82
+ classNameSegments .addFirst (element .getSimpleName ().toString ());
83
+ element = element .getEnclosingElement ();
84
+ }
85
+ classNameSegments .addFirst ("AutoBazelRepository" );
86
+ String generatedClassSimpleName = String .join ("_" , classNameSegments );
95
87
96
88
String generatedClassPackage =
97
89
processingEnv .getElementUtils ().getPackageOf (annotatedClass ).getQualifiedName ().toString ();
0 commit comments