Module: Jade::Frontend::CommentAttacher
- Extended by:
- CommentAttacher
- Included in:
- CommentAttacher
- Defined in:
- lib/jade/frontend/comment_attacher.rb
Defined Under Namespace
Modules: CommentEntry Classes: CommentGroup
Constant Summary collapse
- SKIP_FIELDS =
%i[range symbol id leading_comments trailing_comments dangling_comments].freeze
Instance Method Summary collapse
Instance Method Details
#attach(ast, comments, source) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jade/frontend/comment_attacher.rb', line 8 def attach(ast, comments, source) return ast if comments.empty? collect_nodes(ast) .reject { |n| n.range.nil? } # Outermost first, so `x = f(y)` anchors on the Assign rather # than the pattern nested inside it. .sort_by { |n| [n.range.begin, -n.range.size] } .then { build_map(comments, it, source) } .then { reattach(ast, it) } end |