use of org.eclipse.jdt.core.dom.AnonymousClassDeclaration in project flux by eclipse.
the class Bindings method getBindingOfParentTypeContext.
/**
* Returns the type binding of the node's type context or null if the node is inside
* an annotation, type parameter, super type declaration, or Javadoc of a top level type.
* The result of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in the type's body.
*
* @param node an AST node
* @return the type binding of the node's parent type context, or <code>null</code>
*/
public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) {
StructuralPropertyDescriptor lastLocation = null;
while (node != null) {
if (node instanceof AbstractTypeDeclaration) {
AbstractTypeDeclaration decl = (AbstractTypeDeclaration) node;
if (lastLocation == decl.getBodyDeclarationsProperty() || lastLocation == decl.getJavadocProperty()) {
return decl.resolveBinding();
} else if (decl instanceof EnumDeclaration && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) {
return decl.resolveBinding();
}
} else if (node instanceof AnonymousClassDeclaration) {
return ((AnonymousClassDeclaration) node).resolveBinding();
}
lastLocation = node.getLocationInParent();
node = node.getParent();
}
return null;
}
use of org.eclipse.jdt.core.dom.AnonymousClassDeclaration in project AutoRefactor by JnRouvignac.
the class RemoveSemiColonRefactoring method visit.
private boolean visit(BodyDeclaration node) {
final BodyDeclaration nextSibling = getNextSibling(node);
final ASTNode parent = node.getParent();
if (nextSibling != null) {
return removeSuperfluousSemiColons(node, getEndPosition(node), nextSibling.getStartPosition());
} else if (parent instanceof AbstractTypeDeclaration) {
final AbstractTypeDeclaration typeDecl = (AbstractTypeDeclaration) parent;
return removeSuperfluousSemiColons(node, getEndPosition(node), getEndPosition(typeDecl) - 1);
} else if (parent instanceof AnonymousClassDeclaration) {
final AnonymousClassDeclaration classDecl = (AnonymousClassDeclaration) parent;
return removeSuperfluousSemiColons(node, getEndPosition(node), getEndPosition(classDecl) - 1);
} else if (parent instanceof CompilationUnit) {
final CompilationUnit cu = (CompilationUnit) parent;
return removeSuperfluousSemiColons(node, getEndPosition(node), getEndPosition(cu) - 1);
} else if (parent instanceof TypeDeclarationStatement) {
return VISIT_SUBTREE;
}
throw new NotImplementedException(node, "for a parent of type " + (parent != null ? parent.getClass().getSimpleName() : null));
}
Aggregations