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

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

Introduction

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

Prototype

public Name getSuperclass() 

Source Link

Document

Returns the name of the superclass declared in this type declaration, or null if there is none (JLS2 API only).

Usage

From source file:lang.java.jdt.internal.JdtAstToRascalAstConverter.java

License:Open Source License

public boolean visit(TypeDeclaration node) {
    java.util.Map.Entry<IValueList, IValueList> extendedModifiers = parseExtendedModifiers(node);
    IValue objectType = node.isInterface() ? values.string("interface") : values.string("class");
    IValue name = values.string(node.getName().getFullyQualifiedName());

    IValueList genericTypes = new IValueList(values);
    if (node.getAST().apiLevel() >= AST.JLS3) {
        if (!node.typeParameters().isEmpty()) {
            for (Iterator it = node.typeParameters().iterator(); it.hasNext();) {
                TypeParameter t = (TypeParameter) it.next();
                genericTypes.add(visitChild(t));
            }//  www  .j  a  v a2s  .c om
        }
    }

    IValue extendsClass = null;
    IValueList implementsInterfaces = new IValueList(values);

    if (node.getAST().apiLevel() == AST.JLS2) {
        if (node.getSuperclass() != null) {
            extendsClass = visitChild(node.getSuperclass());
        }
        if (!node.superInterfaces().isEmpty()) {
            for (Iterator it = node.superInterfaces().iterator(); it.hasNext();) {
                Name n = (Name) it.next();
                implementsInterfaces.add(visitChild(n));
            }
        }
    } else if (node.getAST().apiLevel() >= AST.JLS3) {
        if (node.getSuperclassType() != null) {
            extendsClass = visitChild(node.getSuperclassType());
        }
        if (!node.superInterfaceTypes().isEmpty()) {
            for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext();) {
                Type t = (Type) it.next();
                implementsInterfaces.add(visitChild(t));
            }
        }
    }

    IValueList bodyDeclarations = new IValueList(values);
    for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) {
        BodyDeclaration d = (BodyDeclaration) it.next();
        bodyDeclarations.add(visitChild(d));
    }

    ownValue = constructRascalNode(node, extendedModifiers.getKey().asList(),
            extendedModifiers.getValue().asList(), objectType, name, genericTypes.asList(),
            optional(extendsClass), implementsInterfaces.asList(), bodyDeclarations.asList());
    return false;
}

From source file:org.codemucker.jmutate.ast.JAstFlattener.java

License:Open Source License

/**
 * Internal synonym for {@link TypeDeclaration#getSuperclass()}. Use to
 * alleviate deprecation warnings./*w ww. j a va  2  s.  c  o  m*/
 * 
 * @deprecated
 * @since 3.4
 */
private static Name getSuperclass(TypeDeclaration node) {
    return node.getSuperclass();
}