ruby-lsp 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -16
  3. data/.github/pull_request_template.md +15 -0
  4. data/.github/workflows/ci.yml +31 -0
  5. data/.github/workflows/publish_docs.yml +32 -0
  6. data/.gitignore +9 -12
  7. data/.rubocop.yml +20 -2
  8. data/.vscode/settings.json +5 -0
  9. data/CHANGELOG.md +29 -0
  10. data/Gemfile +8 -4
  11. data/Gemfile.lock +76 -14
  12. data/README.md +69 -2
  13. data/Rakefile +5 -0
  14. data/VERSION +1 -1
  15. data/bin/tapioca +29 -0
  16. data/bin/test +7 -1
  17. data/dev.yml +7 -7
  18. data/exe/ruby-lsp +19 -2
  19. data/lib/internal.rb +7 -0
  20. data/lib/ruby-lsp.rb +4 -1
  21. data/lib/ruby_lsp/cli.rb +88 -0
  22. data/lib/ruby_lsp/document.rb +113 -0
  23. data/lib/ruby_lsp/handler.rb +236 -0
  24. data/lib/ruby_lsp/requests/base_request.rb +33 -0
  25. data/lib/ruby_lsp/requests/code_actions.rb +37 -0
  26. data/lib/ruby_lsp/requests/diagnostics.rb +37 -0
  27. data/lib/ruby_lsp/requests/document_highlight.rb +96 -0
  28. data/lib/ruby_lsp/requests/document_symbol.rb +216 -0
  29. data/lib/ruby_lsp/requests/folding_ranges.rb +213 -0
  30. data/lib/ruby_lsp/requests/formatting.rb +52 -0
  31. data/lib/ruby_lsp/requests/rubocop_request.rb +50 -0
  32. data/lib/ruby_lsp/requests/selection_ranges.rb +103 -0
  33. data/lib/ruby_lsp/requests/semantic_highlighting.rb +112 -0
  34. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +88 -0
  35. data/lib/ruby_lsp/requests/support/selection_range.rb +17 -0
  36. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +60 -0
  37. data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +27 -0
  38. data/lib/ruby_lsp/requests.rb +24 -0
  39. data/lib/ruby_lsp/store.rb +59 -0
  40. data/rakelib/check_docs.rake +56 -0
  41. data/ruby-lsp.gemspec +5 -1
  42. data/{shipit.yml → shipit.production.yml} +0 -0
  43. data/sorbet/config +4 -0
  44. data/sorbet/rbi/.rubocop.yml +8 -0
  45. data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
  46. data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
  47. data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
  48. data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
  49. data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
  50. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
  51. data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
  52. data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
  53. data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
  54. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  55. data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
  56. data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
  57. data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
  58. data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
  59. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
  60. data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
  61. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
  62. data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
  63. data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
  64. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
  65. data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
  66. data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
  67. data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
  68. data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
  69. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
  70. data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
  71. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
  72. data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
  73. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
  74. data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
  75. data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
  76. data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
  77. data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
  78. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
  79. data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
  80. data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
  81. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
  82. data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
  83. data/sorbet/rbi/shims/fiddle.rbi +4 -0
  84. data/sorbet/rbi/shims/hash.rbi +6 -0
  85. data/sorbet/rbi/shims/rdoc.rbi +4 -0
  86. data/sorbet/tapioca/config.yml +13 -0
  87. data/sorbet/tapioca/require.rb +7 -0
  88. metadata +119 -9
  89. data/.vscode/launch.json +0 -19
  90. data/bin/package_extension +0 -5
  91. data/bin/style +0 -10
  92. data/lib/ruby/lsp/cli.rb +0 -37
  93. data/lib/ruby/lsp.rb +0 -3
@@ -0,0 +1,289 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `yard-sorbet` gem.
5
+ # Please instead update this file by running `bin/tapioca gem yard-sorbet`.
6
+
7
+ # Types are documentation
8
+ module YARDSorbet; end
9
+
10
+ # Extract & re-add directives to a docstring
11
+ module YARDSorbet::Directives
12
+ class << self
13
+ sig { params(docstring: ::String, directives: T::Array[::String]).void }
14
+ def add_directives(docstring, directives); end
15
+
16
+ sig { params(docstring: T.nilable(::String)).returns([::YARD::Docstring, T::Array[::String]]) }
17
+ def extract_directives(docstring); end
18
+ end
19
+ end
20
+
21
+ # Custom YARD Handlers
22
+ #
23
+ # @see https://rubydoc.info/gems/yard/YARD/Handlers/Base YARD Base Handler documentation
24
+ module YARDSorbet::Handlers; end
25
+
26
+ # Apllies an `@abstract` tag to `abstract!`/`interface!` modules (if not alerady present).
27
+ class YARDSorbet::Handlers::AbstractDSLHandler < ::YARD::Handlers::Ruby::Base
28
+ sig { void }
29
+ def process; end
30
+ end
31
+
32
+ # Extra text for class namespaces
33
+ YARDSorbet::Handlers::AbstractDSLHandler::CLASS_TAG_TEXT = T.let(T.unsafe(nil), String)
34
+
35
+ # The text accompanying the `@abstract` tag.
36
+ #
37
+ # @see https://github.com/lsegal/yard/blob/main/templates/default/docstring/html/abstract.erb The `@abstract` tag template
38
+ YARDSorbet::Handlers::AbstractDSLHandler::TAG_TEXT = T.let(T.unsafe(nil), String)
39
+
40
+ # Handle `enums` calls, registering enum values as constants
41
+ class YARDSorbet::Handlers::EnumsHandler < ::YARD::Handlers::Ruby::Base
42
+ sig { void }
43
+ def process; end
44
+
45
+ private
46
+
47
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Boolean) }
48
+ def const_assign_node?(node); end
49
+ end
50
+
51
+ # Extends any modules included via `mixes_in_class_methods`
52
+ #
53
+ # @see https://sorbet.org/docs/abstract#interfaces-and-the-included-hook Sorbet `mixes_in_class_methods` documentation
54
+ class YARDSorbet::Handlers::IncludeHandler < ::YARD::Handlers::Ruby::Base
55
+ sig { void }
56
+ def process; end
57
+
58
+ private
59
+
60
+ sig { returns(::YARD::CodeObjects::NamespaceObject) }
61
+ def included_in; end
62
+ end
63
+
64
+ # Tracks modules that invoke `mixes_in_class_methods` for use in {IncludeHandler}
65
+ #
66
+ # @see https://sorbet.org/docs/abstract#interfaces-and-the-included-hook Sorbet `mixes_in_class_methods` documentation
67
+ class YARDSorbet::Handlers::MixesInClassMethodsHandler < ::YARD::Handlers::Ruby::Base
68
+ sig { void }
69
+ def process; end
70
+
71
+ class << self
72
+ sig { params(code_obj: ::String).returns(T.nilable(::String)) }
73
+ def mixed_in_class_methods(code_obj); end
74
+ end
75
+ end
76
+
77
+ # A YARD Handler for Sorbet type declarations
78
+ class YARDSorbet::Handlers::SigHandler < ::YARD::Handlers::Ruby::Base
79
+ # Swap the method definition docstring and the sig docstring.
80
+ # Parse relevant parts of the `sig` and include them as well.
81
+ sig { void }
82
+ def process; end
83
+
84
+ private
85
+
86
+ sig do
87
+ params(
88
+ method_node: ::YARD::Parser::Ruby::AstNode,
89
+ node: ::YARD::Parser::Ruby::AstNode,
90
+ docstring: ::YARD::Docstring
91
+ ).void
92
+ end
93
+ def parse_params(method_node, node, docstring); end
94
+
95
+ sig { params(node: ::YARD::Parser::Ruby::AstNode, docstring: ::YARD::Docstring).void }
96
+ def parse_return(node, docstring); end
97
+
98
+ sig { params(method_node: ::YARD::Parser::Ruby::AstNode, docstring: ::YARD::Docstring).void }
99
+ def parse_sig(method_node, docstring); end
100
+ end
101
+
102
+ # These node types attached to sigs represent attr_* declarations
103
+ YARDSorbet::Handlers::SigHandler::ATTR_NODE_TYPES = T.let(T.unsafe(nil), Array)
104
+
105
+ # Class-level handler that folds all `const` and `prop` declarations into the constructor documentation
106
+ # this needs to be injected as a module otherwise the default Class handler will overwrite documentation
107
+ #
108
+ # @note this module is included in `YARD::Handlers::Ruby::ClassHandler`
109
+ module YARDSorbet::Handlers::StructClassHandler
110
+ sig { void }
111
+ def process; end
112
+
113
+ private
114
+
115
+ sig do
116
+ params(
117
+ object: ::YARD::CodeObjects::MethodObject,
118
+ props: T::Array[::YARDSorbet::TStructProp],
119
+ docstring: ::YARD::Docstring,
120
+ directives: T::Array[::String]
121
+ ).void
122
+ end
123
+ def decorate_t_struct_init(object, props, docstring, directives); end
124
+
125
+ # Create a virtual `initialize` method with all the `prop`/`const` arguments
126
+ sig { params(props: T::Array[::YARDSorbet::TStructProp], class_ns: ::YARD::CodeObjects::ClassObject).void }
127
+ def process_t_struct_props(props, class_ns); end
128
+
129
+ sig { params(props: T::Array[::YARDSorbet::TStructProp]).returns(T::Array[[::String, T.nilable(::String)]]) }
130
+ def to_object_parameters(props); end
131
+ end
132
+
133
+ # Handles all `const`/`prop` calls, creating accessor methods, and compiles them for later usage at the class level
134
+ # in creating a constructor
135
+ class YARDSorbet::Handlers::StructPropHandler < ::YARD::Handlers::Ruby::Base
136
+ sig { void }
137
+ def process; end
138
+
139
+ private
140
+
141
+ # Add the source and docstring to the method object
142
+ sig { params(object: ::YARD::CodeObjects::MethodObject, prop: ::YARDSorbet::TStructProp).void }
143
+ def decorate_object(object, prop); end
144
+
145
+ # Get the default prop value
146
+ sig { returns(T.nilable(::String)) }
147
+ def default_value; end
148
+
149
+ sig { params(name: ::String).returns(::YARDSorbet::TStructProp) }
150
+ def make_prop(name); end
151
+
152
+ # Register the field explicitly as an attribute.
153
+ # While `const` attributes are immutable, `prop` attributes may be reassigned.
154
+ sig { params(object: ::YARD::CodeObjects::MethodObject, name: ::String).void }
155
+ def register_attrs(object, name); end
156
+
157
+ # Store the prop for use in the constructor definition
158
+ sig { params(prop: ::YARDSorbet::TStructProp).void }
159
+ def update_state(prop); end
160
+ end
161
+
162
+ # Helper methods for working with `YARD` AST Nodes
163
+ module YARDSorbet::NodeUtils
164
+ class << self
165
+ # Traverese AST nodes in breadth-first order
166
+ #
167
+ # @note This will skip over some node types.
168
+ # @yield [YARD::Parser::Ruby::AstNode]
169
+ sig do
170
+ params(
171
+ node: ::YARD::Parser::Ruby::AstNode,
172
+ _blk: T.proc.params(n: ::YARD::Parser::Ruby::AstNode).void
173
+ ).void
174
+ end
175
+ def bfs_traverse(node, &_blk); end
176
+
177
+ # Gets the node that a sorbet `sig` can be attached do, bypassing visisbility modifiers and the like
178
+ sig do
179
+ params(
180
+ node: ::YARD::Parser::Ruby::AstNode
181
+ ).returns(T.any(::YARD::Parser::Ruby::MethodCallNode, ::YARD::Parser::Ruby::MethodDefinitionNode))
182
+ end
183
+ def get_method_node(node); end
184
+
185
+ # Find and return the adjacent node (ascending)
186
+ #
187
+ # @raise [IndexError] if the node does not have an adjacent sibling (ascending)
188
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(::YARD::Parser::Ruby::AstNode) }
189
+ def sibling_node(node); end
190
+ end
191
+ end
192
+
193
+ # Command node types that can have type signatures
194
+ YARDSorbet::NodeUtils::ATTRIBUTE_METHODS = T.let(T.unsafe(nil), Array)
195
+
196
+ # Node types that can have type signatures
197
+ YARDSorbet::NodeUtils::SIGABLE_NODE = T.type_alias { T.any(::YARD::Parser::Ruby::MethodCallNode, ::YARD::Parser::Ruby::MethodDefinitionNode) }
198
+
199
+ # Skip these method contents during BFS node traversal, they can have their own nested types via `T.Proc`
200
+ YARDSorbet::NodeUtils::SKIP_METHOD_CONTENTS = T.let(T.unsafe(nil), Array)
201
+
202
+ # Translate `sig` type syntax to `YARD` type syntax.
203
+ module YARDSorbet::SigToYARD
204
+ class << self
205
+ # @see https://yardoc.org/types.html
206
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
207
+ def convert(node); end
208
+
209
+ private
210
+
211
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(::String) }
212
+ def build_generic_type(node); end
213
+
214
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
215
+ def convert_aref(node); end
216
+
217
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
218
+ def convert_array(node); end
219
+
220
+ sig { params(node: ::YARD::Parser::Ruby::MethodCallNode).returns(T::Array[::String]) }
221
+ def convert_call(node); end
222
+
223
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
224
+ def convert_collection(node); end
225
+
226
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
227
+ def convert_hash(node); end
228
+
229
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
230
+ def convert_list(node); end
231
+
232
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
233
+ def convert_node(node); end
234
+
235
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
236
+ def convert_node_type(node); end
237
+
238
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
239
+ def convert_ref(node); end
240
+
241
+ sig { params(node: ::YARD::Parser::Ruby::MethodCallNode).returns(T::Array[::String]) }
242
+ def convert_t_method(node); end
243
+
244
+ sig { params(node: ::YARD::Parser::Ruby::AstNode).returns(T::Array[::String]) }
245
+ def convert_unknown(node); end
246
+ end
247
+ end
248
+
249
+ # Used to store the details of a `T::Struct` `prop` definition
250
+ class YARDSorbet::TStructProp < ::T::Struct
251
+ const :default, T.nilable(::String)
252
+ const :doc, ::String
253
+ const :prop_name, ::String
254
+ const :source, ::String
255
+ const :types, T::Array[::String]
256
+
257
+ class << self
258
+ def inherited(s); end
259
+ end
260
+ end
261
+
262
+ # Helper methods for working with `YARD` tags
263
+ module YARDSorbet::TagUtils
264
+ class << self
265
+ sig do
266
+ params(
267
+ docstring: ::YARD::Docstring,
268
+ tag_name: ::String,
269
+ name: T.nilable(::String)
270
+ ).returns(T.nilable(::YARD::Tags::Tag))
271
+ end
272
+ def find_tag(docstring, tag_name, name); end
273
+
274
+ # Create or update a `YARD` tag with type information
275
+ sig do
276
+ params(
277
+ docstring: ::YARD::Docstring,
278
+ tag_name: ::String,
279
+ types: T.nilable(T::Array[::String]),
280
+ name: T.nilable(::String),
281
+ text: ::String
282
+ ).void
283
+ end
284
+ def upsert_tag(docstring, tag_name, types = T.unsafe(nil), name = T.unsafe(nil), text = T.unsafe(nil)); end
285
+ end
286
+ end
287
+
288
+ # {https://rubygems.org/gems/yard-sorbet Version history}
289
+ YARDSorbet::VERSION = T.let(T.unsafe(nil), String)