ruby-lsp 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/exe/ruby-lsp +2 -1
  4. data/exe/ruby-lsp-doctor +16 -0
  5. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +5 -1
  6. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +205 -0
  7. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +23 -106
  8. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +6 -6
  9. data/lib/ruby_indexer/lib/ruby_indexer/visitor.rb +101 -49
  10. data/lib/ruby_indexer/ruby_indexer.rb +1 -0
  11. data/lib/ruby_indexer/test/classes_and_modules_test.rb +49 -16
  12. data/lib/ruby_indexer/test/constant_test.rb +99 -36
  13. data/lib/ruby_indexer/test/index_test.rb +1 -1
  14. data/lib/ruby_indexer/test/method_test.rb +73 -0
  15. data/lib/ruby_indexer/test/test_case.rb +5 -1
  16. data/lib/ruby_lsp/addon.rb +8 -8
  17. data/lib/ruby_lsp/document.rb +14 -14
  18. data/lib/ruby_lsp/executor.rb +89 -53
  19. data/lib/ruby_lsp/internal.rb +7 -2
  20. data/lib/ruby_lsp/listener.rb +6 -6
  21. data/lib/ruby_lsp/requests/base_request.rb +1 -9
  22. data/lib/ruby_lsp/requests/code_action_resolve.rb +3 -3
  23. data/lib/ruby_lsp/requests/code_lens.rb +30 -30
  24. data/lib/ruby_lsp/requests/completion.rb +83 -32
  25. data/lib/ruby_lsp/requests/definition.rb +21 -15
  26. data/lib/ruby_lsp/requests/diagnostics.rb +1 -1
  27. data/lib/ruby_lsp/requests/document_highlight.rb +508 -31
  28. data/lib/ruby_lsp/requests/document_link.rb +24 -17
  29. data/lib/ruby_lsp/requests/document_symbol.rb +42 -42
  30. data/lib/ruby_lsp/requests/folding_ranges.rb +83 -77
  31. data/lib/ruby_lsp/requests/hover.rb +22 -17
  32. data/lib/ruby_lsp/requests/inlay_hints.rb +6 -6
  33. data/lib/ruby_lsp/requests/selection_ranges.rb +13 -105
  34. data/lib/ruby_lsp/requests/semantic_highlighting.rb +92 -92
  35. data/lib/ruby_lsp/requests/support/annotation.rb +3 -3
  36. data/lib/ruby_lsp/requests/support/common.rb +5 -5
  37. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +12 -0
  38. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +10 -7
  39. data/lib/ruby_lsp/requests/support/sorbet.rb +28 -28
  40. data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
  41. data/lib/ruby_lsp/requests.rb +0 -1
  42. data/lib/ruby_lsp/setup_bundler.rb +8 -5
  43. metadata +19 -17
  44. data/lib/ruby_lsp/event_emitter.rb +0 -351
  45. data/lib/ruby_lsp/requests/support/highlight_target.rb +0 -118
@@ -1,118 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module RubyLsp
5
- module Requests
6
- module Support
7
- class HighlightTarget
8
- extend T::Sig
9
-
10
- READ = Constant::DocumentHighlightKind::READ
11
- WRITE = Constant::DocumentHighlightKind::WRITE
12
-
13
- class HighlightMatch
14
- extend T::Sig
15
-
16
- sig { returns(Integer) }
17
- attr_reader :type
18
-
19
- sig { returns(YARP::Location) }
20
- attr_reader :location
21
-
22
- sig { params(type: Integer, location: YARP::Location).void }
23
- def initialize(type:, location:)
24
- @type = type
25
- @location = location
26
- end
27
- end
28
-
29
- sig { params(node: YARP::Node).void }
30
- def initialize(node)
31
- @node = node
32
- @value = T.let(value(node), T.nilable(String))
33
- end
34
-
35
- sig { params(other: YARP::Node).returns(T.nilable(HighlightMatch)) }
36
- def highlight_type(other)
37
- matched_highlight(other) if @value && @value == value(other)
38
- end
39
-
40
- private
41
-
42
- # Match the target type (where the cursor is positioned) with the `other` type (the node we're currently
43
- # visiting)
44
- sig { params(other: YARP::Node).returns(T.nilable(HighlightMatch)) }
45
- def matched_highlight(other)
46
- case @node
47
- # Method definitions and invocations
48
- when YARP::CallNode, YARP::DefNode
49
- case other
50
- when YARP::CallNode
51
- HighlightMatch.new(type: READ, location: other.location)
52
- when YARP::DefNode
53
- HighlightMatch.new(type: WRITE, location: other.name_loc)
54
- end
55
- # Variables, parameters and constants
56
- else
57
- case other
58
- when YARP::GlobalVariableTargetNode, YARP::InstanceVariableTargetNode, YARP::ConstantPathTargetNode,
59
- YARP::ConstantTargetNode, YARP::ClassVariableTargetNode, YARP::LocalVariableTargetNode,
60
- YARP::BlockParameterNode, YARP::RequiredParameterNode
61
-
62
- HighlightMatch.new(type: WRITE, location: other.location)
63
- when YARP::LocalVariableWriteNode, YARP::KeywordParameterNode, YARP::RestParameterNode,
64
- YARP::OptionalParameterNode, YARP::KeywordRestParameterNode, YARP::LocalVariableAndWriteNode,
65
- YARP::LocalVariableOperatorWriteNode, YARP::LocalVariableOrWriteNode, YARP::ClassVariableWriteNode,
66
- YARP::ClassVariableOrWriteNode, YARP::ClassVariableOperatorWriteNode, YARP::ClassVariableAndWriteNode,
67
- YARP::ConstantWriteNode, YARP::ConstantOrWriteNode, YARP::ConstantOperatorWriteNode,
68
- YARP::InstanceVariableWriteNode, YARP::ConstantAndWriteNode, YARP::InstanceVariableOrWriteNode,
69
- YARP::InstanceVariableAndWriteNode, YARP::InstanceVariableOperatorWriteNode,
70
- YARP::GlobalVariableWriteNode, YARP::GlobalVariableOrWriteNode, YARP::GlobalVariableAndWriteNode,
71
- YARP::GlobalVariableOperatorWriteNode
72
-
73
- HighlightMatch.new(type: WRITE, location: T.must(other.name_loc)) if other.name
74
- when YARP::ConstantPathWriteNode, YARP::ConstantPathOrWriteNode, YARP::ConstantPathAndWriteNode,
75
- YARP::ConstantPathOperatorWriteNode
76
-
77
- HighlightMatch.new(type: WRITE, location: other.target.location)
78
- when YARP::LocalVariableReadNode, YARP::ConstantPathNode, YARP::ConstantReadNode,
79
- YARP::InstanceVariableReadNode, YARP::ClassVariableReadNode, YARP::GlobalVariableReadNode
80
-
81
- HighlightMatch.new(type: READ, location: other.location)
82
- when YARP::ClassNode, YARP::ModuleNode
83
- HighlightMatch.new(type: WRITE, location: other.constant_path.location)
84
- end
85
- end
86
- end
87
-
88
- sig { params(node: YARP::Node).returns(T.nilable(String)) }
89
- def value(node)
90
- case node
91
- when YARP::ConstantReadNode, YARP::ConstantPathNode, YARP::BlockArgumentNode, YARP::ConstantTargetNode,
92
- YARP::ConstantPathWriteNode, YARP::ConstantPathTargetNode, YARP::ConstantPathOrWriteNode,
93
- YARP::ConstantPathOperatorWriteNode, YARP::ConstantPathAndWriteNode
94
- node.slice
95
- when YARP::GlobalVariableReadNode, YARP::GlobalVariableAndWriteNode, YARP::GlobalVariableOperatorWriteNode,
96
- YARP::GlobalVariableOrWriteNode, YARP::GlobalVariableTargetNode, YARP::GlobalVariableWriteNode,
97
- YARP::InstanceVariableAndWriteNode, YARP::InstanceVariableOperatorWriteNode,
98
- YARP::InstanceVariableOrWriteNode, YARP::InstanceVariableReadNode, YARP::InstanceVariableTargetNode,
99
- YARP::InstanceVariableWriteNode, YARP::ConstantAndWriteNode, YARP::ConstantOperatorWriteNode,
100
- YARP::ConstantOrWriteNode, YARP::ConstantWriteNode, YARP::ClassVariableAndWriteNode,
101
- YARP::ClassVariableOperatorWriteNode, YARP::ClassVariableOrWriteNode, YARP::ClassVariableReadNode,
102
- YARP::ClassVariableTargetNode, YARP::ClassVariableWriteNode, YARP::LocalVariableAndWriteNode,
103
- YARP::LocalVariableOperatorWriteNode, YARP::LocalVariableOrWriteNode, YARP::LocalVariableReadNode,
104
- YARP::LocalVariableTargetNode, YARP::LocalVariableWriteNode, YARP::DefNode, YARP::BlockParameterNode,
105
- YARP::KeywordParameterNode, YARP::KeywordRestParameterNode, YARP::OptionalParameterNode,
106
- YARP::RequiredParameterNode, YARP::RestParameterNode
107
-
108
- node.name.to_s
109
- when YARP::CallNode
110
- node.message
111
- when YARP::ClassNode, YARP::ModuleNode
112
- node.constant_path.slice
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end