public static List<BodyDeclaration> getBodyDeclarationList(IType iType, CompilationUnit cuNode) throws JavaModelException { if (iType.isAnonymous()) return getClassInstanceCreationNode(iType, cuNode).getAnonymousClassDeclaration().bodyDeclarations(); else return getAbstractTypeDeclarationNode(iType, cuNode).bodyDeclarations(); }
public static List getBodyDeclarationList(IType iType, CompilationUnit cuNode) throws JavaModelException { if (iType.isAnonymous()) return getClassInstanceCreationNode(iType, cuNode).getAnonymousClassDeclaration().bodyDeclarations(); else return getAbstractTypeDeclarationNode(iType, cuNode).bodyDeclarations(); }
public static List<BodyDeclaration> getBodyDeclarationList(IType iType, CompilationUnit cuNode) throws JavaModelException { if (iType.isAnonymous()) return getClassInstanceCreationNode(iType, cuNode).getAnonymousClassDeclaration().bodyDeclarations(); else return getAbstractTypeDeclarationNode(iType, cuNode).bodyDeclarations(); }
private ASTNode getDestinationNode(IJavaElement destination, CompilationUnit target) throws JavaModelException { switch (destination.getElementType()) { case IJavaElement.INITIALIZER: return ASTNodeSearchUtil.getInitializerNode((IInitializer) destination, target); case IJavaElement.FIELD: return ASTNodeSearchUtil.getFieldOrEnumConstantDeclaration((IField) destination, target); case IJavaElement.METHOD: return ASTNodeSearchUtil.getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) destination, target); case IJavaElement.TYPE: IType typeDestination= (IType) destination; if (typeDestination.isAnonymous()) { return ASTNodeSearchUtil.getClassInstanceCreationNode(typeDestination, target).getAnonymousClassDeclaration(); } else { return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(typeDestination, target); } case IJavaElement.COMPILATION_UNIT: IType mainType= JavaElementUtil.getMainType((ICompilationUnit) destination); if (mainType != null) { return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(mainType, target); } //$FALL-THROUGH$ default: return null; } }
private ASTNode getDestinationNode(IJavaElement destination, CompilationUnit target) throws JavaModelException { switch (destination.getElementType()) { case IJavaElement.INITIALIZER: return ASTNodeSearchUtil.getInitializerNode((IInitializer) destination, target); case IJavaElement.FIELD: return ASTNodeSearchUtil.getFieldOrEnumConstantDeclaration((IField) destination, target); case IJavaElement.METHOD: return ASTNodeSearchUtil.getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) destination, target); case IJavaElement.TYPE: IType typeDestination= (IType) destination; if (typeDestination.isAnonymous()) { return ASTNodeSearchUtil.getClassInstanceCreationNode(typeDestination, target).getAnonymousClassDeclaration(); } else { return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(typeDestination, target); } case IJavaElement.COMPILATION_UNIT: IType mainType= JavaElementUtil.getMainType((ICompilationUnit) destination); if (mainType != null) { return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(mainType, target); } //$FALL-THROUGH$ default: return null; } }
IType typeDestination= (IType) javaElementDestination; if (typeDestination.isAnonymous()) destinationContainer= ASTNodeSearchUtil.getClassInstanceCreationNode(typeDestination, targetCuNode).getAnonymousClassDeclaration(); else destinationContainer= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(typeDestination, targetCuNode);
private static ASTNode[] getNodesToDelete(IJavaElement element, CompilationUnit cuNode) throws JavaModelException { // fields are different because you don't delete the whole declaration but only a fragment of it if (element.getElementType() == IJavaElement.FIELD) { if (JdtFlags.isEnum((IField) element)) return new ASTNode[] { ASTNodeSearchUtil.getEnumConstantDeclaration((IField) element, cuNode)}; else return new ASTNode[] { ASTNodeSearchUtil.getFieldDeclarationFragmentNode((IField) element, cuNode)}; } if (element.getElementType() == IJavaElement.TYPE && ((IType) element).isLocal()) { IType type= (IType) element; if (type.isAnonymous()) { if (type.getParent().getElementType() == IJavaElement.FIELD) { final ISourceRange range= type.getSourceRange(); if (range != null) { final ASTNode node= ASTNodeSearchUtil.getAstNode(cuNode, range.getOffset(), range.getLength()); if (node instanceof AnonymousClassDeclaration) return new ASTNode[] { node}; } } return new ASTNode[] { ASTNodeSearchUtil.getClassInstanceCreationNode(type, cuNode)}; } else { ASTNode[] nodes= ASTNodeSearchUtil.getDeclarationNodes(element, cuNode); // we have to delete the TypeDeclarationStatement nodes[0]= nodes[0].getParent(); return nodes; } } return ASTNodeSearchUtil.getDeclarationNodes(element, cuNode); }
ClassInstanceCreation creation= ASTNodeSearchUtil.getClassInstanceCreationNode(type, cuNode); if (creation != null) { if (creation.getLocationInParent() == ExpressionStatement.EXPRESSION_PROPERTY) {
ClassInstanceCreation creation= ASTNodeSearchUtil.getClassInstanceCreationNode(type, cuNode); if (creation != null) { if (creation.getLocationInParent() == ExpressionStatement.EXPRESSION_PROPERTY) {