ruby-syntax-tree / syntax_tree

Interact with the Ruby syntax tree
https://ruby-syntax-tree.github.io/syntax_tree/
MIT License
563 stars 54 forks source link

Formatting fixes for YARP #394

Open csabahenk opened 1 year ago

csabahenk commented 1 year ago

Following issues are addressed:

---
"constant misnomer (has: AssocSplat, should have: AssocSplatNode) brings on formatting failure": "{a => b}"
hash label key duplicated: "{a: b}"
identity hash formatting failure: "{a:}"
mixed hash content loss: "{a => b, c: d}"
funcall with kwargs gets bogus '=>': "fun(a: b)"
"empty #call formatting failure": fun[]
"#-@ appended to arg": "-1"
empty funcall formatting failure: fun()
empty super call formatting failure: super()
ternary conditional formatting failure: "a ? b : c"
incorrect postfix unless for compound statements: unless a; b; c; end
AlternationPatternNode: foo => bar | baz
CallOperatorAndWriteNode: foo.bar &&= value
CallOperatorOrWriteNode: foo.bar ||= value
ClassVariableOperatorAndWriteNode: "@https://github.com/target &&= value"
ClassVariableOperatorOrWriteNode: "@https://github.com/target ||= value"
ClassVariableOperatorWriteNode: "@https://github.com/target += value"
ConstantOperatorAndWriteNode: Target &&= value
ConstantOperatorOrWriteNode: Target ||= value
ConstantOperatorWriteNode: Target += value
ConstantPathOperatorWriteNode: Parent::Child += value
ConstantPathOperatorAndWriteNode: Parent::Child &&= value
ConstantPathOperatorOrWriteNode: Parent::Child ||= value
GlobalVariableOperatorAndWriteNode: $target &&= value
GlobalVariableOperatorOrWriteNode: $target ||= value
GlobalVariableOperatorWriteNode: $target += value
InstanceVariableOperatorAndWriteNode: "https://github.com/target &&= value"
InstanceVariableOperatorOrWriteNode: "https://github.com/target ||= value"
InstanceVariableOperatorWriteNode: "https://github.com/target += value"
KeywordHashNode: "[**{}]"
LocalVariableOperatorAndWriteNode: target &&= value
LocalVariableOperatorOrWriteNode: target ||= value
OrNode: left or right
RequiredDestructuredParameterNode: def foo((bar, baz)); end
SourceFileNode: __FILE__
SourceLineNode: __LINE__
SourceEncodingNode: __ENCODING__

Notes:

Tested with YARP 0eb5f7c3..

csabahenk commented 1 year ago

As the build setup does not integrate YARP (which is not even available on Rubygems.org ATM), all CI cases fail on require "yarp",