summaryrefslogtreecommitdiff
path: root/yarp
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-09-08 14:33:21 -0400
committergit <svn-admin@ruby-lang.org>2023-09-08 19:38:17 +0000
commitc0f162caab6098b1709cce893c2c86fec88d0d4c (patch)
tree2ab5f397b023efda122a25c1cf374e3ef9c4da97 /yarp
parent5d73c0f3dfa489ec3380b997dd151a07e790562a (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.erb10
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(