use of org.eclipse.jdt.core.dom.UnionType in project flux by eclipse.
the class ASTNodes method getTopMostType.
/**
* Returns the topmost ancestor of <code>node</code> that is a {@link Type} (but not a {@link UnionType}).
* <p>
* <b>Note:</b> The returned node often resolves to a different binding than the given <code>node</code>!
*
* @param node the starting node, can be <code>null</code>
* @return the topmost type or <code>null</code> if the node is not a descendant of a type node
* @see #getNormalizedNode(ASTNode)
*/
public static Type getTopMostType(ASTNode node) {
ASTNode result = null;
while (node instanceof Type && !(node instanceof UnionType) || node instanceof Name || node instanceof Annotation || node instanceof MemberValuePair || node instanceof Expression) {
// Expression could maybe be reduced to expression node types that can appear in an annotation
result = node;
node = node.getParent();
}
if (result instanceof Type)
return (Type) result;
return null;
}
Aggregations