Class: RuboCop::RBS::ProcessedRBSSource

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/rbs/processed_rbs_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ ProcessedRBSSource

Returns a new instance of ProcessedRBSSource.



13
14
15
16
17
18
19
20
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 13

def initialize(source)
  @raw_source = source.content
  @buffer, @directives, @decls = ::RBS::Parser.parse_signature(source)
  @error = nil
  @tokens = nil
rescue ::RBS::ParsingError => e
  @error = e
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



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

def buffer
  @buffer
end

#declsObject (readonly)

Returns the value of attribute decls.



10
11
12
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 10

def decls
  @decls
end

#directivesObject (readonly)

Returns the value of attribute directives.



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

def directives
  @directives
end

#errorObject (readonly)

Returns the value of attribute error.



11
12
13
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 11

def error
  @error
end

#raw_sourceObject (readonly)

Returns the value of attribute raw_source.



6
7
8
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 6

def raw_source
  @raw_source
end

#sourceObject (readonly)

Returns the value of attribute source.



7
8
9
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 7

def source
  @source
end

Instance Method Details

#tokensObject



26
27
28
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 26

def tokens
  @tokens ||= ::RBS::Parser.lex(buffer).value
end

#valid_syntax?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rubocop/rbs/processed_rbs_source.rb', line 22

def valid_syntax?
  @error.nil?
end