Example usage for org.eclipse.jdt.core.dom TypeParameter TypeParameter

List of usage examples for org.eclipse.jdt.core.dom TypeParameter TypeParameter

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom TypeParameter TypeParameter.

Prototype

TypeParameter(AST ast) 

Source Link

Document

Creates a new unparented node for a parameterized type owned by the given AST.

Usage

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

public TypeParameter convert(org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter) {
    final TypeParameter typeParameter2 = new TypeParameter(this.ast);
    final SimpleName simpleName = new SimpleName(this.ast);
    simpleName.internalSetIdentifier(new String(typeParameter.name));
    int start = typeParameter.sourceStart;
    int end = typeParameter.sourceEnd;
    simpleName.setSourceRange(start, end - start + 1);
    typeParameter2.setName(simpleName);//  www.ja v a 2s .  co  m
    final TypeReference superType = typeParameter.type;
    end = typeParameter.declarationSourceEnd;
    if (superType != null) {
        Type type = convertType(superType);
        typeParameter2.typeBounds().add(type);
        end = type.getStartPosition() + type.getLength() - 1;
    }
    TypeReference[] bounds = typeParameter.bounds;
    if (bounds != null) {
        Type type = null;
        for (int index = 0, length = bounds.length; index < length; index++) {
            type = convertType(bounds[index]);
            typeParameter2.typeBounds().add(type);
            end = type.getStartPosition() + type.getLength() - 1;
        }
    }
    start = typeParameter.declarationSourceStart;
    end = retrieveClosingAngleBracketPosition(end);
    typeParameter2.setSourceRange(start, end - start + 1);
    if (this.resolveBindings) {
        recordName(simpleName, typeParameter);
        recordNodes(typeParameter2, typeParameter);
        typeParameter2.resolveBinding();
    }
    return typeParameter2;
}