@@ -174,6 +174,8 @@ def initialize(top_level, file_name, content, options, stats)
174174 @scanner . exception_on_syntax_error = false
175175 @prev_seek = nil
176176
177+ @encoding = @options . encoding if Object . const_defined? :Encoding
178+
177179 reset
178180 end
179181
@@ -449,6 +451,9 @@ def make_message message
449451 # +comment+.
450452
451453 def parse_attr ( context , single , tk , comment )
454+ column = tk . char_no
455+ line_no = tk . line_no
456+
452457 args = parse_symbol_arg 1
453458 if args . size > 0 then
454459 name = args [ 0 ]
@@ -464,6 +469,8 @@ def parse_attr(context, single, tk, comment)
464469
465470 att = RDoc ::Attr . new get_tkread , name , rw , comment , single == SINGLE
466471 att . record_location @top_level
472+ att . offset = column
473+ att . line = line_no
467474
468475 read_documentation_modifiers att , RDoc ::ATTR_MODIFIERS
469476
@@ -480,6 +487,9 @@ def parse_attr(context, single, tk, comment)
480487 # comment for each to +comment+.
481488
482489 def parse_attr_accessor ( context , single , tk , comment )
490+ column = tk . char_no
491+ line_no = tk . line_no
492+
483493 args = parse_symbol_arg
484494 rw = "?"
485495
@@ -498,6 +508,8 @@ def parse_attr_accessor(context, single, tk, comment)
498508 for name in args
499509 att = RDoc ::Attr . new get_tkread , name , rw , comment , single == SINGLE
500510 att . record_location @top_level
511+ att . offset = column
512+ att . line = line_no
501513
502514 context . add_attribute att
503515 @stats . add_attribute att
@@ -508,6 +520,9 @@ def parse_attr_accessor(context, single, tk, comment)
508520 # Parses an +alias+ in +context+ with +comment+
509521
510522 def parse_alias ( context , single , tk , comment )
523+ column = tk . char_no
524+ line_no = tk . line_no
525+
511526 skip_tkspace
512527
513528 if TkLPAREN === peek_tk then
@@ -534,6 +549,8 @@ def parse_alias(context, single, tk, comment)
534549 al = RDoc ::Alias . new ( get_tkread , old_name , new_name , comment ,
535550 single == SINGLE )
536551 al . record_location @top_level
552+ al . offset = column
553+ al . line = line_no
537554
538555 read_documentation_modifiers al , RDoc ::ATTR_MODIFIERS
539556 context . add_alias al if al . document_self
@@ -586,6 +603,9 @@ def parse_call_parameters(tk)
586603 # Parses a class in +context+ with +comment+
587604
588605 def parse_class ( container , single , tk , comment )
606+ column = tk . char_no
607+ line_no = tk . line_no
608+
589609 declaration_context = container
590610 container , name_t , given_name = get_class_or_module container
591611
@@ -606,6 +626,9 @@ def parse_class(container, single, tk, comment)
606626
607627 read_documentation_modifiers cls , RDoc ::CLASS_MODIFIERS
608628 cls . record_location @top_level
629+ cls . offset = column
630+ cls . line = line_no
631+
609632 cls . comment = comment if cls . document_self
610633
611634 @top_level . add_to_classes_or_modules cls
@@ -622,6 +645,9 @@ def parse_class(container, single, tk, comment)
622645 unless other then
623646 other = container . add_module RDoc ::NormalModule , name
624647 other . record_location @top_level
648+ other . offset = column
649+ other . line = line_no
650+
625651 other . comment = comment
626652 end
627653
@@ -639,7 +665,6 @@ def parse_class(container, single, tk, comment)
639665 read_documentation_modifiers other , RDoc ::CLASS_MODIFIERS
640666 parse_statements ( other , SINGLE )
641667 end
642-
643668 else
644669 warn ( "Expected class name or '<<'. Got #{ name_t . class } : #{ name_t . text . inspect } " )
645670 end
@@ -649,6 +674,9 @@ def parse_class(container, single, tk, comment)
649674 # Parses a constant in +context+ with +comment+
650675
651676 def parse_constant ( container , tk , comment )
677+ column = tk . char_no
678+ line_no = tk . line_no
679+
652680 name = tk . name
653681 skip_tkspace false
654682
@@ -721,6 +749,8 @@ def parse_constant(container, tk, comment)
721749
722750 con = RDoc ::Constant . new name , res , comment
723751 con . record_location @top_level
752+ con . offset = column
753+ con . line = line_no
724754 read_documentation_modifiers con , RDoc ::CONSTANT_MODIFIERS
725755
726756 @stats . add_constant con
@@ -745,6 +775,8 @@ def parse_comment(container, tk, comment)
745775 meth = RDoc ::GhostMethod . new get_tkread , name
746776 meth . record_location @top_level
747777 meth . singleton = singleton
778+ meth . offset = column
779+ meth . line = line_no
748780
749781 meth . start_collecting_tokens
750782 indent = TkSPACE . new nil , 1 , 1
@@ -777,6 +809,8 @@ def parse_comment(container, tk, comment)
777809 # TODO authorize 'singleton-attr...'?
778810 att = RDoc ::Attr . new get_tkread , name , rw , comment
779811 att . record_location @top_level
812+ att . offset = column
813+ att . line = line_no
780814
781815 container . add_attribute att
782816
@@ -904,6 +938,8 @@ def parse_meta_method(container, single, tk, comment)
904938
905939 meth = RDoc ::MetaMethod . new get_tkread , name
906940 meth . record_location @top_level
941+ meth . offset = column
942+ meth . line = line_no
907943 meth . singleton = singleton
908944
909945 remove_token_listener self
@@ -1049,6 +1085,8 @@ def parse_method(container, single, tk, comment)
10491085 end
10501086
10511087 meth . record_location @top_level
1088+ meth . offset = column
1089+ meth . line = line_no
10521090
10531091 meth . start_collecting_tokens
10541092 indent = TkSPACE . new nil , 1 , 1
0 commit comments