@@ -12,8 +12,6 @@ public static void write(PrintWriter out, String packageName) {
12
12
+ packageName
13
13
+ ";\n "
14
14
+ "\n "
15
- + "\n "
16
- + "import static java.util.function.Predicate.not;\n "
17
15
+ "import static java.util.stream.Collectors.toSet;\n "
18
16
+ "\n "
19
17
+ "import java.util.ArrayList;\n "
@@ -25,6 +23,7 @@ public static void write(PrintWriter out, String packageName) {
25
23
+ "import java.util.Map;\n "
26
24
+ "import java.util.Set;\n "
27
25
+ "\n "
26
+ + "import javax.annotation.processing.Generated;\n "
28
27
+ "import javax.lang.model.element.AnnotationMirror;\n "
29
28
+ "import javax.lang.model.element.Element;\n "
30
29
+ "import javax.lang.model.element.QualifiedNameable;\n "
@@ -44,6 +43,7 @@ public static void write(PrintWriter out, String packageName) {
44
43
+ "import javax.lang.model.type.WildcardType;\n "
45
44
+ "import javax.lang.model.util.AbstractTypeVisitor9;\n "
46
45
+ "\n "
46
+ + "@Generated(\" avaje-prism-generator\" )\n "
47
47
+ "class TypeMirrorVisitor extends AbstractTypeVisitor9<StringBuilder, StringBuilder>\n "
48
48
+ " implements UType {\n "
49
49
+ "\n "
@@ -62,26 +62,35 @@ public static void write(PrintWriter out, String packageName) {
62
62
+ " private TypeKind kind;\n "
63
63
+ "\n "
64
64
+ " public static TypeMirrorVisitor create(TypeMirror typeMirror) {\n "
65
- + " final var v = new TypeMirrorVisitor(1, Map.of());\n "
65
+ + " return create(typeMirror, true);\n "
66
+ + " }\n "
67
+ + "\n "
68
+ + " public static TypeMirrorVisitor create(TypeMirror typeMirror, boolean includedAnnotations) {\n "
69
+ + " final var v = new TypeMirrorVisitor(1, Map.of(), includedAnnotations);\n "
66
70
+ " final StringBuilder b = new StringBuilder();\n "
67
71
+ " v.fullType = typeMirror.accept(v, b).toString();\n "
68
72
+ " return v;\n "
69
73
+ " }\n "
70
74
+ "\n "
71
75
+ " private TypeMirrorVisitor() {\n "
72
- + " this(1, new HashMap<>());\n "
76
+ + " this(1, new HashMap<>(), true );\n "
73
77
+ " }\n "
74
78
+ "\n "
75
- + " private TypeMirrorVisitor(int depth, Map<TypeVariable, String> typeVariables) {\n "
76
- + " this.includeAnnotations = true;\n "
79
+ + " private TypeMirrorVisitor(\n "
80
+ + " int depth, Map<TypeVariable, String> typeVariables, boolean includeAnnotations) {\n "
81
+ + " this.includeAnnotations = includeAnnotations;\n "
77
82
+ " this.depth = depth;\n "
78
83
+ " this.typeVariables = new HashMap<>();\n "
79
84
+ " this.typeVariables.putAll(typeVariables);\n "
80
85
+ " }\n "
81
86
+ "\n "
82
87
+ " @Override\n "
83
88
+ " public Set<String> importTypes() {\n "
84
- + " return allTypes.stream().filter(s -> !s.startsWith(\" java.lang.\" )).collect(toSet());\n "
89
+ + " return allTypes.stream().filter(this::notJavaLang).collect(toSet());\n "
90
+ + " }\n "
91
+ + "\n "
92
+ + " private boolean notJavaLang(String type) {\n "
93
+ + " return !type.startsWith(\" java.lang.\" ) || Character.isLowerCase(type.charAt(10));\n "
85
94
+ " }\n "
86
95
+ "\n "
87
96
+ " @Override\n "
@@ -151,7 +160,7 @@ public static void write(PrintWriter out, String packageName) {
151
160
+ "\n "
152
161
+ " private void child(TypeMirror ct, StringBuilder p, boolean setMain) {\n "
153
162
+ "\n "
154
- + " var child = new TypeMirrorVisitor(depth + 1, typeVariables);\n "
163
+ + " var child = new TypeMirrorVisitor(depth + 1, typeVariables, includeAnnotations );\n "
155
164
+ " child.allTypes = allTypes;\n "
156
165
+ " child.everyAnnotation = everyAnnotation;\n "
157
166
+ " var full = ct.accept(child, new StringBuilder()).toString();\n "
0 commit comments