diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-09-08 14:33:21 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-08 19:38:17 +0000 |
commit | c0f162caab6098b1709cce893c2c86fec88d0d4c (patch) | |
tree | 2ab5f397b023efda122a25c1cf374e3ef9c4da97 /yarp | |
parent | 5d73c0f3dfa489ec3380b997dd151a07e790562a (diff) |
[ruby/yarp] Template out a comment_targets method
https://github.com/ruby/yarp/commit/a94af7c4c8
Diffstat (limited to 'yarp')
-rw-r--r-- | yarp/templates/lib/yarp/node.rb.erb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/yarp/templates/lib/yarp/node.rb.erb b/yarp/templates/lib/yarp/node.rb.erb index 0d40406360..9cc4495986 100644 --- a/yarp/templates/lib/yarp/node.rb.erb +++ b/yarp/templates/lib/yarp/node.rb.erb @@ -48,6 +48,16 @@ module YARP }.compact.join(", ") %>] end + # def comment_targets: () -> Array[Node | Location] + def comment_targets + [<%= node.fields.map { |field| + case field + when YARP::NodeField, YARP::LocationField then field.name + when YARP::OptionalNodeField, YARP::NodeListField, YARP::OptionalLocationField then "*#{field.name}" + end + }.compact.join(", ") %>] + end + # def copy: (**params) -> <%= node.name %> def copy(**params) <%= node.name %>.new( |