Class: Wool::SexpAnalysis::NextPrevAnnotation::Annotator

Inherits:
Object
  • Object
show all
Defined in:
lib/wool/analysis/annotations/next_annotation.rb

Overview

This is the annotator for the next and prev annotation.

Instance Method Summary collapse

Instance Method Details

#annotate!(root) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/wool/analysis/annotations/next_annotation.rb', line 12

def annotate!(root)
  children = root.children
  children.each_with_index do |elt, idx|
    # ignore non-sexps. Primitives can't be annotated, sadly.
    if SexpAnalysis::Sexp === elt
      elt.next = children[idx+1]
      elt.prev = children[idx-1] if idx >= 1
    end
  end
end