@@ -161,12 +161,13 @@ def t_sig_without_runtime?(node)
161161 !!( node . is_a? ( Prism ::ConstantPathNode ) && node_string ( node ) =~ /(::)?T::Sig::WithoutRuntime/ )
162162 end
163163
164- #: (Prism::Node node) -> Array[Comment]
165- def node_comments ( node )
164+ #: (Prism::Node node, ?min_line: Integer? ) -> Array[Comment]
165+ def node_comments ( node , min_line : nil )
166166 comments = [ ]
167167
168168 start_line = node . location . start_line
169169 start_line -= 1 unless @comments_by_line . key? ( start_line )
170+ start_line = [ start_line , min_line ] . max if min_line
170171
171172 rbs_continuation = [ ] #: Array[Prism::Comment]
172173
@@ -767,7 +768,7 @@ def parse_params(node)
767768
768769 #: (Prism::CallNode node) -> Sig
769770 def parse_sig ( node )
770- builder = SigBuilder . new ( @source , file : @file )
771+ builder = SigBuilder . new ( @source , comments_by_line : @comments_by_line , file : @file )
771772 builder . current . loc = node_loc ( node )
772773 builder . visit_call_node ( node )
773774 builder . current . comments = node_comments ( node )
@@ -920,11 +921,15 @@ class SigBuilder < Visitor
920921 #: Sig
921922 attr_reader :current
922923
923- #: (String content, file: String) -> void
924- def initialize ( content , file :)
925- super
924+ #: Integer?
925+ attr_reader :params_start_line
926+
927+ #: (String content, comments_by_line: Hash[Integer, Prism::Comment], file: String) -> void
928+ def initialize ( content , comments_by_line :, file :)
929+ super ( content , comments_by_line : comments_by_line , file : file )
926930
927931 @current = Sig . new #: Sig
932+ @params_start_line = nil #: Integer?
928933 end
929934
930935 # @override
@@ -955,7 +960,9 @@ def visit_call_node(node)
955960 when "overridable"
956961 @current . is_overridable = true
957962 when "params"
963+ @params_start_line = node . location . start_line
958964 visit ( node . arguments )
965+ @params_start_line = nil
959966 when "returns"
960967 args = node . arguments
961968 if args . is_a? ( Prism ::ArgumentsNode )
@@ -983,6 +990,8 @@ def visit_assoc_node(node)
983990 @current . params << SigParam . new (
984991 node_string! ( node . key ) . delete_suffix ( ":" ) ,
985992 node_string! ( node . value ) ,
993+ loc : node_loc ( node ) ,
994+ comments : node_comments ( node , min_line : params_start_line ) ,
986995 )
987996 end
988997
0 commit comments