use of org.eclipse.jdt.core.dom.EnumDeclaration 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;
}
Aggregations