Class: RubyLsp::RBSDocument

Inherits:
Document show all
Defined in:
lib/ruby_lsp/rbs_document.rb

Overview

: [ParseResultType = Array]

Constant Summary

Constants inherited from Document

Document::EMPTY_CACHE, Document::MAXIMUM_CHARACTERS_FOR_EXPENSIVE_FEATURES

Instance Attribute Summary

Attributes inherited from Document

#encoding, #last_edit, #parse_result, #semantic_tokens, #source, #uri, #version

Instance Method Summary collapse

Methods inherited from Document

#==, #cache_fetch, #cache_get, #cache_set, #clear_cache, #find_index_by_position, #past_expensive_limit?, #push_edits

Constructor Details

#initialize(source:, version:, uri:, global_state:) ⇒ RBSDocument

: (source: String, version: Integer, uri: URI::Generic, global_state: GlobalState) -> void



8
9
10
11
# File 'lib/ruby_lsp/rbs_document.rb', line 8

def initialize(source:, version:, uri:, global_state:)
  @syntax_error = false #: bool
  super
end

Instance Method Details

#language_idObject

: -> Symbol



37
38
39
# File 'lib/ruby_lsp/rbs_document.rb', line 37

def language_id
  :rbs
end

#parse!Object

: -> bool



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_lsp/rbs_document.rb', line 15

def parse!
  return false unless @needs_parsing

  @needs_parsing = false

  _, _, declarations = RBS::Parser.parse_signature(@source)
  @syntax_error = false
  @parse_result = declarations
  true
rescue RBS::ParsingError
  @syntax_error = true
  true
end

#syntax_error?Boolean

: -> bool



31
32
33
# File 'lib/ruby_lsp/rbs_document.rb', line 31

def syntax_error?
  @syntax_error
end