Example usage for org.eclipse.jdt.core.dom TypeDeclaration internalSetSuperclass

List of usage examples for org.eclipse.jdt.core.dom TypeDeclaration internalSetSuperclass

Introduction

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

Prototype

 final void internalSetSuperclass(Name superclassName) 

Source Link

Document

Internal synonym for deprecated method.

Usage

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

License:Open Source License

public ASTNode convert(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
    int kind = org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind(typeDeclaration.modifiers);
    switch (kind) {
    case org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ENUM_DECL:
        if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
            return null;
        } else {//from w ww . j  a  v  a  2 s.  c om
            return convertToEnumDeclaration(typeDeclaration);
        }
    case org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.ANNOTATION_TYPE_DECL:
        if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
            return null;
        } else {
            return convertToAnnotationDeclaration(typeDeclaration);
        }
    }

    checkCanceled();
    TypeDeclaration typeDecl = new TypeDeclaration(this.ast);
    if (typeDeclaration.modifiersSourceStart != -1) {
        setModifiers(typeDecl, typeDeclaration);
    }
    boolean isInterface = kind == org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.INTERFACE_DECL;
    typeDecl.setInterface(isInterface);
    final SimpleName typeName = new SimpleName(this.ast);
    typeName.internalSetIdentifier(new String(typeDeclaration.name));
    typeName.setSourceRange(typeDeclaration.sourceStart,
            typeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
    typeDecl.setName(typeName);
    typeDecl.setSourceRange(typeDeclaration.declarationSourceStart,
            typeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);

    // need to set the superclass and super interfaces here since we cannot distinguish them at
    // the type references level.
    if (typeDeclaration.superclass != null) {
        switch (this.ast.apiLevel) {
        case AST.JLS2_INTERNAL:
            typeDecl.internalSetSuperclass(convert(typeDeclaration.superclass));
            break;
        default:
            typeDecl.setSuperclassType(convertType(typeDeclaration.superclass));
            break;
        }
    }

    org.eclipse.jdt.internal.compiler.ast.TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
    if (superInterfaces != null) {
        switch (this.ast.apiLevel) {
        case AST.JLS2_INTERNAL:
            for (int index = 0, length = superInterfaces.length; index < length; index++) {
                typeDecl.internalSuperInterfaces().add(convert(superInterfaces[index]));
            }
            break;
        default:
            for (int index = 0, length = superInterfaces.length; index < length; index++) {
                typeDecl.superInterfaceTypes().add(convertType(superInterfaces[index]));
            }
        }
    }
    org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = typeDeclaration.typeParameters;
    if (typeParameters != null) {
        switch (this.ast.apiLevel) {
        case AST.JLS2_INTERNAL:
            typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
            break;
        default:
            for (int index = 0, length = typeParameters.length; index < length; index++) {
                typeDecl.typeParameters().add(convert(typeParameters[index]));
            }
        }
    }
    buildBodyDeclarations(typeDeclaration, typeDecl, isInterface);
    if (this.resolveBindings) {
        recordNodes(typeDecl, typeDeclaration);
        recordNodes(typeName, typeDeclaration);
        typeDecl.resolveBinding();
    }
    return typeDecl;
}