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

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

Introduction

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

Prototype

public final void setSourceRange(int startPosition, int length) 

Source Link

Document

Sets the source range of the original source file where the source fragment corresponding to this node was found.

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);// w w  w.  ja v  a  2  s  .  c  o 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;
}