use of org.eclipse.jdt.internal.compiler.ast.TypeReference in project lombok by rzwitserloot.
the class EclipseHandlerUtil method namePlusTypeParamsToTypeReference.
public static TypeReference namePlusTypeParamsToTypeReference(char[] typeName, TypeParameter[] params, long p) {
if (params != null && params.length > 0) {
TypeReference[] refs = new TypeReference[params.length];
int idx = 0;
for (TypeParameter param : params) {
TypeReference typeRef = new SingleTypeReference(param.name, p);
refs[idx++] = typeRef;
}
return new ParameterizedSingleTypeReference(typeName, refs, 0, p);
}
return new SingleTypeReference(typeName, p);
}
use of org.eclipse.jdt.internal.compiler.ast.TypeReference in project lombok by rzwitserloot.
the class Eclipse method findAnnotations.
/**
* Searches the given field node for annotations and returns each one that matches the provided regular expression pattern.
*
* Only the simple name is checked - the package and any containing class are ignored.
*/
public static Annotation[] findAnnotations(FieldDeclaration field, Pattern namePattern) {
List<Annotation> result = new ArrayList<Annotation>();
if (field.annotations == null)
return EMPTY_ANNOTATIONS_ARRAY;
for (Annotation annotation : field.annotations) {
TypeReference typeRef = annotation.type;
if (typeRef != null && typeRef.getTypeName() != null) {
char[][] typeName = typeRef.getTypeName();
String suspect = new String(typeName[typeName.length - 1]);
if (namePattern.matcher(suspect).matches()) {
result.add(annotation);
}
}
}
return result.toArray(EMPTY_ANNOTATIONS_ARRAY);
}
Aggregations