예제 #1
0
    // 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;
    }
예제 #2
0
 public int offset() {
   return node.from();
 }
예제 #3
0
 public CharSequence image() {
   return node.image();
 }