Class: Rubocop::Language::Server::StateStore

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/language/server/state_store.rb

Instance Method Summary collapse

Constructor Details

#initializeStateStore

Returns a new instance of StateStore.



7
8
9
# File 'lib/rubocop/language/server/state_store.rb', line 7

def initialize
  @state_map = {}
end

Instance Method Details

#clearObject



11
12
13
# File 'lib/rubocop/language/server/state_store.rb', line 11

def clear
  @state_map = {}
end

#code_actions_for(uri, line_range) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/rubocop/language/server/state_store.rb', line 37

def code_actions_for(uri, line_range)
  state = get(uri)

  return [] unless state

  state.code_actions(line_range)
end

#delete(uri) ⇒ Object



15
16
17
18
# File 'lib/rubocop/language/server/state_store.rb', line 15

def delete(uri)
  @state_map.delete(uri)
  []
end

#get(uri) ⇒ Object



24
25
26
# File 'lib/rubocop/language/server/state_store.rb', line 24

def get(uri)
  @state_map[uri]
end

#set(uri:, text:, diagnostics: []) ⇒ Object



20
21
22
# File 'lib/rubocop/language/server/state_store.rb', line 20

def set(uri:, text:, diagnostics: [])
  @state_map[uri] = State.new(uri: uri, text: text, diagnostics: diagnostics || [])
end

#text_for(uri) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/rubocop/language/server/state_store.rb', line 28

def text_for(uri)
  state = get(uri)

  return state.text if state

  file = CGI.unescape(URI.parse(uri).path)
  File.binread(file)
end