Class: Rubocop::ProcessedSource
- Inherits:
-
Object
- Object
- Rubocop::ProcessedSource
- Defined in:
- lib/rubocop/processed_source.rb
Overview
ProcessedSource contains objects which are generated by Parser and other information such as disabled lines for cops. It also provides a convenient way to access source lines.
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#comment_config ⇒ Object
readonly
Returns the value of attribute comment_config.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #disabled_line_ranges ⇒ Object
- #file_path ⇒ Object
-
#initialize(buffer, ast, comments, tokens, diagnostics) ⇒ ProcessedSource
constructor
A new instance of ProcessedSource.
- #lines ⇒ Object
- #raw_lines ⇒ Object
- #valid_syntax? ⇒ Boolean
Constructor Details
#initialize(buffer, ast, comments, tokens, diagnostics) ⇒ ProcessedSource
Returns a new instance of ProcessedSource.
11 12 13 14 15 16 17 18 |
# File 'lib/rubocop/processed_source.rb', line 11 def initialize(buffer, ast, comments, tokens, diagnostics) @buffer = buffer @ast = ast @comments = comments @tokens = tokens @diagnostics = diagnostics @comment_config = CommentConfig.new(self) end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
8 9 10 |
# File 'lib/rubocop/processed_source.rb', line 8 def ast @ast end |
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
8 9 10 |
# File 'lib/rubocop/processed_source.rb', line 8 def buffer @buffer end |
#comment_config ⇒ Object (readonly)
Returns the value of attribute comment_config.
8 9 10 |
# File 'lib/rubocop/processed_source.rb', line 8 def comment_config @comment_config end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
8 9 10 |
# File 'lib/rubocop/processed_source.rb', line 8 def comments @comments end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
8 9 10 |
# File 'lib/rubocop/processed_source.rb', line 8 def diagnostics @diagnostics end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
8 9 10 |
# File 'lib/rubocop/processed_source.rb', line 8 def tokens @tokens end |
Instance Method Details
#[](*args) ⇒ Object
42 43 44 |
# File 'lib/rubocop/processed_source.rb', line 42 def [](*args) lines[*args] end |
#disabled_line_ranges ⇒ Object
20 21 22 |
# File 'lib/rubocop/processed_source.rb', line 20 def disabled_line_ranges comment_config.cop_disabled_line_ranges end |
#file_path ⇒ Object
50 51 52 |
# File 'lib/rubocop/processed_source.rb', line 50 def file_path @buffer.name end |
#lines ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/rubocop/processed_source.rb', line 24 def lines if @lines @lines else init_lines @lines end end |
#raw_lines ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/processed_source.rb', line 33 def raw_lines if @raw_lines @raw_lines else init_lines @raw_lines end end |
#valid_syntax? ⇒ Boolean
46 47 48 |
# File 'lib/rubocop/processed_source.rb', line 46 def valid_syntax? @diagnostics.none? { |d| [:error, :fatal].include?(d.level) } end |