Search in sources :

Example 6 with ParameterizedSingleTypeReference

use of org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference in project lombok by rzwitserloot.

the class EclipseHandlerUtil method cloneSelfType.

public static TypeReference cloneSelfType(EclipseNode context, ASTNode source) {
    int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd;
    long p = (long) pS << 32 | pE;
    EclipseNode type = context;
    TypeReference result = null;
    while (type != null && type.getKind() != Kind.TYPE) type = type.up();
    if (type != null && type.get() instanceof TypeDeclaration) {
        TypeDeclaration typeDecl = (TypeDeclaration) type.get();
        if (typeDecl.typeParameters != null && typeDecl.typeParameters.length > 0) {
            TypeReference[] refs = new TypeReference[typeDecl.typeParameters.length];
            int idx = 0;
            for (TypeParameter param : typeDecl.typeParameters) {
                TypeReference typeRef = new SingleTypeReference(param.name, (long) param.sourceStart << 32 | param.sourceEnd);
                if (source != null)
                    setGeneratedBy(typeRef, source);
                refs[idx++] = typeRef;
            }
            result = new ParameterizedSingleTypeReference(typeDecl.name, refs, 0, p);
        } else {
            result = new SingleTypeReference(((TypeDeclaration) type.get()).name, p);
        }
    }
    if (result != null && source != null)
        setGeneratedBy(result, source);
    return result;
}
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) EclipseNode(lombok.eclipse.EclipseNode) 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) TypeDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)

Example 7 with ParameterizedSingleTypeReference

use of org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference 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)

Aggregations

ParameterizedQualifiedTypeReference (org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference)7 ParameterizedSingleTypeReference (org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference)7 QualifiedTypeReference (org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference)7 SingleTypeReference (org.eclipse.jdt.internal.compiler.ast.SingleTypeReference)7 TypeReference (org.eclipse.jdt.internal.compiler.ast.TypeReference)7 EclipseNode (lombok.eclipse.EclipseNode)4 ArrayQualifiedTypeReference (org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference)4 ArrayTypeReference (org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference)4 ArrayList (java.util.ArrayList)3 TypeDeclaration (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)3 TypeParameter (org.eclipse.jdt.internal.compiler.ast.TypeParameter)3 Wildcard (org.eclipse.jdt.internal.compiler.ast.Wildcard)3 EclipseSingularizer (lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer)2 SingularData (lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData)2 Builder (lombok.Builder)1 Singular (lombok.Singular)1 AbstractMethodDeclaration (org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration)1 AbstractVariableDeclaration (org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration)1 Argument (org.eclipse.jdt.internal.compiler.ast.Argument)1 ConstructorDeclaration (org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration)1