Conversation
fc643c4 to
0235374
Compare
|
Wouldn't you want require 'prism'
code = <<'RUBY'
"a\nb"
RUBY
node = Prism.parse(code).value.statements.body[0]
pp node
p node.content
p node.unescapedgives: |
|
SymbolNode does indeed name |
|
Or IOW, I would expect (apologies for the many comments, just trying to explain my thoughts on this) |
|
That did not cross my mind. Yes, I would want the unescaped one and have probably not done so many times when I should have for correctness. Let me update this to a different approach. However I'm not so convinced anymore since the distinction between value/content is not immediatly obvious when both are present. |
|
Yeah I'm very hesitant on this. If I were to call |
|
Not sure I'm following. What should |
I believe Kevin means with the newline resolved, since it would be a Symbol object corresponding to the source. I'd imagine changing SymbolNode#value to return a Symbol instead of a String is tough for compatibility. |
0235374 to
f92d9b5
Compare
content fields to valueSymbolNode#value_loc to SymbolNode#content_loc
f92d9b5 to
1c8aca6
Compare
Makes it consistent with nodes that contain text, like `StringNode` For those, `value` returns the literal. But we can't make it return a symbol for backwards compatibility.
1c8aca6 to
7c1e135
Compare
Currently there are 43 matches for
name: valueand only 4 forname: contentinconfig.ymlRationalNode/ImaginaryNodealso havevaluefrom node extensions.(of course, most of the 43 are not for literals but for child nodes like in the RHS of
a = 1)The one I particularly care about is
StringNodebecause I often handleSymbolNodeandStringNodethe same way but I have to write different code becaues the fields are not named the same. This allows to ducktype them and I don't have to keep in mind when to usecontentvsvalue.valuefor a literal also sounds better to me.Same as in #4060, keep the previous names around.