Skip to content

Commit

Permalink
Make NodeKindField subclass NodeKindField
Browse files Browse the repository at this point in the history
* To avoid duplication.
  • Loading branch information
eregon committed Feb 28, 2024
1 parent 33e987b commit 12e5aae
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions templates/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def rbi_class

# This represents a field on a node that is a list of nodes. We pass them as
# references and store them directly on the struct.
class NodeListField < Field
class NodeListField < NodeKindField
def rbs_class
if specific_kind
"Array[#{specific_kind}]"
Expand All @@ -161,20 +161,7 @@ def rbi_class
end

def java_type
if specific_kind
"#{specific_kind}[]"
else
"Node[]"
end
end

# TODO: unduplicate with NodeKindField
def specific_kind
options[:kind] unless options[:kind].is_a?(Array)
end

def union_kind
options[:kind] if options[:kind].is_a?(Array)
"#{super}[]"
end
end

Expand Down

0 comments on commit 12e5aae

Please sign in to comment.