Search in sources :

Example 51 with TypeReference

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);
}
Also used : TypeParameter(org.eclipse.jdt.internal.compiler.ast.TypeParameter) ParameterizedSingleTypeReference(org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference) SingleTypeReference(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) ParameterizedSingleTypeReference(org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference) TypeReference(org.eclipse.jdt.internal.compiler.ast.TypeReference) ParameterizedSingleTypeReference(org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference) QualifiedTypeReference(org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) ArrayQualifiedTypeReference(org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference) ArrayTypeReference(org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference) ParameterizedQualifiedTypeReference(org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference) SingleTypeReference(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference)

Example 52 with TypeReference

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);
}
Also used : ArrayList(java.util.ArrayList) TypeReference(org.eclipse.jdt.internal.compiler.ast.TypeReference) Annotation(org.eclipse.jdt.internal.compiler.ast.Annotation)

Aggregations

TypeReference (org.eclipse.jdt.internal.compiler.ast.TypeReference)52 QualifiedTypeReference (org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference)44 SingleTypeReference (org.eclipse.jdt.internal.compiler.ast.SingleTypeReference)26 ParameterizedQualifiedTypeReference (org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference)20 Statement (org.eclipse.jdt.internal.compiler.ast.Statement)20 MethodDeclaration (org.eclipse.jdt.internal.compiler.ast.MethodDeclaration)19 IfStatement (org.eclipse.jdt.internal.compiler.ast.IfStatement)17 ParameterizedSingleTypeReference (org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference)17 ArrayList (java.util.ArrayList)16 MessageSend (org.eclipse.jdt.internal.compiler.ast.MessageSend)16 ReturnStatement (org.eclipse.jdt.internal.compiler.ast.ReturnStatement)16 ThisReference (org.eclipse.jdt.internal.compiler.ast.ThisReference)16 SingleNameReference (org.eclipse.jdt.internal.compiler.ast.SingleNameReference)15 Expression (org.eclipse.jdt.internal.compiler.ast.Expression)13 Argument (org.eclipse.jdt.internal.compiler.ast.Argument)12 FieldReference (org.eclipse.jdt.internal.compiler.ast.FieldReference)12 EclipseNode (lombok.eclipse.EclipseNode)11 ArrayTypeReference (org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference)11 FieldDeclaration (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)11 ArrayQualifiedTypeReference (org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference)8