List of usage examples for org.eclipse.jdt.core.dom TypeDeclaration SUPERCLASS_TYPE_PROPERTY
ChildPropertyDescriptor SUPERCLASS_TYPE_PROPERTY
To view the source code for org.eclipse.jdt.core.dom TypeDeclaration SUPERCLASS_TYPE_PROPERTY.
Click Source Link
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 . java2 s . c om*/ 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 w w w . j a va 2 s . c o m*/ 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:edu.illinois.compositerefactorings.steps.CreateNewSuperclass.java
License:Open Source License
@Override public Collection<ASTRewriteCorrectionProposal> getProposals(Object input) throws CoreException { TypeDeclaration typeDeclaration = (TypeDeclaration) input; ASTNode node = typeDeclaration.getParent(); AST ast = node.getAST();/*from w ww .j ava 2s .c om*/ ASTRewrite rewrite = ASTRewrite.create(ast); String label = MessageFormat.format(CompositeRefactoringsMessages.CreateNewSuperclass_description, typeDeclaration.getName(), getCompilationUnit().getElementName()); Image image = JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC); ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, getCompilationUnit(), rewrite, 0, image); TypeDeclaration newSuperclass = ast.newTypeDeclaration(); newSuperclass.setName(ast.newSimpleName("Super" + typeDeclaration.getName())); ListRewrite listRewrite = rewrite.getListRewrite(node, CompilationUnit.TYPES_PROPERTY); listRewrite.insertLast(newSuperclass, null); rewrite.set(newSuperclass, TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, typeDeclaration.getStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY), null); rewrite.set(typeDeclaration, TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, newSuperclass.getName(), null); Collection<ASTRewriteCorrectionProposal> proposals = new ArrayList<ASTRewriteCorrectionProposal>(); proposals.add(proposal); return proposals; }
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 * //from w ww. ja va 2 s. c o m * 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 setSuperclass(String superclassName) { this.superclassName = superclassName; setNodeProperty(getASTNode(), superclassName, TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, ASTNode.SIMPLE_TYPE);//from w w w. ja va 2s .c o m }
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();//w w w .j a v a2 s .co m 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.jboss.forge.parser.java.impl.JavaClassImpl.java
License:Open Source License
@Override public String getSuperType() { Object superType = getBodyDeclaration().getStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY); if (superType == null) superType = Object.class.getName(); return resolveType(superType.toString()); }
From source file:org.jboss.forge.parser.java.impl.JavaClassImpl.java
License:Open Source License
@Override public JavaClass setSuperType(final String type) { SimpleType simpleType = body.getAST().newSimpleType(body.getAST().newSimpleName(Types.toSimpleName(type))); getBodyDeclaration().setStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, simpleType); if (!hasImport(type) && Types.isQualified(type)) { addImport(type);//ww w .j a v a 2 s .c om } return this; }
From source file:org.jboss.forge.roaster.model.impl.JavaClassImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from www.j a v a 2s . c o m*/ public JavaClassSource setSuperType(final String type) { if (type == null || type.trim().isEmpty()) { getBodyDeclaration().setStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, null); } else if (Types.isGeneric(type)) { String typeD = Types.stripGenerics(type); String sympleTypeDName = Types.toSimpleName(typeD); String typesGeneric = Types.getGenericsTypeParameter(type); org.eclipse.jdt.core.dom.ParameterizedType pt = body.getAST().newParameterizedType( body.getAST().newSimpleType(body.getAST().newSimpleName(sympleTypeDName))); if (!hasImport(typeD) && Types.isQualified(typeD)) { addImport(typeD); } for (String typeP : typesGeneric.split(",")) { pt.typeArguments().add( body.getAST().newSimpleType(body.getAST().newSimpleName(Types.toSimpleName(typeP.trim())))); if (!hasImport(typeP) && Types.isQualified(typeP)) { addImport(typeP); } } getBodyDeclaration().setStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, pt); } else { SimpleType simpleType = body.getAST() .newSimpleType(body.getAST().newSimpleName(Types.toSimpleName(type))); getBodyDeclaration().setStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, simpleType); if (!hasImport(type) && Types.isQualified(type)) { addImport(type); } } return this; }
From source file:org.jboss.windup.rules.apps.java.scan.ast.VariableResolvingASTVisitor.java
License:Open Source License
public boolean visit(TypeDeclaration node) { Object clzInterfaces = node.getStructuralProperty(TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY); Object clzSuperClasses = node.getStructuralProperty(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY); if (clzInterfaces != null) { if (List.class.isAssignableFrom(clzInterfaces.getClass())) { List<?> clzInterfacesList = (List<?>) clzInterfaces; for (Object clzInterface : clzInterfacesList) { if (clzInterface instanceof SimpleType) { processType((SimpleType) clzInterface, TypeReferenceLocation.IMPLEMENTS_TYPE); } else { LOG.trace("" + clzInterface); }/* w w w .j a v a 2s .co m*/ } } } if (clzSuperClasses != null) { if (clzSuperClasses instanceof SimpleType) { processType((SimpleType) clzSuperClasses, TypeReferenceLocation.EXTENDS_TYPE); } else { LOG.trace("" + clzSuperClasses); } } return super.visit(node); }