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.
-
#features_configuration ⇒ Object
Returns the value of attribute features_configuration.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#supports_progress ⇒ Object
Returns the value of attribute supports_progress.
-
#workspace_uri ⇒ Object
Returns the value of attribute workspace_uri.
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby_lsp/store.rb', line 27 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) @workspace_uri = T.let(URI::Generic.from_path(path: Dir.pwd), URI::Generic) @features_configuration = T.let( { codeLens: RequestConfig.new({ enableAll: false, gemfileLinks: true, }), inlayHint: RequestConfig.new({ enableAll: false, implicitRescue: false, implicitHashValue: false, }), }, T::Hash[Symbol, RequestConfig], ) end |
Instance Attribute Details
#encoding ⇒ Object
Returns the value of attribute encoding.
9 10 11 |
# File 'lib/ruby_lsp/store.rb', line 9 def encoding @encoding end |
#experimental_features ⇒ Object
Returns the value of attribute experimental_features.
18 19 20 |
# File 'lib/ruby_lsp/store.rb', line 18 def experimental_features @experimental_features end |
#features_configuration ⇒ Object
Returns the value of attribute features_configuration.
24 25 26 |
# File 'lib/ruby_lsp/store.rb', line 24 def features_configuration @features_configuration end |
#formatter ⇒ Object
Returns the value of attribute formatter.
12 13 14 |
# File 'lib/ruby_lsp/store.rb', line 12 def formatter @formatter end |
#supports_progress ⇒ Object
Returns the value of attribute supports_progress.
15 16 17 |
# File 'lib/ruby_lsp/store.rb', line 15 def supports_progress @supports_progress end |
#workspace_uri ⇒ Object
Returns the value of attribute workspace_uri.
21 22 23 |
# File 'lib/ruby_lsp/store.rb', line 21 def workspace_uri @workspace_uri end |
Instance Method Details
#cache_fetch(uri, request_name, &block) ⇒ Object
94 95 96 |
# File 'lib/ruby_lsp/store.rb', line 94 def cache_fetch(uri, request_name, &block) get(uri).cache_fetch(request_name, &block) end |
#clear ⇒ Object
72 73 74 |
# File 'lib/ruby_lsp/store.rb', line 72 def clear @state.clear end |
#delete(uri) ⇒ Object
82 83 84 |
# File 'lib/ruby_lsp/store.rb', line 82 def delete(uri) @state.delete(uri.to_s) end |
#empty? ⇒ Boolean
77 78 79 |
# File 'lib/ruby_lsp/store.rb', line 77 def empty? @state.empty? end |
#get(uri) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/ruby_lsp/store.rb', line 51 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
67 68 69 |
# File 'lib/ruby_lsp/store.rb', line 67 def push_edits(uri:, edits:, version:) T.must(@state[uri.to_s]).push_edits(edits, version: version) end |
#set(uri:, source:, version:) ⇒ Object
61 62 63 64 |
# File 'lib/ruby_lsp/store.rb', line 61 def set(uri:, source:, version:) document = RubyDocument.new(source: source, version: version, uri: uri, encoding: @encoding) @state[uri.to_s] = document end |