Class: StateStore
- Inherits:
-
Object
- Object
- StateStore
- Defined in:
- lib/rubocop/lsp/state_store.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #code_actions_for(uri, line_range) ⇒ Object
- #delete(uri) ⇒ Object
- #get(uri) ⇒ Object
-
#initialize ⇒ StateStore
constructor
A new instance of StateStore.
- #set(uri:, text:, diagnostics: []) ⇒ Object
- #text_for(uri) ⇒ Object
Constructor Details
#initialize ⇒ StateStore
Returns a new instance of StateStore.
6 7 8 |
# File 'lib/rubocop/lsp/state_store.rb', line 6 def initialize @state_map = {} end |
Instance Method Details
#clear ⇒ Object
10 11 12 |
# File 'lib/rubocop/lsp/state_store.rb', line 10 def clear @state_map = {} end |
#code_actions_for(uri, line_range) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/rubocop/lsp/state_store.rb', line 36 def code_actions_for(uri, line_range) state = get(uri) return [] unless state state.code_actions(line_range) end |
#delete(uri) ⇒ Object
14 15 16 17 |
# File 'lib/rubocop/lsp/state_store.rb', line 14 def delete(uri) @state_map.delete(uri) [] end |
#get(uri) ⇒ Object
23 24 25 |
# File 'lib/rubocop/lsp/state_store.rb', line 23 def get(uri) @state_map[uri] end |
#set(uri:, text:, diagnostics: []) ⇒ Object
19 20 21 |
# File 'lib/rubocop/lsp/state_store.rb', line 19 def set(uri:, text:, diagnostics: []) @state_map[uri] = State.new(uri: uri, text: text, diagnostics: diagnostics || []) end |
#text_for(uri) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/lsp/state_store.rb', line 27 def text_for(uri) state = get(uri) return state.text if state file = CGI.unescape(URI.parse(uri).path) File.binread(file) end |