Skip to content

Commit a39b0bb

Browse files
authored
Remove RDoc::MethodAttr#text (#1710)
It is unused and in majority of the cases just set to nil or the empty string
1 parent 1f93543 commit a39b0bb

32 files changed

Lines changed: 299 additions & 318 deletions

lib/rdoc/code_object/alias.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,12 @@ class RDoc::Alias < RDoc::CodeObject
2626
attr_reader :singleton
2727

2828
##
29-
# Source file token stream
30-
31-
attr_reader :text
32-
33-
##
34-
# Creates a new Alias with a token stream of +text+ that aliases +old_name+
29+
# Creates a new Alias that aliases +old_name+
3530
# to +new_name+, has +comment+ and is a +singleton+ context.
3631

37-
def initialize(text, old_name, new_name, comment, singleton: false)
32+
def initialize(old_name, new_name, comment, singleton: false)
3833
super()
3934

40-
@text = text
4135
@singleton = singleton
4236
@old_name = old_name
4337
@new_name = new_name

lib/rdoc/code_object/any_method.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class RDoc::AnyMethod < RDoc::MethodAttr
3939
include RDoc::TokenStream
4040

4141
##
42-
# Creates a new AnyMethod with a token stream +text+ and +name+
42+
# Creates a new AnyMethod with name +name+
4343

44-
def initialize(text, name, singleton: false)
45-
super(text, name, singleton: singleton)
44+
def initialize(name, singleton: false)
45+
super(name, singleton: singleton)
4646

4747
@c_function = nil
4848
@dont_rename_initialize = false
@@ -55,7 +55,7 @@ def initialize(text, name, singleton: false)
5555
# Adds +an_alias+ as an alias for this method in +context+.
5656

5757
def add_alias(an_alias, context = nil)
58-
method = self.class.new an_alias.text, an_alias.new_name, singleton: singleton
58+
method = self.class.new an_alias.new_name, singleton: singleton
5959

6060
method.record_location an_alias.file
6161
method.params = self.params
@@ -211,7 +211,7 @@ def marshal_load(array)
211211
@type_signature_lines = array[16]&.split("\n")
212212

213213
array[8].each do |new_name, document|
214-
add_alias RDoc::Alias.new(nil, @name, new_name, RDoc::Comment.from_document(document), singleton: @singleton)
214+
add_alias RDoc::Alias.new(@name, new_name, RDoc::Comment.from_document(document), singleton: @singleton)
215215
end
216216

217217
@parent_name ||= if @full_name =~ /#/ then

lib/rdoc/code_object/attr.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class RDoc::Attr < RDoc::MethodAttr
2121
attr_accessor :rw
2222

2323
##
24-
# Creates a new Attr with body +text+, +name+, read/write status +rw+ and
24+
# Creates a new Attr with +name+, read/write status +rw+ and
2525
# +comment+. +singleton+ marks this as a class attribute.
2626

27-
def initialize(text, name, rw, comment, singleton: false)
28-
super(text, name, singleton: singleton)
27+
def initialize(name, rw, comment, singleton: false)
28+
super(name, singleton: singleton)
2929

3030
@rw = rw
3131
self.comment = comment
@@ -46,7 +46,7 @@ def ==(other)
4646

4747
def add_alias(an_alias, context)
4848
access_type = an_alias.new_name.end_with?('=') ? 'W' : 'R'
49-
new_attr = self.class.new(text, an_alias.new_name, access_type, comment, singleton: singleton)
49+
new_attr = self.class.new(an_alias.new_name, access_type, comment, singleton: singleton)
5050
new_attr.record_location an_alias.file
5151
new_attr.visibility = self.visibility
5252
new_attr.is_alias_for = self

lib/rdoc/code_object/class_module.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def marshal_load(array) # :nodoc:
414414
singleton ||= false
415415
visibility ||= :public
416416

417-
attr = RDoc::Attr.new nil, name, rw, nil, singleton: singleton
417+
attr = RDoc::Attr.new name, rw, nil, singleton: singleton
418418

419419
add_attribute attr
420420
attr.visibility = visibility
@@ -441,7 +441,7 @@ def marshal_load(array) # :nodoc:
441441
@visibility = visibility
442442

443443
methods.each do |name, file|
444-
method = RDoc::AnyMethod.new nil, name, singleton: type == 'class'
444+
method = RDoc::AnyMethod.new name, singleton: type == 'class'
445445
method.record_location RDoc::TopLevel.new file
446446
add_method method
447447
end

lib/rdoc/code_object/method_attr.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ class RDoc::MethodAttr < RDoc::CodeObject
2121

2222
attr_accessor :singleton
2323

24-
##
25-
# Source file token stream
26-
27-
attr_reader :text
28-
2924
##
3025
# Array of other names for this method/attribute
3126

@@ -70,15 +65,14 @@ class RDoc::MethodAttr < RDoc::CodeObject
7065
attr_reader :arglists
7166

7267
##
73-
# Creates a new MethodAttr from token stream +text+ and method or attribute
68+
# Creates a new MethodAttr with method or attribute
7469
# name +name+.
7570
#
7671
# Usually this is called by super from a subclass.
7772

78-
def initialize(text, name, singleton: false)
73+
def initialize(name, singleton: false)
7974
super()
8075

81-
@text = text
8276
@name = name
8377

8478
@aliases = []
@@ -363,13 +357,6 @@ def pretty_print(q) # :nodoc:
363357
q.text alias_for
364358
end
365359

366-
if text then
367-
q.breakable
368-
q.text "text:"
369-
q.breakable
370-
q.pp @text
371-
end
372-
373360
unless comment.empty? then
374361
q.breakable
375362
q.text "comment:"

lib/rdoc/parser/c.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def do_aliases
248248
# method that reference the same function.
249249

250250
def add_alias(var_name, class_obj, old_name, new_name, comment)
251-
al = RDoc::Alias.new '', old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
251+
al = RDoc::Alias.new old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
252252
al.record_location @top_level
253253
class_obj.add_alias al
254254
@stats.add_alias al
@@ -848,7 +848,7 @@ def handle_attr(var_name, attr_name, read, write)
848848

849849
name = attr_name.gsub(/rb_intern(?:_const)?\("([^"]+)"\)/, '\1')
850850

851-
attr = RDoc::Attr.new '', name, rw, comment
851+
attr = RDoc::Attr.new name, rw, comment
852852

853853
attr.record_location @top_level
854854
class_obj.add_attribute attr
@@ -1007,7 +1007,7 @@ def handle_method(type, var_name, meth_name, function, param_count,
10071007
end
10081008

10091009
singleton = singleton || %w[singleton_method module_function].include?(type)
1010-
meth_obj = RDoc::AnyMethod.new '', meth_name, singleton: singleton
1010+
meth_obj = RDoc::AnyMethod.new meth_name, singleton: singleton
10111011
meth_obj.c_function = function
10121012

10131013
p_count = Integer(param_count) rescue -1

lib/rdoc/parser/ruby.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def parse_comment_tomdoc(container, comment, line_no, start_line)
311311

312312
name, = signature.split %r%[ \(]%, 2
313313

314-
meth = RDoc::AnyMethod.new comment.text, name
314+
meth = RDoc::AnyMethod.new name
315315
record_location(meth)
316316
meth.line = start_line
317317
meth.call_seq = signature
@@ -377,7 +377,7 @@ def handle_meta_method_comment(comment, directives, node)
377377

378378
if attributes
379379
attributes.each do |attr|
380-
a = RDoc::Attr.new(@container, attr, rw, comment, singleton: @singleton)
380+
a = RDoc::Attr.new(attr, rw, comment, singleton: @singleton)
381381
a.store = @store
382382
a.line = line_no
383383
record_location(a)
@@ -562,7 +562,7 @@ def add_alias_method(old_name, new_name, line_no)
562562
comment, directives = consecutive_comment(line_no)
563563
handle_code_object_directives(@container, directives) if directives
564564
visibility = @container.find_method(old_name, @singleton)&.visibility || :public
565-
a = RDoc::Alias.new(nil, old_name, new_name, comment, singleton: @singleton)
565+
a = RDoc::Alias.new(old_name, new_name, comment, singleton: @singleton)
566566
handle_modifier_directive(a, line_no)
567567
a.store = @store
568568
a.line = line_no
@@ -581,7 +581,7 @@ def add_attributes(names, rw, line_no)
581581
return unless @container.document_children
582582

583583
names.each do |symbol|
584-
a = RDoc::Attr.new(nil, symbol.to_s, rw, comment, singleton: @singleton)
584+
a = RDoc::Attr.new(symbol.to_s, rw, comment, singleton: @singleton)
585585
a.store = @store
586586
a.line = line_no
587587
a.type_signature_lines = type_signature_lines
@@ -644,7 +644,7 @@ def add_method(method_name, receiver_name:, receiver_fallback_type:, visibility:
644644
end
645645

646646
private def internal_add_method(method_name, container, comment:, dont_rename_initialize: false, directives:, modifier_comment_lines: nil, line_no:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:, type_signature_lines: nil) # :nodoc:
647-
meth = RDoc::AnyMethod.new(nil, method_name, singleton: singleton)
647+
meth = RDoc::AnyMethod.new(method_name, singleton: singleton)
648648
meth.comment = comment
649649
handle_code_object_directives(meth, directives) if directives
650650
modifier_comment_lines&.each do |line|

lib/rdoc/ri/driver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ def load_method(store, cache, klass, type, name)
12181218
comment = RDoc::Comment.new("missing documentation at #{e.file}")
12191219
comment.parse
12201220

1221-
method = RDoc::AnyMethod.new nil, name
1221+
method = RDoc::AnyMethod.new name
12221222
method.comment = comment
12231223
method
12241224
end

test/rdoc/code_object/alias_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class RDocAliasTest < XrefTestCase
55

66
def test_to_s
7-
a = RDoc::Alias.new nil, 'a', 'b', ''
7+
a = RDoc::Alias.new 'a', 'b', ''
88
a.parent = @c2
99

1010
assert_equal 'alias: b -> #a in: RDoc::NormalClass C2 < Object', a.to_s

0 commit comments

Comments
 (0)