Class: RubyLsp::Store
- Inherits:
-
Object
- Object
- RubyLsp::Store
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/store.rb
Instance Attribute Summary collapse
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#experimental_features ⇒ Object
Returns the value of attribute experimental_features.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#supports_progress ⇒ Object
Returns the value of attribute supports_progress.
Instance Method Summary collapse
- #cache_fetch(uri, request_name, &block) ⇒ Object
- #clear ⇒ Object
- #delete(uri) ⇒ Object
- #empty? ⇒ Boolean
- #get(uri) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #push_edits(uri:, edits:, version:) ⇒ Object
- #set(uri:, source:, version:) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
23 24 25 26 27 28 29 |
# File 'lib/ruby_lsp/store.rb', line 23 def initialize @state = T.let({}, T::Hash[String, Document]) @encoding = T.let(Constant::PositionEncodingKind::UTF8, String) @formatter = T.let("auto", String) @supports_progress = T.let(true, T::Boolean) @experimental_features = T.let(false, T::Boolean) end |
Instance Attribute Details
#encoding ⇒ Object
Returns the value of attribute encoding.
11 12 13 |
# File 'lib/ruby_lsp/store.rb', line 11 def encoding @encoding end |
#experimental_features ⇒ Object
Returns the value of attribute experimental_features.
20 21 22 |
# File 'lib/ruby_lsp/store.rb', line 20 def experimental_features @experimental_features end |
#formatter ⇒ Object
Returns the value of attribute formatter.
14 15 16 |
# File 'lib/ruby_lsp/store.rb', line 14 def formatter @formatter end |
#supports_progress ⇒ Object
Returns the value of attribute supports_progress.
17 18 19 |
# File 'lib/ruby_lsp/store.rb', line 17 def supports_progress @supports_progress end |
Instance Method Details
#cache_fetch(uri, request_name, &block) ⇒ Object
75 76 77 |
# File 'lib/ruby_lsp/store.rb', line 75 def cache_fetch(uri, request_name, &block) get(uri).cache_fetch(request_name, &block) end |
#clear ⇒ Object
53 54 55 |
# File 'lib/ruby_lsp/store.rb', line 53 def clear @state.clear end |
#delete(uri) ⇒ Object
63 64 65 |
# File 'lib/ruby_lsp/store.rb', line 63 def delete(uri) @state.delete(uri.to_s) end |
#empty? ⇒ Boolean
58 59 60 |
# File 'lib/ruby_lsp/store.rb', line 58 def empty? @state.empty? end |
#get(uri) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/ruby_lsp/store.rb', line 32 def get(uri) document = @state[uri.to_s] return document unless document.nil? path = T.must(uri.to_standardized_path) set(uri: uri, source: File.binread(path), version: 0) T.must(@state[uri.to_s]) end |
#push_edits(uri:, edits:, version:) ⇒ Object
48 49 50 |
# File 'lib/ruby_lsp/store.rb', line 48 def push_edits(uri:, edits:, version:) T.must(@state[uri.to_s]).push_edits(edits, version: version) end |
#set(uri:, source:, version:) ⇒ Object
42 43 44 45 |
# File 'lib/ruby_lsp/store.rb', line 42 def set(uri:, source:, version:) document = Document.new(source: source, version: version, uri: uri, encoding: @encoding) @state[uri.to_s] = document end |