ruby-syntax-tree / syntax_tree

Interact with the Ruby syntax tree

Home Page:https://ruby-syntax-tree.github.io/syntax_tree/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Body of block missing from AST

andyw8 opened this issue · comments

With this code:

MyClass.call 1 do
  if true
    # ...
  end
end

Output from stree ast:

(program (statements ((command_call (var_ref (const "MyClass")) (period ".") (ident "call") (args ((int "1")))))))

With the 1 in parentheses the output is as expected:

(program
  (statements
    ((method_add_block
        (call (var_ref (const "MyClass")) (period ".") (ident "call") (arg_paren (args ((int "1")))))
        (block (bodystmt (statements ((if (var_ref (kw "true")) (statements ((void_stmt), (comment "# ..."))))))))))))

syntax_tree 6.0.0

Original context: Shopify/ruby-lsp#515

@andyw8 there are 2 bugs here. The first is in Syntax Tree - I forgot to add the block to the AST output when I added blocks to Command and CommandCall nodes. The second is in Ruby LSP - when you upgraded to Syntax Tree 5, you forgot to add the blocks to the folding ranges that were attached to Command and CommandCall nodes. I'll get the one in stree fixed up if you can fix up the one here?

Thanks @kddnewton, yes I can update Ruby LSP.