@@ -69,7 +69,20 @@ def initialize(string, location)
6969 end
7070
7171 class Annotation < Comment ; end
72- class Signature < Comment ; end
72+
73+ class Signature < Comment
74+ # Locations of the `#|` continuation comment lines that make up a multiline signature,
75+ # in addition to the `#:` line tracked by `location`.
76+ #: Array[Prism::Location]
77+ attr_reader :continuation_locations
78+
79+ #: (String, Prism::Location, ?continuation_locations: Array[Prism::Location]) -> void
80+ def initialize ( string , location , continuation_locations : [ ] )
81+ super ( string , location )
82+ @continuation_locations = continuation_locations
83+ end
84+ end
85+
7386 class TypeAlias < Comment ; end
7487
7588 module ExtractRBSComments
@@ -99,16 +112,18 @@ def node_rbs_comments(node)
99112 elsif string . start_with? ( "#: " )
100113 string = string . delete_prefix ( "#:" ) . strip
101114 location = comment . location
115+ continuation_locations = [ ] #: Array[Prism::Location]
102116
103117 continuation_comments . reverse_each do |continuation_comment |
104118 string = "#{ string } #{ continuation_comment . slice . delete_prefix ( "#|" ) } "
105119 location = location . join ( continuation_comment . location )
120+ continuation_locations << continuation_comment . location
106121 end
107122 continuation_comments . clear
108123
109124 next if string . start_with? ( "type " )
110125
111- res . signatures . prepend ( Signature . new ( string , location ) )
126+ res . signatures . prepend ( Signature . new ( string , location , continuation_locations : ) )
112127 elsif string . start_with? ( "#|" )
113128 continuation_comments << comment
114129 end
0 commit comments