// XXX make it only caret position sensitive for now private Node findCurrentElement() { Node root = getParserResult().getParseTree(); int astOffset = getParserResult().getSnapshot().getEmbeddedOffset(caretOffset); Node leaf = NodeUtil.findNodeAtOffset(root, astOffset); if (leaf != null) { // we found token node, use its encolosing node - parent leaf = leaf.parent(); } // if leaf == null the astOffset is out of the root's node range, return the root node return leaf == null ? root : leaf; }
public int offset() { return node.from(); }
public CharSequence image() { return node.image(); }