class Solargraph::Plugin::Runtime
def executable
def executable @executable ||= 'solargraph-runtime' end
def get_constants namespace, root
-
(Array-)
def get_constants namespace, root response = send_get_constants namespace, root response['data'] end
def get_fqns namespace, root
def get_fqns namespace, root response = send_get_fqns namespace, root response['data'] end
def get_methods namespace:, root:, scope:, with_private: false
-
(Array-)
def get_methods namespace:, root:, scope:, with_private: false response = send_get_methods(namespace, root, scope, with_private) response['data'] end
def load_environment
def load_environment return if api_map.nil? STDERR.puts "Required paths given to Runtime: #{api_map.required}" send_require api_map.required @current_required = api_map.required.clone end
def post_initialize
def post_initialize start_process end
def refresh
def refresh if api_map.nil? false else if @current_required != api_map.required STDERR.puts "Restarting #{self.class} process" @io.close unless @io.nil? or @io.closed? start_process true else false end end end
def runtime?
-
(Boolean)-
def runtime? true end
def send_get_constants namespace, root
def send_get_constants namespace, root cmd = { command: 'constants', params: { namespace: namespace, root: root } } transact cmd end
def send_get_fqns namespace, root
def send_get_fqns namespace, root cmd = { command: 'fqns', params: { namespace: namespace, root: root } } transact cmd end
def send_get_methods namespace, root, scope, with_private
def send_get_methods namespace, root, scope, with_private cmd = { command: 'methods', params: { namespace: namespace, root: root, scope: scope, with_private: with_private } } transact cmd end
def send_require paths
def send_require paths cmd = { command: 'require', paths: paths } transact cmd end
def start_process
def start_process dir = Dir.pwd unless api_map.nil? or api_map.workspace.nil? dir = api_map.workspace end STDERR.puts "Starting #{self.class} process in #{dir}" Dir.chdir(dir) do @io = IO.popen(executable, 'r+') end load_environment end
def transact cmd
def transact cmd @io.puts cmd.to_json @io.flush result = @io.gets JSON.parse(result) end