Class: Rubocop::ProcessedSource

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(buffer, ast, comments, tokens, diagnostics) ⇒ ProcessedSource

Returns a new instance of ProcessedSource.



11
12
13
14
15
16
17
# 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
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



8
9
10
# File 'lib/rubocop/processed_source.rb', line 8

def ast
  @ast
end

#bufferObject (readonly)

Returns the value of attribute buffer.



8
9
10
# File 'lib/rubocop/processed_source.rb', line 8

def buffer
  @buffer
end

#commentsObject (readonly)

Returns the value of attribute comments.



8
9
10
# File 'lib/rubocop/processed_source.rb', line 8

def comments
  @comments
end

#diagnosticsObject (readonly)

Returns the value of attribute diagnostics.



8
9
10
# File 'lib/rubocop/processed_source.rb', line 8

def diagnostics
  @diagnostics
end

#disabled_lines_for_copsObject

Returns the value of attribute disabled_lines_for_cops.



9
10
11
# File 'lib/rubocop/processed_source.rb', line 9

def disabled_lines_for_cops
  @disabled_lines_for_cops
end

#tokensObject (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



23
24
25
# File 'lib/rubocop/processed_source.rb', line 23

def [](*args)
  lines[*args]
end

#linesObject



19
20
21
# File 'lib/rubocop/processed_source.rb', line 19

def lines
  @lines ||= @buffer.source.split($RS)
end