106 Arrays.fill(result, AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE);
107 @SuppressWarnings("rawtypes")
108 ArrayList[] l = new ArrayList[size]; // array of ArrayList<TypeAnnotation>
109
110 TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations,
111 cp, decl, container);
112
113 for (TypeAnnotation t : tas) {
114 TypeAnnotationTargetInfo ti = t.getTargetInfo();
115 if (ti.getTarget() == filter) {
116 int pos = ti.getCount();
117 if (l[pos] == null) {
118 ArrayList<TypeAnnotation> tmp = new ArrayList<>(tas.length);
119 l[pos] = tmp;
120 }
121 @SuppressWarnings("unchecked")
122 ArrayList<TypeAnnotation> tmp = l[pos];
123 tmp.add(t);
124 }
125 }
126 for (int i = 0; i < size; i++) {
127 @SuppressWarnings("unchecked")
128 ArrayList<TypeAnnotation> list = l[i];
129 TypeAnnotation[] typeAnnotations;
130 if (list != null) {
131 typeAnnotations = list.toArray(new TypeAnnotation[list.size()]);
132 } else {
133 typeAnnotations = EMPTY_TYPE_ANNOTATION_ARRAY;
134 }
135 result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
136 AnnotatedTypeFactory.nestingForType(types[i], LocationInfo.BASE_LOCATION),
137 typeAnnotations,
138 typeAnnotations,
139 decl);
140
141 }
142 return result;
143 }
144
145 // Class helpers
146
147 /**
148 * Build an AnnotatedType for the class decl's supertype.
|
106 Arrays.fill(result, AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE);
107 @SuppressWarnings("rawtypes")
108 ArrayList[] l = new ArrayList[size]; // array of ArrayList<TypeAnnotation>
109
110 TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations,
111 cp, decl, container);
112
113 for (TypeAnnotation t : tas) {
114 TypeAnnotationTargetInfo ti = t.getTargetInfo();
115 if (ti.getTarget() == filter) {
116 int pos = ti.getCount();
117 if (l[pos] == null) {
118 ArrayList<TypeAnnotation> tmp = new ArrayList<>(tas.length);
119 l[pos] = tmp;
120 }
121 @SuppressWarnings("unchecked")
122 ArrayList<TypeAnnotation> tmp = l[pos];
123 tmp.add(t);
124 }
125 }
126 // If a constructor has a mandated outer this, that parameter
127 // has no annotations and the annotations to parameter mapping
128 // should be offset by 1.
129 boolean offset = false;
130 if (decl instanceof Constructor) {
131 Constructor<?> ctor = (Constructor<?>) decl;
132 Class<?> declaringClass = ctor.getDeclaringClass();
133 if (!declaringClass.isEnum() &&
134 (declaringClass.isMemberClass() &&
135 (declaringClass.getModifiers() & Modifier.STATIC) == 0) ) {
136 offset = true;
137 }
138 }
139 for (int i = 0; i < size; i++) {
140 ArrayList<TypeAnnotation> list;
141 if (offset) {
142 @SuppressWarnings("unchecked")
143 ArrayList<TypeAnnotation> tmp = (i == 0) ? null : l[i - 1];
144 list = tmp;
145 } else {
146 @SuppressWarnings("unchecked")
147 ArrayList<TypeAnnotation> tmp = l[i];
148 list = tmp;
149 }
150 TypeAnnotation[] typeAnnotations;
151 if (list != null) {
152 typeAnnotations = list.toArray(new TypeAnnotation[list.size()]);
153 } else {
154 typeAnnotations = EMPTY_TYPE_ANNOTATION_ARRAY;
155 }
156 result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
157 AnnotatedTypeFactory.nestingForType(types[i], LocationInfo.BASE_LOCATION),
158 typeAnnotations,
159 typeAnnotations,
160 decl);
161
162 }
163 return result;
164 }
165
166 // Class helpers
167
168 /**
169 * Build an AnnotatedType for the class decl's supertype.
|