rider-server 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.build.yml +3 -3
  3. data/CHANGELOG.md +17 -1
  4. data/README.rdoc +39 -0
  5. data/Rakefile +5 -0
  6. data/exe/rider-server +3 -3
  7. data/lib/rider_server/config.rb +76 -0
  8. data/lib/rider_server/core_ext/array.rb +3 -1
  9. data/lib/rider_server/core_ext/class.rb +5 -0
  10. data/lib/rider_server/core_ext/env.rb +14 -0
  11. data/lib/rider_server/core_ext/hash.rb +3 -1
  12. data/lib/rider_server/core_ext/kernel.rb +5 -0
  13. data/lib/rider_server/core_ext/module.rb +18 -0
  14. data/lib/rider_server/core_ext/object.rb +7 -1
  15. data/lib/rider_server/core_ext/string.rb +3 -1
  16. data/lib/rider_server/core_ext/symbol.rb +3 -1
  17. data/lib/rider_server/exception_extension.rb +2 -0
  18. data/lib/rider_server/inspect.rb +108 -32
  19. data/lib/rider_server/logger.rb +11 -4
  20. data/lib/rider_server/operation.rb +39 -20
  21. data/lib/rider_server/{ops → operations}/clone.rb +3 -2
  22. data/lib/rider_server/{ops → operations}/close.rb +3 -2
  23. data/lib/rider_server/operations/completions.rb +146 -0
  24. data/lib/rider_server/operations/lookup.rb +102 -0
  25. data/lib/rider_server/operations/ls_sessions.rb +51 -0
  26. data/lib/rider_server/operations/toggle_catch_all_exceptions.rb +24 -0
  27. data/lib/rider_server/operations.rb +42 -68
  28. data/lib/rider_server/request.rb +61 -0
  29. data/lib/rider_server/response.rb +10 -2
  30. data/lib/rider_server/server.rb +28 -16
  31. data/lib/rider_server/services/capture_exceptions.rb +1 -1
  32. data/lib/rider_server/services/rails.rb +1 -1
  33. data/lib/rider_server/session.rb +75 -44
  34. data/lib/rider_server/session_operation.rb +17 -0
  35. data/lib/rider_server/session_operations/eval.rb +61 -0
  36. data/lib/rider_server/session_operations/inspect.rb +123 -0
  37. data/lib/rider_server/session_operations/inspect_exception.rb +46 -0
  38. data/lib/rider_server/session_operations/interrupt.rb +29 -0
  39. data/lib/rider_server/session_operations/load_path.rb +19 -0
  40. data/lib/rider_server/session_operations/ls_exceptions.rb +28 -0
  41. data/lib/rider_server/session_operations/ls_services.rb +18 -0
  42. data/lib/rider_server/session_operations/service.rb +42 -0
  43. data/lib/rider_server/session_operations/set_namespace.rb +82 -0
  44. data/lib/rider_server/session_operations/set_namespace_variable.rb +81 -0
  45. data/lib/rider_server/session_operations/stdin.rb +19 -0
  46. data/lib/rider_server/utils.rb +7 -7
  47. data/lib/rider_server/validate/array.rb +32 -0
  48. data/lib/rider_server/validate/base.rb +28 -0
  49. data/lib/rider_server/validate/boolean.rb +47 -0
  50. data/lib/rider_server/validate/hash.rb +32 -0
  51. data/lib/rider_server/validate/integer.rb +56 -0
  52. data/lib/rider_server/validate/predicates.rb +30 -0
  53. data/lib/rider_server/validate/string.rb +60 -0
  54. data/lib/rider_server/validate/symbol.rb +90 -0
  55. data/lib/rider_server/validate.rb +15 -0
  56. data/lib/rider_server/version.rb +1 -1
  57. data/lib/rider_server/workspace.rb +1 -1
  58. data/lib/rider_server.rb +3 -1
  59. metadata +54 -24
  60. data/README.md +0 -46
  61. data/lib/rider_server/ops/completions.rb +0 -145
  62. data/lib/rider_server/ops/eval.rb +0 -62
  63. data/lib/rider_server/ops/inspect.rb +0 -121
  64. data/lib/rider_server/ops/inspect_exception.rb +0 -47
  65. data/lib/rider_server/ops/interrupt.rb +0 -30
  66. data/lib/rider_server/ops/load_path.rb +0 -20
  67. data/lib/rider_server/ops/lookup.rb +0 -104
  68. data/lib/rider_server/ops/ls_exceptions.rb +0 -29
  69. data/lib/rider_server/ops/ls_services.rb +0 -19
  70. data/lib/rider_server/ops/ls_sessions.rb +0 -52
  71. data/lib/rider_server/ops/service.rb +0 -43
  72. data/lib/rider_server/ops/set_namespace.rb +0 -79
  73. data/lib/rider_server/ops/set_namespace_variable.rb +0 -80
  74. data/lib/rider_server/ops/stdin.rb +0 -20
  75. data/lib/rider_server/ops/toggle_catch_all_exceptions.rb +0 -27
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rider-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Sim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-31 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bencode
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.8'
19
+ version: '1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.8'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: binding_of_caller
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: parser
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.1.0
41
55
  description: ''
42
56
  email:
43
57
  - rsl@simopolis.xyz
@@ -51,12 +65,17 @@ files:
51
65
  - ".standard.yml"
52
66
  - CHANGELOG.md
53
67
  - COPYING
54
- - README.md
68
+ - README.rdoc
55
69
  - Rakefile
56
70
  - exe/rider-server
57
71
  - lib/rider_server.rb
72
+ - lib/rider_server/config.rb
58
73
  - lib/rider_server/core_ext/array.rb
74
+ - lib/rider_server/core_ext/class.rb
75
+ - lib/rider_server/core_ext/env.rb
59
76
  - lib/rider_server/core_ext/hash.rb
77
+ - lib/rider_server/core_ext/kernel.rb
78
+ - lib/rider_server/core_ext/module.rb
60
79
  - lib/rider_server/core_ext/object.rb
61
80
  - lib/rider_server/core_ext/string.rb
62
81
  - lib/rider_server/core_ext/symbol.rb
@@ -66,23 +85,13 @@ files:
66
85
  - lib/rider_server/logger.rb
67
86
  - lib/rider_server/operation.rb
68
87
  - lib/rider_server/operations.rb
69
- - lib/rider_server/ops/clone.rb
70
- - lib/rider_server/ops/close.rb
71
- - lib/rider_server/ops/completions.rb
72
- - lib/rider_server/ops/eval.rb
73
- - lib/rider_server/ops/inspect.rb
74
- - lib/rider_server/ops/inspect_exception.rb
75
- - lib/rider_server/ops/interrupt.rb
76
- - lib/rider_server/ops/load_path.rb
77
- - lib/rider_server/ops/lookup.rb
78
- - lib/rider_server/ops/ls_exceptions.rb
79
- - lib/rider_server/ops/ls_services.rb
80
- - lib/rider_server/ops/ls_sessions.rb
81
- - lib/rider_server/ops/service.rb
82
- - lib/rider_server/ops/set_namespace.rb
83
- - lib/rider_server/ops/set_namespace_variable.rb
84
- - lib/rider_server/ops/stdin.rb
85
- - lib/rider_server/ops/toggle_catch_all_exceptions.rb
88
+ - lib/rider_server/operations/clone.rb
89
+ - lib/rider_server/operations/close.rb
90
+ - lib/rider_server/operations/completions.rb
91
+ - lib/rider_server/operations/lookup.rb
92
+ - lib/rider_server/operations/ls_sessions.rb
93
+ - lib/rider_server/operations/toggle_catch_all_exceptions.rb
94
+ - lib/rider_server/request.rb
86
95
  - lib/rider_server/response.rb
87
96
  - lib/rider_server/server.rb
88
97
  - lib/rider_server/service.rb
@@ -90,8 +99,29 @@ files:
90
99
  - lib/rider_server/services/capture_io.rb
91
100
  - lib/rider_server/services/rails.rb
92
101
  - lib/rider_server/session.rb
102
+ - lib/rider_server/session_operation.rb
103
+ - lib/rider_server/session_operations/eval.rb
104
+ - lib/rider_server/session_operations/inspect.rb
105
+ - lib/rider_server/session_operations/inspect_exception.rb
106
+ - lib/rider_server/session_operations/interrupt.rb
107
+ - lib/rider_server/session_operations/load_path.rb
108
+ - lib/rider_server/session_operations/ls_exceptions.rb
109
+ - lib/rider_server/session_operations/ls_services.rb
110
+ - lib/rider_server/session_operations/service.rb
111
+ - lib/rider_server/session_operations/set_namespace.rb
112
+ - lib/rider_server/session_operations/set_namespace_variable.rb
113
+ - lib/rider_server/session_operations/stdin.rb
93
114
  - lib/rider_server/transports/bencode.rb
94
115
  - lib/rider_server/utils.rb
116
+ - lib/rider_server/validate.rb
117
+ - lib/rider_server/validate/array.rb
118
+ - lib/rider_server/validate/base.rb
119
+ - lib/rider_server/validate/boolean.rb
120
+ - lib/rider_server/validate/hash.rb
121
+ - lib/rider_server/validate/integer.rb
122
+ - lib/rider_server/validate/predicates.rb
123
+ - lib/rider_server/validate/string.rb
124
+ - lib/rider_server/validate/symbol.rb
95
125
  - lib/rider_server/version.rb
96
126
  - lib/rider_server/workspace.rb
97
127
  homepage: https://sr.ht/~rsl/rider-server/
@@ -107,9 +137,9 @@ require_paths:
107
137
  - lib
108
138
  required_ruby_version: !ruby/object:Gem::Requirement
109
139
  requirements:
110
- - - "<"
140
+ - - ">="
111
141
  - !ruby/object:Gem::Version
112
- version: 3.2.0
142
+ version: '0'
113
143
  required_rubygems_version: !ruby/object:Gem::Requirement
114
144
  requirements:
115
145
  - - ">="
data/README.md DELETED
@@ -1,46 +0,0 @@
1
- # RIDER -- RIDER Interactive Development Environment for Ruby
2
-
3
- RIDER Server is the server component of the RIDER development
4
- environment.
5
-
6
- ## Installation
7
-
8
- TODO: Replace
9
- `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG`
10
- with your gem name right after releasing it to RubyGems.org. Please do
11
- not do it earlier due to security reasons. Alternatively, replace this
12
- section with instructions to install your gem from git if you don't
13
- plan to release to RubyGems.org.
14
-
15
- Install the gem and add to the application's Gemfile by executing:
16
-
17
- $ bundle add rider-server
18
-
19
- If bundler is not being used to manage dependencies, install the gem by executing:
20
-
21
- $ gem install rider-server
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install
30
- dependencies. Then, run `rake test` to run the tests. You can also run
31
- `bin/console` for an interactive prompt that will allow you to
32
- experiment.
33
-
34
- To install this gem onto your local machine, run `bundle exec rake
35
- install`.
36
-
37
- To release a new version run `rake bump:patch` and then run `bundle
38
- exec rake release`, which will create a git tag for the version, push
39
- git commits and the created tag, and push the `.gem` file to
40
- [rubygems.org](https://rubygems.org).
41
-
42
- ## Contributing
43
-
44
- Bug reports https://todo.sr.ht/~rsl/rider
45
-
46
- Support or discussion https://lists.sr.ht/~rsl/rider-devel
@@ -1,145 +0,0 @@
1
- require "rider_server/operation"
2
- require "rider_server/response"
3
- require "rider_server/inspect"
4
-
5
- module RiderServer
6
- module Ops
7
- class Completions < Operation
8
- documentation "Get completions for a given prefix"
9
-
10
- argument :id, :string, "The request id", required: true
11
- argument :prefix, :string, "The prefix to complete", required: true
12
- argument :complete_fn, :string, "What completion function to use, top-level, module, method or singleton-method"
13
- argument :ns, :string, "The namespace to search for completions"
14
-
15
- def initialize(*args)
16
- @workspace = Workspace.new
17
- super
18
- end
19
-
20
- def handle(session, operation)
21
- response = Response.new(operation)
22
-
23
- prefix = operation["prefix"]
24
- ns = operation["ns"]
25
- complete_fn = operation.fetch("complete-fn", "top-level")
26
-
27
- if prefix.nil? || parse_string(prefix).nil?
28
- response.set("completions", [])
29
- else
30
- ns_object = if ns.empty?
31
- ::Object
32
- else
33
- @workspace.lookup_module(ns)
34
- end
35
-
36
- # If the prefix isn't parseable, return an empty list
37
- response.set("completions", lookup_module(prefix, klass: ns_object, completion_fn: complete_fn))
38
- end
39
- response.status("done")
40
- response
41
- end
42
-
43
- def lookup_module(module_name, klass: ::Object, completion_fn: "top-level")
44
- node = parse_string(module_name)
45
- case node.type
46
- when :const
47
- ns = lookup_module_ast(node.children.first, klass)
48
- prefix = node.children.last
49
- all_constants(ns, prefix)
50
- when :send
51
- ns = lookup_module_ast(node.children.first, klass)
52
- prefix = node.children.last
53
- if completion_fn == "method"
54
- all_constants(ns, prefix) + encode_methods(class_instance_methods(ns, prefix) + class_singleton_methods(::Kernel, prefix))
55
- else
56
- all_constants(ns, prefix) + encode_methods(class_methods(ns, prefix) + class_singleton_methods(::Kernel, prefix))
57
- end
58
- else
59
- []
60
- end
61
- end
62
-
63
- def parse_string(string)
64
- buffer = Parser::Source::Buffer.new("(string)")
65
- buffer.source = string
66
- Parser::CurrentRuby.new.parse(buffer)
67
- end
68
-
69
- def lookup_module_ast(node, klass = ::Object)
70
- return klass if node.nil?
71
-
72
- case node.type
73
- when :cbase
74
- ::Object
75
- when :const
76
- if node.children.first.nil?
77
- klass.const_get(node.children.last)
78
- else
79
- lookup_module_ast(node.children.first, klass).const_get(node.children.last)
80
- end
81
- else
82
- raise ModuleLookupError, "Unknown node type #{node.type}"
83
- end
84
- end
85
-
86
- def parent_constant(ns_object)
87
- ns_object_name = ns_object.to_s
88
- parent_name, _ = ns_object_name.rpartition("::")
89
- parent_name.empty? ? nil : ::Object.const_get(parent_name)
90
- end
91
-
92
- def all_constants(ns_object, prefix)
93
- consts = []
94
- ns_object.constants.grep(/^#{prefix}/).each do |constant|
95
- consts << constant.to_s
96
- end
97
-
98
- # Search up the tree to find all the other constants
99
- constant = ns_object
100
- loop do
101
- constant = parent_constant(constant)
102
- break if constant.nil?
103
-
104
- constant.constants.grep(/^#{prefix}/).each do |constant|
105
- consts << constant.to_s
106
- end
107
- end
108
-
109
- consts.map do |constant|
110
- {
111
- "candidate" => constant,
112
- "type" => "constant"
113
- }
114
- end
115
- end
116
-
117
- ##
118
- # Get all instance methods that match a +prefix+ for a given object +obj+
119
- #
120
- # This method should be called when in the context of an
121
- # instance method, as all other instance methods will be
122
- # acessable.
123
- def class_instance_methods(obj, prefix)
124
- Set.new(obj.instance_methods.grep(/^#{prefix}/))
125
- end
126
-
127
- def class_methods(obj, prefix)
128
- Set.new(obj.methods.grep(/^#{prefix}/))
129
- end
130
-
131
- def class_singleton_methods(obj, prefix)
132
- Set.new(obj.singleton_methods.grep(/^#{prefix}/))
133
- end
134
-
135
- def encode_methods(methods)
136
- methods.map do |method|
137
- {
138
- "candidate" => method.to_s,
139
- "type" => "method"
140
- }
141
- end
142
- end
143
- end
144
- end
145
- end
@@ -1,62 +0,0 @@
1
- require "rider_server/operation"
2
- require "rider_server/response"
3
- require "rider_server/utils"
4
-
5
- module RiderServer
6
- module Ops
7
- class Eval < Operation
8
- documentation "Evaluate a string of code"
9
-
10
- argument :id, :string, "The request id", required: true
11
- argument :code, :string, "The code to evaluate"
12
- argument :ns, :string, "The namespace to evaluate the code in"
13
- argument :file, :string, "The file the code is from"
14
- argument :line, :integer, "The line number the code is from"
15
-
16
- def handle(session, operation)
17
- # TODO should do something if the session is nil
18
-
19
- response = Response.new(operation)
20
-
21
- # Abort if there is an evaluation with the same id
22
- if session.running_evaluation?(operation["id"])
23
- msg = "Evaluation already in progress for #{operation["id"]}"
24
- log.warn(msg)
25
- response.set("value", msg)
26
- response.status("eval-error", "done")
27
- send_response(response)
28
- return
29
- end
30
-
31
- session.push_history(operation)
32
- code = operation["code"]
33
- ns = operation["ns"]
34
- file = operation["file"] || ""
35
- line = operation["line"] || 0
36
-
37
- eval_thread = Thread.new do
38
- begin
39
- value = session.workspace.evaluate(code, ns, file, line)
40
- response.set("value", Utils.rider_inspect(value))
41
- response.set("ns", session.workspace.evaluate("inspect"))
42
- response.status("done")
43
- session.add_result(operation["id"], value)
44
- send_response(response)
45
- rescue EvalInterrupt, ScriptError, StandardError => e
46
- response.set("ex", e.inspect)
47
- response.set("ns", session.workspace.evaluate("inspect"))
48
- response.status("eval-error", "done")
49
- exception = session.push_exception(operation["id"], e)
50
- response.set("rider/exception-id", exception["id"])
51
- send_response(response)
52
- end
53
-
54
- session.remove_evaluation(operation["id"])
55
- end
56
-
57
- session.add_evaluation(operation["id"], eval_thread)
58
- nil
59
- end
60
- end
61
- end
62
- end
@@ -1,121 +0,0 @@
1
- require "rider_server/inspect"
2
- require "rider_server/operation"
3
- require "rider_server/response"
4
- require "rider_server/utils"
5
-
6
- module RiderServer
7
- module Ops
8
- class Inspect < Operation
9
- documentation "Inspect an object"
10
-
11
- argument :id, :string, "The request id", required: true
12
- argument :location, :array, "The location of the object to inspect"
13
-
14
- def handle(session, operation)
15
- response = Response.new(operation)
16
- location = operation["location"]
17
- raise "Location is required" if location.nil? || location.empty?
18
-
19
- value = traverse_location(location, nil, session)
20
- response.set("name", Utils.rider_inspect(value))
21
-
22
- if value.is_a?(Array)
23
- value = value.map.with_index do |item, index|
24
- {
25
- "name" => item.to_s,
26
- "value" => Utils.rider_inspect(item),
27
- "inspect-location" => "rider_array_item:#{index}"
28
- }
29
- end
30
- response.set("value-array", value)
31
- elsif value.is_a?(Hash)
32
- value = value.map do |key, value|
33
- [
34
- {
35
- "name" => key.to_s,
36
- "value" => Utils.rider_inspect(key),
37
- "inspect-location" => "rider_hash_key:#{key.hash}"
38
- },
39
- {
40
- "name" => value.to_s,
41
- "value" => Utils.rider_inspect(value),
42
- "inspect-location" => "rider_hash_value:#{key.hash}"
43
- }
44
- ]
45
- end
46
- response.set("value-hash", value)
47
- elsif value.is_a?(String)
48
- response.set("value", value.inspect)
49
- elsif value.is_a?(Numeric)
50
- response.set("value", value.to_s)
51
- end
52
-
53
- response.set("inspect-location", location)
54
-
55
- response.set("class", RiderServer::Inspect.class(value))
56
- response.set("ancestors", RiderServer::Inspect.ancestors(value))
57
- response.set("constants", RiderServer::Inspect.constants(value))
58
- response.set("methods", RiderServer::Inspect.methods(value))
59
- response.set("instance-variables", RiderServer::Inspect.instance_variables(value))
60
- response.set("instance-methods", RiderServer::Inspect.instance_methods(value))
61
- response.set("class-variables", RiderServer::Inspect.class_variables(value))
62
- response.status("done")
63
- response
64
- end
65
-
66
- def traverse_location(location, ctx, session)
67
- loc = location.first
68
- locs = location.drop(1)
69
-
70
- if locs.empty?
71
- lookup_object(loc, ctx, session)
72
- else
73
- traverse_location(locs, lookup_object(loc, ctx, session), session)
74
- end
75
- end
76
-
77
- def lookup_object(loc, ctx, session)
78
- lookup, identifier = loc.split(":", 2)
79
-
80
- case lookup
81
- when "rider_main"
82
- "main"
83
- when "rider_history"
84
- rider_history(identifier, nil, session)
85
- when "rider_exception"
86
- rider_exception(identifier, nil, session)
87
- when "rider_stackframe_variable"
88
- frame_id, local_var = identifier.split(":", 2)
89
- ctx.__rider_bindings_stack[frame_id.to_i].local_variable_get(local_var)
90
- when "rider_array_item"
91
- ctx[identifier.to_i]
92
- when "rider_hash_key"
93
- hash = identifier.to_i
94
- ctx.keys.find { |key| key.hash == hash }
95
- when "rider_hash_value"
96
- hash = identifier.to_i
97
- key = ctx.keys.find { |key| key.hash == hash }
98
- ctx.fetch(key)
99
- when "toplevel_const_get"
100
- Object.const_get(identifier)
101
- when "instance_variable_get"
102
- ctx.instance_variable_get(identifier)
103
- when "const_get"
104
- ctx.const_get(identifier)
105
- when "ancestor_find"
106
- ctx.class.ancestors.find { |item| item.to_s == identifier }
107
- else
108
- raise "Unknown inspect function: #{lookup}"
109
- end
110
- end
111
-
112
- def rider_history(id, ctx, session)
113
- session.get_result(id)
114
- end
115
-
116
- def rider_exception(id, ctx, session)
117
- session.get_exception(id)["exception"]
118
- end
119
- end
120
- end
121
- end
@@ -1,47 +0,0 @@
1
- require "rider_server/operation"
2
- require "rider_server/response"
3
-
4
- module RiderServer
5
- module Ops
6
- class InspectException < Operation
7
- documentation "Inspect an exception."
8
-
9
- argument :id, :string, "The request id", required: true
10
- argument :"exception-id", :string, "The exception id"
11
-
12
- def handle(session, operation)
13
- response = Response.new(operation)
14
- exception_id = operation["exception-id"]
15
-
16
- value = session.get_exception(exception_id)
17
- response.set("inspect-location", value["id"])
18
- response.set("exception-id", value["id"])
19
- response.set("source-operation-id", value["operation_id"])
20
- response.set("created-at", value["created_at"].to_s)
21
-
22
- exception = value["exception"]
23
- response.set("value", exception.inspect)
24
- response.set("stacktrace", encode_stacktrace(exception, exception_id))
25
-
26
- response.status("done")
27
- response
28
- end
29
-
30
- def encode_stacktrace(exception, exception_id)
31
- exception.backtrace.zip(exception.__rider_bindings_stack).map.with_index do |(line, frame), frame_id|
32
- {
33
- "line" => line,
34
- "inspect-location" => ["rider_exception:#{exception_id}", "rider_stackframe:#{frame_id}"],
35
- "frame" => (frame&.local_variables || []).map do |var|
36
- {
37
- "name" => var.to_s,
38
- "value" => Utils.rider_inspect(frame.local_variable_get(var)),
39
- "inspect-location" => ["rider_exception:#{exception_id}", "rider_stackframe_variable:#{frame_id}:#{var}"]
40
- }
41
- end
42
- }
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,30 +0,0 @@
1
- require "rider_server/operation"
2
- require "rider_server/response"
3
-
4
- module RiderServer
5
- module Ops
6
- class Interrupt < Operation
7
- documentation "Interrupts the evaluation of a session."
8
-
9
- argument :id, :string, "The request id", required: true
10
- argument :"interrupt-id", :string, "The ID of the evaluation to interrupt.", required: true
11
-
12
- def handle(session, operation)
13
- # TODO should do something if the session is nil
14
-
15
- if operation["interrupt-id"].nil? || operation["interrupt-id"].empty?
16
- if session.evaluations.empty?
17
- raise ArgumentError, "No evaluations to interrupt"
18
- end
19
- session.interrupt_evaluation(session.evaluations.keys.max)
20
- else
21
- session.interrupt_evaluation(operation["interrupt-id"])
22
- end
23
-
24
- response = Response.new(operation)
25
- response.status("interrupted", "done")
26
- response
27
- end
28
- end
29
- end
30
- end
@@ -1,20 +0,0 @@
1
- require "rider_server/operation"
2
- require "rider_server/response"
3
-
4
- module RiderServer
5
- module Ops
6
- class LoadPath < Operation
7
- documentation "Return the current load path."
8
-
9
- argument :id, :string, "The request id", required: true
10
-
11
- def handle(session, operation)
12
- response = Response.new(operation)
13
- load_path = session.workspace.evaluate("$LOAD_PATH", "main")
14
- response.set("load-path", load_path)
15
- response.status("done")
16
- response
17
- end
18
- end
19
- end
20
- end