ruby-lsp 0.17.16 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -110
  3. data/VERSION +1 -1
  4. data/exe/ruby-lsp +10 -8
  5. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +14 -6
  6. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +157 -27
  7. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +31 -12
  8. data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +2 -2
  9. data/lib/ruby_indexer/test/classes_and_modules_test.rb +10 -10
  10. data/lib/ruby_indexer/test/constant_test.rb +4 -4
  11. data/lib/ruby_indexer/test/enhancements_test.rb +2 -2
  12. data/lib/ruby_indexer/test/index_test.rb +41 -0
  13. data/lib/ruby_indexer/test/method_test.rb +257 -2
  14. data/lib/ruby_indexer/test/rbs_indexer_test.rb +1 -1
  15. data/lib/ruby_lsp/addon.rb +3 -2
  16. data/lib/ruby_lsp/base_server.rb +21 -1
  17. data/lib/ruby_lsp/document.rb +5 -3
  18. data/lib/ruby_lsp/erb_document.rb +29 -10
  19. data/lib/ruby_lsp/global_state.rb +15 -1
  20. data/lib/ruby_lsp/listeners/code_lens.rb +34 -5
  21. data/lib/ruby_lsp/listeners/folding_ranges.rb +1 -1
  22. data/lib/ruby_lsp/listeners/semantic_highlighting.rb +28 -0
  23. data/lib/ruby_lsp/listeners/signature_help.rb +55 -24
  24. data/lib/ruby_lsp/rbs_document.rb +5 -4
  25. data/lib/ruby_lsp/requests/code_action_resolve.rb +0 -15
  26. data/lib/ruby_lsp/requests/code_actions.rb +0 -10
  27. data/lib/ruby_lsp/requests/code_lens.rb +1 -11
  28. data/lib/ruby_lsp/requests/completion.rb +3 -20
  29. data/lib/ruby_lsp/requests/completion_resolve.rb +0 -8
  30. data/lib/ruby_lsp/requests/definition.rb +6 -20
  31. data/lib/ruby_lsp/requests/diagnostics.rb +0 -10
  32. data/lib/ruby_lsp/requests/document_highlight.rb +7 -14
  33. data/lib/ruby_lsp/requests/document_link.rb +0 -10
  34. data/lib/ruby_lsp/requests/document_symbol.rb +0 -17
  35. data/lib/ruby_lsp/requests/folding_ranges.rb +0 -10
  36. data/lib/ruby_lsp/requests/formatting.rb +3 -17
  37. data/lib/ruby_lsp/requests/hover.rb +9 -9
  38. data/lib/ruby_lsp/requests/inlay_hints.rb +0 -30
  39. data/lib/ruby_lsp/requests/on_type_formatting.rb +0 -10
  40. data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +0 -11
  41. data/lib/ruby_lsp/requests/request.rb +17 -1
  42. data/lib/ruby_lsp/requests/selection_ranges.rb +0 -10
  43. data/lib/ruby_lsp/requests/semantic_highlighting.rb +1 -23
  44. data/lib/ruby_lsp/requests/show_syntax_tree.rb +0 -11
  45. data/lib/ruby_lsp/requests/signature_help.rb +5 -20
  46. data/lib/ruby_lsp/requests/support/common.rb +1 -1
  47. data/lib/ruby_lsp/requests/support/rubocop_runner.rb +2 -0
  48. data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +0 -11
  49. data/lib/ruby_lsp/requests/workspace_symbol.rb +0 -12
  50. data/lib/ruby_lsp/ruby_document.rb +4 -3
  51. data/lib/ruby_lsp/server.rb +23 -8
  52. data/lib/ruby_lsp/setup_bundler.rb +31 -13
  53. data/lib/ruby_lsp/type_inferrer.rb +6 -2
  54. data/lib/ruby_lsp/utils.rb +11 -1
  55. metadata +7 -14
  56. data/lib/ruby_lsp/check_docs.rb +0 -130
@@ -1,130 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "ruby_lsp/internal"
5
- require "objspace"
6
-
7
- module RubyLsp
8
- # This rake task checks that all requests or addons are fully documented. Add the rake task to your Rakefile and
9
- # specify the absolute path for all files that must be required in order to discover all requests and their related
10
- # GIFs
11
- #
12
- # # Rakefile
13
- # request_files = FileList.new("#{__dir__}/lib/ruby_lsp/requests/*.rb") do |fl|
14
- # fl.exclude(/base_request\.rb/)
15
- # end
16
- # gif_files = FileList.new("#{__dir__}/**/*.gif")
17
- # RubyLsp::CheckDocs.new(request_files, gif_files)
18
- # # Run with bundle exec rake ruby_lsp:check_docs
19
- class CheckDocs < Rake::TaskLib
20
- extend T::Sig
21
-
22
- sig { params(require_files: Rake::FileList, gif_files: Rake::FileList).void }
23
- def initialize(require_files, gif_files)
24
- super()
25
-
26
- @name = T.let("ruby_lsp:check_docs", String)
27
- @file_list = require_files
28
- @gif_list = gif_files
29
- define_task
30
- end
31
-
32
- private
33
-
34
- sig { void }
35
- def define_task
36
- desc("Checks if all Ruby LSP requests are documented")
37
- task(@name) { run_task }
38
- end
39
-
40
- sig { params(request_path: String).returns(T::Boolean) }
41
- def gif_exists?(request_path)
42
- request_gif = request_path.gsub(".rb", ".gif").split("/").last
43
-
44
- @gif_list.any? { |gif_path| gif_path.end_with?(request_gif) }
45
- end
46
-
47
- sig { void }
48
- def run_task
49
- # Require all files configured to make sure all requests are loaded
50
- @file_list.each { |f| require(f.delete_suffix(".rb")) }
51
-
52
- # Find all classes that inherit from BaseRequest, which are the ones we want to make sure are
53
- # documented
54
- features = ObjectSpace.each_object(Class).select do |k|
55
- klass = T.unsafe(k)
56
- klass < Requests::Request
57
- end
58
-
59
- missing_docs = T.let(Hash.new { |h, k| h[k] = [] }, T::Hash[String, T::Array[String]])
60
-
61
- features.each do |klass|
62
- class_name = T.unsafe(klass).name
63
- file_path, line_number = Module.const_source_location(class_name)
64
- next unless file_path && line_number
65
-
66
- # Adjust the line number to start searching right above the class definition
67
- line_number -= 2
68
-
69
- lines = File.readlines(file_path)
70
- docs = []
71
-
72
- # Extract the documentation on top of the request constant
73
- while (line = lines[line_number]&.strip) && line.start_with?("#")
74
- docs.unshift(line)
75
- line_number -= 1
76
- end
77
-
78
- documentation = docs.join("\n")
79
-
80
- if docs.empty?
81
- T.must(missing_docs[class_name]) << "No documentation found"
82
- elsif !%r{\(https://microsoft.github.io/language-server-protocol/specification#.*\)}.match?(documentation)
83
- T.must(missing_docs[class_name]) << <<~DOCS
84
- Missing specification link. Requests and addons should include a link to the LSP specification for the
85
- related feature. For example:
86
-
87
- [Inlay hint](https://microsoft.github.io/language-server-protocol/specification#textDocument_inlayHint)
88
- DOCS
89
- elsif !documentation.include?("# Example")
90
- T.must(missing_docs[class_name]) << <<~DOCS
91
- Missing example. Requests and addons should include a code example that explains what the feature does.
92
-
93
- # # Example
94
- # ```ruby
95
- # class Foo # <- information is shown here
96
- # end
97
- # ```
98
- DOCS
99
- elsif !/\[.* demo\]\(.*\.gif\)/.match?(documentation)
100
- T.must(missing_docs[class_name]) << <<~DOCS
101
- Missing demonstration GIF. Each request and addon must be documented with a GIF that shows the feature
102
- working. For example:
103
-
104
- # [Inlay hint demo](../../inlay_hint.gif)
105
- DOCS
106
- elsif !gif_exists?(file_path)
107
- T.must(missing_docs[class_name]) << <<~DOCS
108
- The GIF for the request documentation does not exist. Make sure to add it,
109
- with the same naming as the request. For example:
110
-
111
- # lib/ruby_lsp/requests/code_lens.rb
112
- # foo/bar/code_lens.gif
113
- DOCS
114
- end
115
- end
116
-
117
- if missing_docs.any?
118
- $stderr.puts(<<~WARN)
119
- The following requests are missing documentation:
120
-
121
- #{missing_docs.map { |k, v| "#{k}\n\n#{v.join("\n")}" }.join("\n\n")}
122
- WARN
123
-
124
- abort
125
- end
126
-
127
- puts "All requests are documented!"
128
- end
129
- end
130
- end