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

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

Introduction

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

Prototype

ChildListPropertyDescriptor SUPER_INTERFACE_TYPES_PROPERTY

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

Click Source Link

Document

The "superInterfaceTypes" structural property of this node type (element type: Type ) (added in JLS3 API).

Usage

From source file:de.ovgu.cide.export.physical.ahead.JakColorChecker.java

License:Open Source License

private boolean isExtendsOrImplements(ASTNode node) {
    if (isMovableType(node.getParent())) {
        if (node.getLocationInParent() == TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY) {
            return true;
        }/*from  w  ww  .j ava2 s  .  com*/
        if (node.getLocationInParent() == TypeDeclaration.SUPERCLASS_TYPE_PROPERTY) {
            return true;
        }
    }
    return false;
}

From source file:de.ovgu.cide.language.jdt.SimplePrintVisitor.java

License:Open Source License

public boolean visit(IASTNode node) {
    if (node instanceof ASTStringNode) {
        printToken(((ASTStringNode) node).getValue());
        return false;
    }/*from www .  ja  va2 s  . c  om*/
    if (node instanceof ASTTextNode) {
        printToken(((ASTTextNode) node).getValue());
        return false;
    }
    if (node instanceof UnifiedASTNode) {
        UnifiedASTNode unode = (UnifiedASTNode) node;

        if (unode.getEclipseASTNodeClass().equals("AnnotationTypeDeclaration")) {

            accept(node, AnnotationTypeDeclaration.JAVADOC_PROPERTY.getId());

        }

        if (unode.getEclipseASTNodeClass().equals(CompilationUnit.class.getSimpleName())) {
            accept(unode, CompilationUnit.PACKAGE_PROPERTY.getId());
            accept(unode, CompilationUnit.IMPORTS_PROPERTY.getId());
            accept(unode, CompilationUnit.TYPES_PROPERTY.getId());
        }

        if (unode.getEclipseASTNodeClass().equals(TypeDeclaration.class.getSimpleName())) {

            accept(node, TypeDeclaration.JAVADOC_PROPERTY.getId());
            accept(node, TypeDeclaration.MODIFIERS2_PROPERTY.getId());
            accept(node, TypeDeclaration.INTERFACE_PROPERTY.getId());
            accept(node, TypeDeclaration.NAME_PROPERTY.getId());
            accept(node, TypeDeclaration.TYPE_PARAMETERS_PROPERTY.getId(), "<", ",", ">", true);
            //            this.buffer.append(" ");//$NON-NLS-1$

            accept(node, TypeDeclaration.SUPERCLASS_TYPE_PROPERTY.getId(), "extends", "", "", false);
            accept(node, TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY.getId(), "implements", ",", "", false);
            printToken("{");
            hintNewLine();
            hintIncIndent();

            accept(node, TypeDeclaration.BODY_DECLARATIONS_PROPERTY.getId());

            hintDecIndent();
            printToken("}");
            hintNewLine();
        }

        printToken(unode.getEclipseASTNodeClass());
    }
    return false;
}

From source file:org.eclipse.ajdt.internal.ui.refactoring.PushInRefactoring.java

License:Open Source License

/**
 * Adds the specified new parents to the type.
 * Need to determine if the new paretns are extends or implements
 * /*  w w  w  .j  a  v a 2  s .c  om*/
 * FIXADE will not handle generic types
 * @param targetType
 * @param astUnit
 * @param newParents
 * @param holder
 * @throws JavaModelException 
 */
@SuppressWarnings("unchecked")
private void rewriteDeclareParents(IType targetType, CompilationUnit astUnit, Set<String> newParents,
        ICompilationUnit unit) throws JavaModelException {

    // find the Type declaration in the ast
    TypeDeclaration typeDecl = findType(astUnit, targetType.getElementName());
    if (typeDecl == null) {
        createJavaModelException(
                "Couldn't find type " + targetType.getElementName() + " in " + unit.getElementName());
    }

    // convert all parents to simple names
    List<String> simpleParents = new ArrayList<String>(newParents.size());
    for (String qual : newParents) {
        simpleParents.add(convertToSimple(qual));
    }

    // now remove any possible duplicates
    Type superclassType = typeDecl.getSuperclassType();
    Type supr = superclassType;
    if (supr != null && supr.isSimpleType()) {
        simpleParents.remove(((SimpleType) supr).getName().getFullyQualifiedName());
    }
    for (Type iface : (Iterable<Type>) typeDecl.superInterfaceTypes()) {
        if (iface.isSimpleType()) {
            simpleParents.remove(((SimpleType) iface).getName().getFullyQualifiedName());
        }
    }

    // Find the super class if exists
    // make assumption that there is at most one super class defined.
    // if this weren't the case, then there would be a compile error
    // and it would not be possible to invoke refactoring
    String newSuper = null;
    for (String parent : newParents) {
        if (isClass(parent, targetType)) {
            newSuper = convertToSimple(parent);
            simpleParents.remove(newSuper);
        }
    }

    // do the rewrite.  Only need to add simple names since imports are already taken care of
    // in the holder
    ASTRewrite rewriter = ASTRewrite.create(astUnit.getAST());
    AST ast = typeDecl.getAST();
    if (newSuper != null) {
        Type newSuperType = createTypeAST(newSuper, ast);
        if (superclassType == null) {
            rewriter.set(typeDecl, TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, newSuperType, null);
        } else {
            rewriter.replace(superclassType, newSuperType, null);
        }
    }
    if (simpleParents.size() > 0) {
        ListRewrite listRewrite = rewriter.getListRewrite(typeDecl,
                TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY);
        for (String simpleParent : simpleParents) {
            listRewrite.insertLast(createTypeAST(simpleParent, ast), null);
        }
    }
    // finally, add the new change
    TextEdit edit = rewriter.rewriteAST();
    if (!isEmptyEdit(edit)) {
        TextFileChange change = (TextFileChange) allChanges.get(unit);
        if (change == null) {
            change = new TextFileChange(unit.getElementName(), (IFile) unit.getResource());
            change.setTextType("java");
            change.setEdit(new MultiTextEdit());
            allChanges.put(unit, change);
        }
        change.getEdit().addChild(edit);
    }
}

From source file:org.eclipse.emf.codegen.merge.java.facade.ast.ASTJType.java

License:Open Source License

public void setSuperInterfaces(String[] interfaceNames) {
    this.superInterfaces = interfaceNames;
    this.addedSuperInterfaces = null;
    setListNodeProperty(getASTNode(), interfaceNames, TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY,
            ASTNode.SIMPLE_TYPE);//from w  w  w .j av  a  2s.  c o m
}

From source file:org.eclipse.emf.codegen.merge.java.facade.ast.ASTJType.java

License:Open Source License

public void addSuperInterface(String superInterface) {
    if (addedSuperInterfaces == null) {
        addedSuperInterfaces = new ArrayList<String>();
    }//from w w w.jav  a  2  s . c  o m
    addedSuperInterfaces.add(superInterface);
    addValueToListProperty(getASTNode(), superInterface, TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY,
            ASTNode.SIMPLE_TYPE);
}

From source file:org.eclipse.scout.sdk.saml.importer.internal.jdt.imports.OrganizeImportsHelper.java

License:Open Source License

private static int internalGetPossibleTypeKinds(ASTNode node) {
    int kind = ALL_TYPES;

    int mask = ALL_TYPES | VOIDTYPE;

    ASTNode parent = node.getParent();//from  w w w  .  ja  v  a  2 s.c om
    while (parent instanceof QualifiedName) {
        if (node.getLocationInParent() == QualifiedName.QUALIFIER_PROPERTY) {
            return REF_TYPES;
        }
        node = parent;
        parent = parent.getParent();
        mask = REF_TYPES;
    }
    while (parent instanceof Type) {
        if (parent instanceof QualifiedType) {
            if (node.getLocationInParent() == QualifiedType.QUALIFIER_PROPERTY) {
                return mask & (REF_TYPES);
            }
            mask &= REF_TYPES;
        } else if (parent instanceof ParameterizedType) {
            if (node.getLocationInParent() == ParameterizedType.TYPE_ARGUMENTS_PROPERTY) {
                return mask & REF_TYPES_AND_VAR;
            }
            mask &= CLASSES | INTERFACES;
        } else if (parent instanceof WildcardType) {
            if (node.getLocationInParent() == WildcardType.BOUND_PROPERTY) {
                return mask & REF_TYPES_AND_VAR;
            }
        }
        node = parent;
        parent = parent.getParent();
    }

    switch (parent.getNodeType()) {
    case ASTNode.TYPE_DECLARATION:
        if (node.getLocationInParent() == TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY) {
            kind = INTERFACES;
        } else if (node.getLocationInParent() == TypeDeclaration.SUPERCLASS_TYPE_PROPERTY) {
            kind = CLASSES;
        }
        break;
    case ASTNode.ENUM_DECLARATION:
        kind = INTERFACES;
        break;
    case ASTNode.METHOD_DECLARATION:
        if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY) {
            kind = CLASSES;
        } else if (node.getLocationInParent() == MethodDeclaration.RETURN_TYPE2_PROPERTY) {
            kind = ALL_TYPES | VOIDTYPE;
        }
        break;
    case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
        kind = PRIMITIVETYPES | ANNOTATIONS | ENUMS;
        break;
    case ASTNode.INSTANCEOF_EXPRESSION:
        kind = REF_TYPES;
        break;
    case ASTNode.THROW_STATEMENT:
        kind = CLASSES;
        break;
    case ASTNode.CLASS_INSTANCE_CREATION:
        if (((ClassInstanceCreation) parent).getAnonymousClassDeclaration() == null) {
            kind = CLASSES;
        } else {
            kind = CLASSES | INTERFACES;
        }
        break;
    case ASTNode.SINGLE_VARIABLE_DECLARATION:
        int superParent = parent.getParent().getNodeType();
        if (superParent == ASTNode.CATCH_CLAUSE) {
            kind = CLASSES;
        }
        break;
    case ASTNode.TAG_ELEMENT:
        kind = REF_TYPES;
        break;
    case ASTNode.MARKER_ANNOTATION:
    case ASTNode.SINGLE_MEMBER_ANNOTATION:
    case ASTNode.NORMAL_ANNOTATION:
        kind = ANNOTATIONS;
        break;
    case ASTNode.TYPE_PARAMETER:
        if (((TypeParameter) parent).typeBounds().indexOf(node) > 0) {
            kind = INTERFACES;
        } else {
            kind = REF_TYPES_AND_VAR;
        }
        break;
    case ASTNode.TYPE_LITERAL:
        kind = REF_TYPES;
        break;
    default:
    }
    return kind & mask;
}

From source file:org.flowerplatform.codesync.code.java.type_provider.JavaTypeProvider.java

License:Open Source License

@Override
public String getType(Object object) {
    IFileAccessController fileAccessController = CorePlugin.getInstance().getFileAccessController();
    if (fileAccessController.isFile(object)) {
        if (fileAccessController.isDirectory(object)) {
            return CodeSyncCodeConstants.FOLDER;
        } else {/*  w  ww .  j a v  a 2 s . c o  m*/
            return CodeSyncCodeConstants.FILE;
        }
    } else if (object instanceof TypeDeclaration) {
        if (((TypeDeclaration) object).isInterface()) {
            return INTERFACE;
        } else {
            return CLASS;
        }
    } else if (object instanceof Annotation) {
        return ANNOTATION;
    } else if (object instanceof Expression || object instanceof Type) {
        ASTNode node = (ASTNode) object;
        StructuralPropertyDescriptor descriptor = node.getLocationInParent();
        if (descriptor.equals(TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY)
                || descriptor.equals(EnumDeclaration.SUPER_INTERFACE_TYPES_PROPERTY)) {
            return SUPER_INTERFACE;
        } else if (descriptor.equals(EnumConstantDeclaration.ARGUMENTS_PROPERTY)) {
            return ENUM_CONSTANT_ARGUMENT;
        }
        return null;
    } else {
        return directMap.get(object.getClass());
    }
}

From source file:org.jastemf.refactorings.RefactoringManager.java

License:BSD License

private static void performASTClassesAdaptations(final IIntegrationContext context, GenPackage genPackage)
        throws JastEMFException {
    for (final GenClass genClass : genPackage.getGenClasses()) {
        if (genClass.isInterface())
            continue;
        final IFile compilationUnitFile = IOSupport.getFile(context.classfolder(genPackage),
                genClass.getClassName() + ".java");

        final CompilationUnit compilationUnit = JDTSupport.loadCompilationUnit(compilationUnitFile);
        compilationUnit.recordModifications();

        ASTVisitor visitor = new BasicJDTASTVisitor(context) {
            @SuppressWarnings("unchecked")
            public boolean visit(TypeDeclaration decl) {
                IOSupport.log("Visiting " + decl.getName() + " ...");
                if (decl.isInterface())
                    return false;
                // Setting generated interface as super interface
                if (decl.getName().getIdentifier().equals(genClass.getClassName())) {
                    AST ast = decl.getAST();
                    List interfaces = (List) decl
                            .getStructuralProperty(TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY);
                    interfaces.add(ast.newSimpleType(ast.newName(genClass.getQualifiedInterfaceName())));
                    return true;
                }/*from   w w w  .ja  v a 2s  .c  o m*/
                return false;
            }
        };

        compilationUnit.accept(visitor);

        JDTSupport.applyRewritesAndSave(compilationUnit, compilationUnitFile);
    }
    for (GenPackage childPackage : genPackage.getNestedGenPackages()) {
        performASTClassesAdaptations(context, childPackage);
    }

}

From source file:org.jboss.forge.parser.java.impl.JDTHelper.java

License:Open Source License

@SuppressWarnings("unchecked")
public static List<Type> getInterfaces(final BodyDeclaration dec) {
    return (List<Type>) dec.getStructuralProperty(TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY);
}

From source file:org.jboss.forge.roaster.model.impl.JDTHelper.java

License:Open Source License

@SuppressWarnings("unchecked")
public static List<Type> getInterfaces(final BodyDeclaration dec) {
    StructuralPropertyDescriptor desc;/*from  w w w.  ja  va 2s  .  c  om*/
    if (dec instanceof EnumDeclaration) {
        desc = EnumDeclaration.SUPER_INTERFACE_TYPES_PROPERTY;
    } else {
        desc = TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY;
    }
    return (List<Type>) dec.getStructuralProperty(desc);
}