Class: Solargraph::LiveMap

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/live_map.rb,
lib/solargraph/live_map/cache.rb

Overview

The LiveMap allows extensions to add their own completion suggestions.

Defined Under Namespace

Classes: Cache

Constant Summary collapse

@@plugins =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace) ⇒ LiveMap

Returns a new instance of LiveMap.



9
10
11
12
13
# File 'lib/solargraph/live_map.rb', line 9

def initialize workspace
  @workspace = workspace
  @runners = []
  at_exit { stop }
end

Instance Attribute Details

#workspaceObject (readonly)

Returns the value of attribute workspace.



7
8
9
# File 'lib/solargraph/live_map.rb', line 7

def workspace
  @workspace
end

Class Method Details

.install(cls) ⇒ Object



61
62
63
# File 'lib/solargraph/live_map.rb', line 61

def self.install cls
  @@plugins.push cls
end

Instance Method Details

#get_instance_methods(namespace, root = '', with_private = false) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/solargraph/live_map.rb', line 41

def get_instance_methods(namespace, root = '', with_private = false)
  result = []
  @runners.each do |p|
    resp = p.get_methods(namespace: namespace, root: root, scope: 'instance', with_private: with_private)
    STDERR.puts resp.message unless resp.ok?
    result.concat(resp.data)
  end
  result
end

#get_methods(namespace, root = '', with_private = false) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/solargraph/live_map.rb', line 51

def get_methods(namespace, root = '', with_private = false)
  result = []
  @runners.each do |p|
    resp = p.get_methods(namespace: namespace, root: root, scope: 'class', with_private: with_private)
    STDERR.puts resp.message unless resp.ok?
    result.concat(resp.data)
  end
  result
end

#reloadObject



25
26
27
# File 'lib/solargraph/live_map.rb', line 25

def reload
  restart
end

#restartObject



29
30
31
32
# File 'lib/solargraph/live_map.rb', line 29

def restart
  stop
  start
end

#startObject



15
16
17
18
19
20
21
22
23
# File 'lib/solargraph/live_map.rb', line 15

def start
  unless workspace.nil?
    @@plugins.each do |p|
      r = p.new(workspace)
      r.start
      @runners.push r
    end
  end
end

#stopObject



34
35
36
37
38
39
# File 'lib/solargraph/live_map.rb', line 34

def stop
  @runners.each do |p|
    p.stop
  end
  @runners.clear
end