Skip to content

Commit 19d0bd9

Browse files
committed
Remove unnecessary file_name parameter from Parser#initialize
1 parent 1b16fe6 commit 19d0bd9

15 files changed

+20
-23
lines changed

lib/rdoc/parser.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def self.for top_level, content, options, stats
191191

192192
content = remove_modeline content
193193

194-
parser.new top_level, file_name, content, options, stats
194+
parser.new top_level, content, options, stats
195195
rescue SystemCallError
196196
nil
197197
end
@@ -252,12 +252,12 @@ def self.use_markup content
252252
# RDoc::Markup::PreProcess object is created which allows processing of
253253
# directives.
254254

255-
def initialize top_level, file_name, content, options, stats
255+
def initialize top_level, content, options, stats
256256
@top_level = top_level
257257
@top_level.parser = self.class
258258
@store = @top_level.store
259259

260-
@file_name = file_name
260+
@file_name = top_level.absolute_name
261261
@content = content
262262
@options = options
263263
@stats = stats

lib/rdoc/parser/c.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class RDoc::Parser::C < RDoc::Parser
168168
# Prepares for parsing a C file. See RDoc::Parser#initialize for details on
169169
# the arguments.
170170

171-
def initialize top_level, file_name, content, options, stats
171+
def initialize top_level, content, options, stats
172172
super
173173

174174
@known_classes = RDoc::KNOWN_CLASSES.dup

lib/rdoc/parser/prism_ruby.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
1818
attr_accessor :visibility
1919
attr_reader :container, :singleton
2020

21-
def initialize(top_level, file_name, content, options, stats)
21+
def initialize(top_level, content, options, stats)
2222
super
2323

2424
content = handle_tab_width(content)

lib/rdoc/parser/ruby.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
170170
##
171171
# Creates a new Ruby parser.
172172

173-
def initialize(top_level, file_name, content, options, stats)
173+
def initialize(top_level, content, options, stats)
174174
super
175175

176176
content = handle_tab_width(content)

lib/rdoc/parser/simple.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RDoc::Parser::Simple < RDoc::Parser
1414
##
1515
# Prepare to parse a plain file
1616

17-
def initialize(top_level, file_name, content, options, stats)
17+
def initialize(top_level, content, options, stats)
1818
super
1919

2020
preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include

test/rdoc/test_rdoc_parser.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def test_class_use_markup_unknown
310310

311311
def test_initialize
312312
with_top_level("file.rb", "") do |top_level, content|
313-
@RP.new top_level, top_level.absolute_name, content, @options, nil
313+
@RP.new top_level, content, @options, nil
314314

315315
assert_equal @RP, top_level.parser
316316
end

test/rdoc/test_rdoc_parser_c.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_initialize
138138
@fn => { 'cSomeExtSingle' => 'SomeExtSingle' }
139139
}
140140

141-
parser = RDoc::Parser::C.new @top_level, @fn, '', @options, @stats
141+
parser = RDoc::Parser::C.new @top_level, '', @options, @stats
142142

143143
expected = { 'cSomeExt' => some_ext }
144144
assert_equal expected, parser.classes
@@ -2144,7 +2144,7 @@ def util_get_class content, name = nil
21442144
end
21452145

21462146
def util_parser content = ''
2147-
RDoc::Parser::C.new @top_level, @fn, content, @options, @stats
2147+
RDoc::Parser::C.new @top_level, content, @options, @stats
21482148
end
21492149

21502150
end

test/rdoc/test_rdoc_parser_changelog.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ def test_scan_git_commit_date
474474
end
475475

476476
def util_parser content = ''
477-
RDoc::Parser::ChangeLog.new \
478-
@top_level, @tempfile.path, content, @options, @stats
477+
RDoc::Parser::ChangeLog.new @top_level, content, @options, @stats
479478
end
480479

481480
def log_entry(*a)

test/rdoc/test_rdoc_parser_markdown.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_scan
5555
end
5656

5757
def util_parser content
58-
RDoc::Parser::Markdown.new @top_level, @fn, content, @options, @stats
58+
RDoc::Parser::Markdown.new @top_level, content, @options, @stats
5959
end
6060

6161
end

test/rdoc/test_rdoc_parser_prism_ruby.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ def accept_legacy_bug?
19961996
end
19971997

19981998
def util_parser(content)
1999-
@parser = RDoc::Parser::PrismRuby.new @top_level, @filename, content, @options, @stats
1999+
@parser = RDoc::Parser::PrismRuby.new @top_level, content, @options, @stats
20002000
@parser.scan
20012001
end
20022002
end
@@ -2010,7 +2010,7 @@ def accept_legacy_bug?
20102010
end
20112011

20122012
def util_parser(content)
2013-
@parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options, @stats
2013+
@parser = RDoc::Parser::Ruby.new @top_level, content, @options, @stats
20142014
@parser.scan
20152015
end
20162016
end unless ENV['RDOC_USE_PRISM_PARSER']

test/rdoc/test_rdoc_parser_rd.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_scan
4949
end
5050

5151
def util_parser content
52-
RDoc::Parser::RD.new @top_level, @fn, content, @options, @stats
52+
RDoc::Parser::RD.new @top_level, content, @options, @stats
5353
end
5454

5555
end

test/rdoc/test_rdoc_parser_ruby.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -4087,8 +4087,7 @@ class Baz
40874087
end
40884088

40894089
def util_parser(content)
4090-
@parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options,
4091-
@stats
4090+
@parser = RDoc::Parser::Ruby.new @top_level, content, @options, @stats
40924091
end
40934092

40944093
def util_two_parsers(first_file_content, second_file_content)

test/rdoc/test_rdoc_parser_simple.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_scan
109109
end
110110

111111
def util_parser(content)
112-
RDoc::Parser::Simple.new @top_level, @fn, content, @options, @stats
112+
RDoc::Parser::Simple.new @top_level, content, @options, @stats
113113
end
114114

115115
end

test/rdoc/test_rdoc_store.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_add_c_variables
116116
some_ext = c_file.add_class RDoc::NormalClass, 'SomeExt'
117117
c_file.add_class RDoc::SingleClass, 'SomeExtSingle'
118118

119-
c_parser = RDoc::Parser::C.new c_file, 'ext.c', '', options, nil
119+
c_parser = RDoc::Parser::C.new c_file, '', options, nil
120120

121121
c_parser.classes['cSomeExt'] = some_ext
122122
c_parser.singleton_classes['s_cSomeExt'] = 'SomeExtSingle'
@@ -698,7 +698,7 @@ def test_save_cache
698698
some_ext = c_file.add_class RDoc::NormalClass, 'SomeExt'
699699
c_file.add_class RDoc::SingleClass, 'SomeExtSingle'
700700

701-
c_parser = RDoc::Parser::C.new c_file, 'ext.c', '', options, nil
701+
c_parser = RDoc::Parser::C.new c_file, '', options, nil
702702

703703
c_parser.classes['cSomeExt'] = some_ext
704704
c_parser.singleton_classes['s_cSomeExt'] = 'SomeExtSingle'

test/rdoc/xref_test_case.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def setup
2020

2121
stats = RDoc::Stats.new @store, 0
2222

23-
parser = RDoc::Parser::Ruby.new @xref_data, @file_name, XREF_DATA, @options,
24-
stats
23+
parser = RDoc::Parser::Ruby.new @xref_data, XREF_DATA, @options, stats
2524

2625
@example_md = @store.add_file 'EXAMPLE.md'
2726
@example_md.parser = RDoc::Parser::Markdown

0 commit comments

Comments
 (0)