Skip to content
  • Kevin Newton's avatar
    ddacc085
    [ruby/prism] Remove string concat in favor of a flat list · ddacc085
    Kevin Newton authored
    Right now when you have a lot of string concats it ends up being
    difficult to work with because of the depth of the tree. You end
    up descending very far for every string literal that is part of the
    concat.
    
    There are already times when we use an interpolated string node to
    group together two string segments that are part of the same string
    (like when they are interupted by the contents of a heredoc). This
    commit takes the same approach and replaces string concats with
    interpolated string nodes.
    
    Now that they're a flat list, they should be much easier to work
    with. There's still some missing information here that would be
    useful to consumers: whether or not there is _actually_ any
    interpolation contained in the list. We could remedy this with
    another node type that is named something like string list, or we
    could add a flag to interpolated string node indicating that there
    is interpolation. Either way I want to solve that in a follow-up
    commit, since this commit is valuable on its own.
    
    https://github.com/ruby/prism/commit/1e7ae3ad1b
    ddacc085
    [ruby/prism] Remove string concat in favor of a flat list
    Kevin Newton authored
    Right now when you have a lot of string concats it ends up being
    difficult to work with because of the depth of the tree. You end
    up descending very far for every string literal that is part of the
    concat.
    
    There are already times when we use an interpolated string node to
    group together two string segments that are part of the same string
    (like when they are interupted by the contents of a heredoc). This
    commit takes the same approach and replaces string concats with
    interpolated string nodes.
    
    Now that they're a flat list, they should be much easier to work
    with. There's still some missing information here that would be
    useful to consumers: whether or not there is _actually_ any
    interpolation contained in the list. We could remedy this with
    another node type that is named something like string list, or we
    could add a flag to interpolated string node indicating that there
    is interpolation. Either way I want to solve that in a follow-up
    commit, since this commit is valuable on its own.
    
    https://github.com/ruby/prism/commit/1e7ae3ad1b
Loading