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

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

Introduction

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

Prototype

ASTNode.NodeList superInterfaceTypes

To view the source code for org.eclipse.jdt.core.dom TypeDeclaration superInterfaceTypes.

Click Source Link

Document

The superinterface types (element type: Type ).

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(TypeDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//  ww  w  . j ava2s.c o m
    if (node.getAST().apiLevel() >= JLS3) {
        printModifiers(node.modifiers());
    }
    this.fBuffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$
    node.getName().accept(this);
    if (node.getAST().apiLevel() >= JLS3) {
        if (!node.typeParameters().isEmpty()) {
            this.fBuffer.append("<");//$NON-NLS-1$
            for (Iterator<TypeParameter> it = node.typeParameters().iterator(); it.hasNext();) {
                TypeParameter t = it.next();
                t.accept(this);
                if (it.hasNext()) {
                    this.fBuffer.append(",");//$NON-NLS-1$
                }
            }
            this.fBuffer.append(">");//$NON-NLS-1$
        }
    }
    this.fBuffer.append(" ");//$NON-NLS-1$
    if (node.getAST().apiLevel() >= JLS3) {
        if (node.getSuperclassType() != null) {
            this.fBuffer.append("extends ");//$NON-NLS-1$
            node.getSuperclassType().accept(this);
            this.fBuffer.append(" ");//$NON-NLS-1$
        }
        if (!node.superInterfaceTypes().isEmpty()) {
            this.fBuffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$
            for (Iterator<Type> it = node.superInterfaceTypes().iterator(); it.hasNext();) {
                Type t = it.next();
                t.accept(this);
                if (it.hasNext()) {
                    this.fBuffer.append(", ");//$NON-NLS-1$
                }
            }
            this.fBuffer.append(" ");//$NON-NLS-1$
        }
    }
    this.fBuffer.append("{");//$NON-NLS-1$
    BodyDeclaration prev = null;
    for (Iterator<BodyDeclaration> it = node.bodyDeclarations().iterator(); it.hasNext();) {
        BodyDeclaration d = it.next();
        if (prev instanceof EnumConstantDeclaration) {
            // enum constant declarations do not include punctuation
            if (d instanceof EnumConstantDeclaration) {
                // enum constant declarations are separated by commas
                this.fBuffer.append(", ");//$NON-NLS-1$
            } else {
                // semicolon separates last enum constant declaration from
                // first class body declarations
                this.fBuffer.append("; ");//$NON-NLS-1$
            }
        }
        d.accept(this);
        prev = d;
    }
    this.fBuffer.append("}");//$NON-NLS-1$
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(TypeDeclaration node) {
    boa.types.Ast.Declaration.Builder b = boa.types.Ast.Declaration.newBuilder();
    //      b.setPosition(pos.build());
    b.setName(node.getName().getFullyQualifiedName());
    if (node.isInterface())
        b.setKind(boa.types.Ast.TypeKind.INTERFACE);
    else/*w w w  . ja  v  a  2 s .  com*/
        b.setKind(boa.types.Ast.TypeKind.CLASS);
    for (Object m : node.modifiers()) {
        if (((IExtendedModifier) m).isAnnotation())
            ((Annotation) m).accept(this);
        else
            ((org.eclipse.jdt.core.dom.Modifier) m).accept(this);
        b.addModifiers(modifiers.pop());
    }
    for (Object t : node.typeParameters()) {
        boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder();
        String name = ((TypeParameter) t).getName().getFullyQualifiedName();
        String bounds = "";
        for (Object o : ((TypeParameter) t).typeBounds()) {
            if (bounds.length() > 0)
                bounds += " & ";
            bounds += typeName((org.eclipse.jdt.core.dom.Type) o);
        }
        if (bounds.length() > 0)
            name = name + " extends " + bounds;
        tb.setName(getIndex(name));
        tb.setKind(boa.types.Ast.TypeKind.GENERIC);
        b.addGenericParameters(tb.build());
    }
    if (node.getSuperclassType() != null) {
        boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder();
        tb.setName(getIndex(typeName(node.getSuperclassType())));
        tb.setKind(boa.types.Ast.TypeKind.CLASS);
        b.addParents(tb.build());
    }
    for (Object t : node.superInterfaceTypes()) {
        boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder();
        tb.setName(getIndex(typeName((org.eclipse.jdt.core.dom.Type) t)));
        tb.setKind(boa.types.Ast.TypeKind.INTERFACE);
        b.addParents(tb.build());
    }
    for (Object d : node.bodyDeclarations()) {
        if (d instanceof FieldDeclaration) {
            fields.push(new ArrayList<boa.types.Ast.Variable>());
            ((FieldDeclaration) d).accept(this);
            for (boa.types.Ast.Variable v : fields.pop())
                b.addFields(v);
        } else if (d instanceof MethodDeclaration) {
            methods.push(new ArrayList<boa.types.Ast.Method>());
            ((MethodDeclaration) d).accept(this);
            for (boa.types.Ast.Method m : methods.pop())
                b.addMethods(m);
        } else if (d instanceof Initializer) {
            methods.push(new ArrayList<boa.types.Ast.Method>());
            ((Initializer) d).accept(this);
            for (boa.types.Ast.Method m : methods.pop())
                b.addMethods(m);
        } else {
            declarations.push(new ArrayList<boa.types.Ast.Declaration>());
            ((BodyDeclaration) d).accept(this);
            for (boa.types.Ast.Declaration nd : declarations.pop())
                b.addNestedDeclarations(nd);
        }
    }
    // TODO initializers
    // TODO enum constants
    // TODO annotation type members
    declarations.peek().add(b.build());
    return false;
}

From source file:chibi.gumtreediff.gen.jdt.cd.CdJdtVisitor.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from   w ww .  j  a v a2 s . c  o m*/
public boolean visit(TypeDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }
    // @Inria
    pushNode(node, node.getName().toString());
    visitListAsNode(EntityType.MODIFIERS, node.modifiers());
    visitListAsNode(EntityType.TYPE_ARGUMENTS, node.typeParameters());
    if (node.getSuperclassType() != null) {
        node.getSuperclassType().accept(this);
    }

    visitListAsNode(EntityType.SUPER_INTERFACE_TYPES, node.superInterfaceTypes());

    // @Inria
    // Change Distiller does not check the changes at Class Field declaration
    for (FieldDeclaration fd : node.getFields()) {
        fd.accept(this);
    }
    // @Inria
    // Visit Declaration and Body (inside MD visiting)
    for (MethodDeclaration md : node.getMethods()) {
        md.accept(this);
    }
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(TypeDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//from w ww .  ja va2 s.co  m
    if (node.getAST().apiLevel() >= AST.JLS3) {
        printModifiers(node.modifiers());
    }
    this.buffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$
    node.getName().accept(this);
    if (node.getAST().apiLevel() >= AST.JLS3) {
        if (!node.typeParameters().isEmpty()) {
            this.buffer.append("<");//$NON-NLS-1$
            for (Iterator it = node.typeParameters().iterator(); it.hasNext();) {
                TypeParameter t = (TypeParameter) it.next();
                t.accept(this);
                if (it.hasNext()) {
                    this.buffer.append(",");//$NON-NLS-1$
                }
            }
            this.buffer.append(">");//$NON-NLS-1$
        }
    }
    this.buffer.append(" ");//$NON-NLS-1$
    if (node.getAST().apiLevel() >= AST.JLS3) {
        if (node.getSuperclassType() != null) {
            this.buffer.append("extends ");//$NON-NLS-1$
            node.getSuperclassType().accept(this);
            this.buffer.append(" ");//$NON-NLS-1$
        }
        if (!node.superInterfaceTypes().isEmpty()) {
            this.buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$
            for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext();) {
                Type t = (Type) it.next();
                t.accept(this);
                if (it.hasNext()) {
                    this.buffer.append(", ");//$NON-NLS-1$
                }
            }
            this.buffer.append(" ");//$NON-NLS-1$
        }
    }
    this.buffer.append("{\n");//$NON-NLS-1$
    this.indent++;
    BodyDeclaration prev = null;
    for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext();) {
        BodyDeclaration d = (BodyDeclaration) it.next();
        if (prev instanceof EnumConstantDeclaration) {
            // enum constant declarations do not include punctuation
            if (d instanceof EnumConstantDeclaration) {
                // enum constant declarations are separated by commas
                this.buffer.append(", ");//$NON-NLS-1$
            } else {
                // semicolon separates last enum constant declaration from
                // first class body declarations
                this.buffer.append("; ");//$NON-NLS-1$
            }
        }
        d.accept(this);
    }
    this.indent--;
    printIndent();
    this.buffer.append("}\n");//$NON-NLS-1$
    return false;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.linewrap.WrapPreparator.java

License:Open Source License

@Override
public boolean visit(TypeDeclaration node) {
    Type superclassType = node.getSuperclassType();
    if (superclassType != null) {
        this.wrapParentIndex = this.tm.lastIndexIn(node.getName(), -1);
        this.wrapGroupEnd = this.tm.lastIndexIn(superclassType, -1);
        this.wrapIndexes.add(this.tm.firstIndexBefore(superclassType, TokenNameextends));
        this.wrapIndexes.add(this.tm.firstIndexIn(superclassType, -1));
        handleWrap(this.options.alignment_for_superclass_in_type_declaration, PREFERRED);
    }/*from   ww  w .  j a  va 2s .co m*/

    List<Type> superInterfaceTypes = node.superInterfaceTypes();
    if (!superInterfaceTypes.isEmpty()) {
        int implementsToken = node.isInterface() ? TokenNameextends : TokenNameimplements;
        this.wrapParentIndex = this.tm.lastIndexIn(node.getName(), -1);
        this.wrapGroupEnd = this.tm.lastIndexIn(superInterfaceTypes.get(superInterfaceTypes.size() - 1), -1);
        this.wrapIndexes.add(this.tm.firstIndexBefore(superInterfaceTypes.get(0), implementsToken));
        for (Type type : superInterfaceTypes)
            this.wrapIndexes.add(this.tm.firstIndexIn(type, -1));
        handleWrap(this.options.alignment_for_superinterfaces_in_type_declaration, PREFERRED);
    }

    if (this.options.align_type_members_on_columns)
        this.fieldAligner.prepareAlign(node.bodyDeclarations());

    return true;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java

License:Open Source License

@Override
public boolean visit(TypeDeclaration node) {
    if (node.getName().getStartPosition() == -1)
        return true; // this is a fake type created by parsing in class body mode

    handleToken(node.getName(), TokenNameIdentifier, true, false);

    List<TypeParameter> typeParameters = node.typeParameters();
    handleTypeParameters(typeParameters);

    if (!node.isInterface() && !node.superInterfaceTypes().isEmpty()) {
        // fix for: class A<E> extends ArrayList<String>implements Callable<String>
        handleToken(node.getName(), TokenNameimplements, true, false);
    }//  ww w.  j  ava 2  s . c  om

    handleToken(node.getName(), TokenNameLBRACE,
            this.options.insert_space_before_opening_brace_in_type_declaration, false);
    handleCommas(node.superInterfaceTypes(), this.options.insert_space_before_comma_in_superinterfaces,
            this.options.insert_space_after_comma_in_superinterfaces);
    return true;
}

From source file:com.crispico.flower.codesync.tests.java.JavaTestsOnSourceCode.java

License:Open Source License

public SimpleType getInterfaceType(TypeDeclaration class_, String interfaceName) {
    for (Type interfaceType : (List<Type>) class_.superInterfaceTypes())
        if (interfaceName.equals(interfaceType.toString()))
            return (SimpleType) interfaceType;
    throw new IllegalArgumentException(
            "Could not find interface " + interfaceName + " in class " + class_.getName());
}

From source file:com.crispico.flower.mp.metamodel.codesyncjava.algorithm.forward.ForwardJavaClass_OwnedRealizations.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from   w ww  . jav a  2  s. c o  m*/
protected Type createAndAddNewASTElement(InterfaceRealization modelElement, CompilationUnit parentAstElement) {
    AST ast = parentAstElement.getAST();
    Type interfaceType = JavaSyncUtils.getJavaTypeFromString(ast, modelElement.getContract().getName(), false);

    TypeDeclaration parentClass = JavaSyncUtils.getMasterClass((CompilationUnit) parentAstElement);
    parentClass.superInterfaceTypes().add(interfaceType);
    return interfaceType;
}

From source file:com.crispico.flower.mp.metamodel.codesyncjava.algorithm.forward.ForwardJavaGeneralization.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from  ww  w .jav a  2 s . c o  m*/
protected void setASTFeatureValue(EStructuralFeature feature, Type astElement, Object value)
        throws CodeSyncException {
    if (astElement == null)
        throw new IllegalArgumentException("astElement null ");
    AST ast = astElement.getAST();
    switch (feature.getFeatureID()) {
    case UMLPackage.GENERALIZATION__GENERAL:
        parentForwardJavaInterface_OwnedGeneralizations.parentForwardJavaType.parentForwardJavaSrcDir_Files
                .createImportDeclarationIfNeeded((org.eclipse.uml2.uml.Type) value);
        String newInterfaceName = ((Interface) value).getName();
        TypeDeclaration parentClass = JavaSyncUtils.getMasterClass((CompilationUnit) currentCompialtionUnit);
        parentClass.superInterfaceTypes().set(parentClass.superInterfaceTypes().indexOf(astElement),
                JavaSyncUtils.getJavaTypeFromString(ast, newInterfaceName, false));
        break;
    default:
        throw new IllegalArgumentException("Cannot get value for feature in ReversePLField:" + feature);
    }
}

From source file:com.crispico.flower.mp.metamodel.codesyncjava.algorithm.forward.ForwardJavaInterface_OwnedGeneralizations.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  w  w  w.j  av a  2  s  . c  o m
protected Type createAndAddNewASTElement(Generalization modelElement, CompilationUnit parentAstElement) {
    AST ast = parentAstElement.getAST();
    Type interfaceType = JavaSyncUtils.getJavaTypeFromString(ast, modelElement.getGeneral().getName(), false);

    TypeDeclaration parentClass = JavaSyncUtils.getMasterClass((CompilationUnit) parentAstElement);
    parentClass.superInterfaceTypes().add(interfaceType);
    return interfaceType;
}