/**
* If the given {@link AstNode} has an {@link Element} at the given offset, then returns
* {@link Reference} with this {@link Element}.
*/
private Reference getReferenceAtNode(AstNode root, int offset) {
AstNode node = new NodeLocator(offset).searchWithin(root);
if (node != null) {
Element element = ElementLocator.locate(node);
return new Reference(element, node.getOffset(), node.getLength());
}
return null;