@@ -25,15 +25,15 @@ def self.fetch_member(loc, method)
2525 loc . public_send ( method ) rescue -1
2626 end
2727
28- def self . ast_to_json ( node , code , current_depth : 0 , file_path : nil )
28+ def self . ast_to_json ( node , code , current_depth : 0 , file_path : nil , is_erb : false )
2929 return unless node . is_a? ( Parser ::AST ::Node )
3030
3131 loc = node . location
3232 meta_data = {
33- start_line : fetch_member ( loc , :line ) ,
34- start_column : fetch_member ( loc , :column ) ,
35- end_line : fetch_member ( loc , :last_line ) ,
36- end_column : fetch_member ( loc , :last_column ) ,
33+ start_line : is_erb ? - 1 : fetch_member ( loc , :line ) ,
34+ start_column : is_erb ? - 1 : fetch_member ( loc , :column ) ,
35+ end_line : is_erb ? - 1 : fetch_member ( loc , :last_line ) ,
36+ end_column : is_erb ? - 1 : fetch_member ( loc , :last_column ) ,
3737 offset_start : loc &.expression &.begin_pos ,
3838 offset_end : loc &.expression &.end_pos ,
3939 code : self . extract_code_snippet ( loc , code )
@@ -48,7 +48,7 @@ def self.ast_to_json(node, code, current_depth: 0, file_path: nil)
4848 meta_data : meta_data ,
4949 children : node . children . map do |child |
5050 if child . is_a? ( Parser ::AST ::Node )
51- ast_to_json ( child , code , current_depth : current_depth + 1 , file_path : file_path ) # Recursively process child nodes
51+ ast_to_json ( child , code , current_depth : current_depth + 1 , file_path : file_path , is_erb : is_erb ) # Recursively process child nodes
5252 else
5353 child # If it's not a node (e.g., literal), return as-is
5454 end
0 commit comments