Example usage for org.eclipse.jdt.core.dom Type setProperty

List of usage examples for org.eclipse.jdt.core.dom Type setProperty

Introduction

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

Prototype

public final void setProperty(String propertyName, Object data) 

Source Link

Document

Sets the named property of this node to the given value, or to null to clear it.

Usage

From source file:org.eclipse.wb.internal.core.utils.ast.AstParser.java

License:Open Source License

/**
 * @return the copy of given {@link Type} on given position.
 *//*from  ww w  .java  2  s .com*/
public Type parseType(int position, Type sourceType) throws Exception {
    // prepare new type
    Type newType;
    if (sourceType instanceof PrimitiveType) {
        PrimitiveType primitiveSourceType = (PrimitiveType) sourceType;
        newType = getAst().newPrimitiveType(primitiveSourceType.getPrimitiveTypeCode());
        newType.setSourceRange(position, newType.toString().length());
    } else {
        // prepare name of type
        Name newTypeName;
        {
            String typeString = m_editor.getSource(sourceType);
            if (typeString.indexOf('.') == -1) {
                newTypeName = parseSimpleName(position, typeString);
            } else {
                newTypeName = parseQualifiedName(position, typeString);
            }
        }
        // create type for name
        newType = getAst().newSimpleType(newTypeName);
        AstNodeUtils.copySourceRange(newType, newTypeName);
    }
    // copy type binding
    {
        ITypeBinding sourceTypeBinding = AstNodeUtils.getTypeBinding(sourceType);
        ITypeBinding newTypeBinding = m_context.get(sourceTypeBinding);
        newType.setProperty(KEY_TYPE_BINDING, newTypeBinding);
    }
    // return created type
    return newType;
}