File tree Expand file tree Collapse file tree 3 files changed +34
-5
lines changed
inject-generator/src/main/java/io/avaje/inject/generator
inject-test/src/main/java/io/avaje/inject/test Expand file tree Collapse file tree 3 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 8
8
import javax .lang .model .element .AnnotationMirror ;
9
9
import javax .lang .model .element .TypeElement ;
10
10
import javax .lang .model .type .DeclaredType ;
11
+ import javax .lang .model .util .ElementFilter ;
11
12
12
13
/**
13
14
* Read the annotations on the type.
@@ -38,9 +39,19 @@ void process() {
38
39
for (AnnotationMirror annotationMirror : beanType .getAnnotationMirrors ()) {
39
40
DeclaredType annotationType = annotationMirror .getAnnotationType ();
40
41
String annType = annotationType .toString ();
41
-
42
+
42
43
if (QualifierPrism .isPresent (annotationType .asElement ())) {
43
- qualifierName = Util .shortName (annType ).toLowerCase ();
44
+
45
+ final var shortName = Util .shortName (annotationType .toString ());
46
+ var fqn = APContext .asTypeElement (annotationType ).getQualifiedName ().toString ();
47
+ qualifierName =
48
+ annotationMirror
49
+ .toString ()
50
+ .substring (1 )
51
+ .replace (fqn , shortName )
52
+ .replace ("\" " , "\\ \" " )
53
+ .toLowerCase ();
54
+
44
55
} else if (annType .indexOf ('.' ) == -1 ) {
45
56
logWarn ("skip when no package on annotation " + annType );
46
57
} else if (IncludeAnnotations .include (annType )) {
Original file line number Diff line number Diff line change 8
8
import javax .lang .model .element .Element ;
9
9
import javax .lang .model .type .DeclaredType ;
10
10
import javax .lang .model .type .TypeMirror ;
11
+ import javax .lang .model .util .ElementFilter ;
11
12
12
13
final class Util {
13
14
// whitespace not in quotes
@@ -250,7 +251,15 @@ public static String getNamed(Element p) {
250
251
final DeclaredType annotationType = annotationMirror .getAnnotationType ();
251
252
final var hasQualifier = QualifierPrism .isPresent (annotationType .asElement ());
252
253
if (hasQualifier ) {
253
- return Util .shortName (annotationType .toString ()).toLowerCase ();
254
+ final var shortName = Util .shortName (annotationType .toString ());
255
+
256
+ var fqn = APContext .asTypeElement (annotationType ).getQualifiedName ().toString ();
257
+ return annotationMirror
258
+ .toString ()
259
+ .substring (1 )
260
+ .replace (fqn , shortName )
261
+ .replace ("\" " , "\\ \" " )
262
+ .toLowerCase ();
254
263
}
255
264
}
256
265
return null ;
Original file line number Diff line number Diff line change @@ -119,9 +119,18 @@ private String name(Field field) {
119
119
return named .value ().toLowerCase ();
120
120
}
121
121
for (Annotation annotation : field .getAnnotations ()) {
122
- for (Annotation metaAnnotation : annotation .annotationType ().getAnnotations ()) {
122
+ final var annotationType = annotation .annotationType ();
123
+ for (Annotation metaAnnotation : annotationType .getAnnotations ()) {
123
124
if (metaAnnotation .annotationType ().equals (Qualifier .class )) {
124
- return annotation .annotationType ().getSimpleName ().toLowerCase ();
125
+ var toString =
126
+ annotation
127
+ .toString ()
128
+ .substring (1 )
129
+ .replace (annotationType .getCanonicalName (), annotationType .getSimpleName ());
130
+ if (toString .endsWith ("()" )) {
131
+ toString = toString .substring (0 , toString .length () - 2 );
132
+ }
133
+ return toString .toLowerCase ();
125
134
}
126
135
}
127
136
}
You can’t perform that action at this time.
0 commit comments