Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions lib/rdoc/code_object/alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@ class RDoc::Alias < RDoc::CodeObject
attr_reader :singleton

##
# Source file token stream

attr_reader :text

##
# Creates a new Alias with a token stream of +text+ that aliases +old_name+
# Creates a new Alias that aliases +old_name+
# to +new_name+, has +comment+ and is a +singleton+ context.

def initialize(text, old_name, new_name, comment, singleton: false)
def initialize(old_name, new_name, comment, singleton: false)
super()

@text = text
@singleton = singleton
@old_name = old_name
@new_name = new_name
Expand Down
10 changes: 5 additions & 5 deletions lib/rdoc/code_object/any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class RDoc::AnyMethod < RDoc::MethodAttr
include RDoc::TokenStream

##
# Creates a new AnyMethod with a token stream +text+ and +name+
# Creates a new AnyMethod with name +name+

def initialize(text, name, singleton: false)
super(text, name, singleton: singleton)
def initialize(name, singleton: false)
super(name, singleton: singleton)

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

def add_alias(an_alias, context = nil)
method = self.class.new an_alias.text, an_alias.new_name, singleton: singleton
method = self.class.new an_alias.new_name, singleton: singleton

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

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

@parent_name ||= if @full_name =~ /#/ then
Expand Down
8 changes: 4 additions & 4 deletions lib/rdoc/code_object/attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class RDoc::Attr < RDoc::MethodAttr
attr_accessor :rw

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

def initialize(text, name, rw, comment, singleton: false)
super(text, name, singleton: singleton)
def initialize(name, rw, comment, singleton: false)
super(name, singleton: singleton)

@rw = rw
self.comment = comment
Expand All @@ -46,7 +46,7 @@ def ==(other)

def add_alias(an_alias, context)
access_type = an_alias.new_name.end_with?('=') ? 'W' : 'R'
new_attr = self.class.new(text, an_alias.new_name, access_type, comment, singleton: singleton)
new_attr = self.class.new(an_alias.new_name, access_type, comment, singleton: singleton)
new_attr.record_location an_alias.file
new_attr.visibility = self.visibility
new_attr.is_alias_for = self
Expand Down
4 changes: 2 additions & 2 deletions lib/rdoc/code_object/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def marshal_load(array) # :nodoc:
singleton ||= false
visibility ||= :public

attr = RDoc::Attr.new nil, name, rw, nil, singleton: singleton
attr = RDoc::Attr.new name, rw, nil, singleton: singleton

add_attribute attr
attr.visibility = visibility
Expand All @@ -441,7 +441,7 @@ def marshal_load(array) # :nodoc:
@visibility = visibility

methods.each do |name, file|
method = RDoc::AnyMethod.new nil, name, singleton: type == 'class'
method = RDoc::AnyMethod.new name, singleton: type == 'class'
method.record_location RDoc::TopLevel.new file
add_method method
end
Expand Down
17 changes: 2 additions & 15 deletions lib/rdoc/code_object/method_attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ class RDoc::MethodAttr < RDoc::CodeObject

attr_accessor :singleton

##
# Source file token stream

attr_reader :text

##
# Array of other names for this method/attribute

Expand Down Expand Up @@ -70,15 +65,14 @@ class RDoc::MethodAttr < RDoc::CodeObject
attr_reader :arglists

##
# Creates a new MethodAttr from token stream +text+ and method or attribute
# Creates a new MethodAttr with method or attribute
# name +name+.
#
# Usually this is called by super from a subclass.

def initialize(text, name, singleton: false)
def initialize(name, singleton: false)
super()
Comment on lines +68 to 74

@text = text
@name = name

@aliases = []
Expand Down Expand Up @@ -363,13 +357,6 @@ def pretty_print(q) # :nodoc:
q.text alias_for
end

if text then
q.breakable
q.text "text:"
q.breakable
q.pp @text
end

unless comment.empty? then
q.breakable
q.text "comment:"
Expand Down
6 changes: 3 additions & 3 deletions lib/rdoc/parser/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def do_aliases
# method that reference the same function.

def add_alias(var_name, class_obj, old_name, new_name, comment)
al = RDoc::Alias.new '', old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
al = RDoc::Alias.new old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
al.record_location @top_level
class_obj.add_alias al
@stats.add_alias al
Expand Down Expand Up @@ -848,7 +848,7 @@ def handle_attr(var_name, attr_name, read, write)

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

attr = RDoc::Attr.new '', name, rw, comment
attr = RDoc::Attr.new name, rw, comment

attr.record_location @top_level
class_obj.add_attribute attr
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def handle_method(type, var_name, meth_name, function, param_count,
end

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

p_count = Integer(param_count) rescue -1
Expand Down
10 changes: 5 additions & 5 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def parse_comment_tomdoc(container, comment, line_no, start_line)

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

meth = RDoc::AnyMethod.new comment.text, name
meth = RDoc::AnyMethod.new name
record_location(meth)
meth.line = start_line
meth.call_seq = signature
Expand Down Expand Up @@ -377,7 +377,7 @@ def handle_meta_method_comment(comment, directives, node)

if attributes
attributes.each do |attr|
a = RDoc::Attr.new(@container, attr, rw, comment, singleton: @singleton)
a = RDoc::Attr.new(attr, rw, comment, singleton: @singleton)
a.store = @store
a.line = line_no
record_location(a)
Expand Down Expand Up @@ -562,7 +562,7 @@ def add_alias_method(old_name, new_name, line_no)
comment, directives = consecutive_comment(line_no)
handle_code_object_directives(@container, directives) if directives
visibility = @container.find_method(old_name, @singleton)&.visibility || :public
a = RDoc::Alias.new(nil, old_name, new_name, comment, singleton: @singleton)
a = RDoc::Alias.new(old_name, new_name, comment, singleton: @singleton)
handle_modifier_directive(a, line_no)
a.store = @store
a.line = line_no
Expand All @@ -581,7 +581,7 @@ def add_attributes(names, rw, line_no)
return unless @container.document_children

names.each do |symbol|
a = RDoc::Attr.new(nil, symbol.to_s, rw, comment, singleton: @singleton)
a = RDoc::Attr.new(symbol.to_s, rw, comment, singleton: @singleton)
a.store = @store
a.line = line_no
a.type_signature_lines = type_signature_lines
Expand Down Expand Up @@ -644,7 +644,7 @@ def add_method(method_name, receiver_name:, receiver_fallback_type:, visibility:
end

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:
meth = RDoc::AnyMethod.new(nil, method_name, singleton: singleton)
meth = RDoc::AnyMethod.new(method_name, singleton: singleton)
meth.comment = comment
handle_code_object_directives(meth, directives) if directives
modifier_comment_lines&.each do |line|
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/ri/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ def load_method(store, cache, klass, type, name)
comment = RDoc::Comment.new("missing documentation at #{e.file}")
comment.parse

method = RDoc::AnyMethod.new nil, name
method = RDoc::AnyMethod.new name
method.comment = comment
method
end
Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/code_object/alias_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class RDocAliasTest < XrefTestCase

def test_to_s
a = RDoc::Alias.new nil, 'a', 'b', ''
a = RDoc::Alias.new 'a', 'b', ''
a.parent = @c2

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