ruby-lsp 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/VERSION +1 -1
- data/lib/ruby_lsp/document.rb +51 -46
- data/lib/ruby_lsp/handler.rb +2 -2
- data/lib/ruby_lsp/requests/base_request.rb +44 -20
- data/lib/ruby_lsp/requests/code_actions.rb +2 -2
- data/lib/ruby_lsp/requests/diagnostics.rb +1 -8
- data/lib/ruby_lsp/requests/document_highlight.rb +14 -11
- data/lib/ruby_lsp/requests/document_link.rb +30 -26
- data/lib/ruby_lsp/requests/document_symbol.rb +43 -83
- data/lib/ruby_lsp/requests/folding_ranges.rb +58 -38
- data/lib/ruby_lsp/requests/formatting.rb +2 -0
- data/lib/ruby_lsp/requests/hover.rb +16 -7
- data/lib/ruby_lsp/requests/inlay_hints.rb +1 -1
- data/lib/ruby_lsp/requests/on_type_formatting.rb +19 -22
- data/lib/ruby_lsp/requests/selection_ranges.rb +40 -38
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +96 -73
- data/lib/ruby_lsp/requests/support/highlight_target.rb +8 -9
- data/lib/ruby_lsp/requests/support/rails_document_client.rb +13 -6
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +15 -10
- data/lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb +1 -1
- data/lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb +1 -1
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +9 -6
- data/lib/ruby_lsp/requests/support/source_uri.rb +10 -7
- data/lib/ruby_lsp/server.rb +19 -7
- data/lib/ruby_lsp/store.rb +5 -1
- metadata +6 -6
@@ -18,34 +18,38 @@ module RubyLsp
|
|
18
18
|
class FoldingRanges < BaseRequest
|
19
19
|
extend T::Sig
|
20
20
|
|
21
|
-
SIMPLE_FOLDABLES = T.let(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
21
|
+
SIMPLE_FOLDABLES = T.let(
|
22
|
+
[
|
23
|
+
SyntaxTree::ArrayLiteral,
|
24
|
+
SyntaxTree::BlockNode,
|
25
|
+
SyntaxTree::Case,
|
26
|
+
SyntaxTree::ClassDeclaration,
|
27
|
+
SyntaxTree::Command,
|
28
|
+
SyntaxTree::For,
|
29
|
+
SyntaxTree::HashLiteral,
|
30
|
+
SyntaxTree::Heredoc,
|
31
|
+
SyntaxTree::IfNode,
|
32
|
+
SyntaxTree::ModuleDeclaration,
|
33
|
+
SyntaxTree::SClass,
|
34
|
+
SyntaxTree::UnlessNode,
|
35
|
+
SyntaxTree::UntilNode,
|
36
|
+
SyntaxTree::WhileNode,
|
37
|
+
SyntaxTree::Else,
|
38
|
+
SyntaxTree::Ensure,
|
39
|
+
SyntaxTree::Begin,
|
40
|
+
].freeze,
|
41
|
+
T::Array[T.class_of(SyntaxTree::Node)],
|
42
|
+
)
|
43
|
+
|
44
|
+
NODES_WITH_STATEMENTS = T.let(
|
45
|
+
[
|
46
|
+
SyntaxTree::Elsif,
|
47
|
+
SyntaxTree::In,
|
48
|
+
SyntaxTree::Rescue,
|
49
|
+
SyntaxTree::When,
|
50
|
+
].freeze,
|
51
|
+
T::Array[T.class_of(SyntaxTree::Node)],
|
52
|
+
)
|
49
53
|
|
50
54
|
StatementNode = T.type_alias do
|
51
55
|
T.any(
|
@@ -86,10 +90,17 @@ module RubyLsp
|
|
86
90
|
add_lines_range(location.start_line, location.end_line - 1)
|
87
91
|
when *NODES_WITH_STATEMENTS
|
88
92
|
add_statements_range(T.must(node), T.cast(node, StatementNode).statements)
|
89
|
-
when SyntaxTree::
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
when SyntaxTree::CallNode, SyntaxTree::CommandCall
|
94
|
+
# If there is a receiver, it may be a chained invocation,
|
95
|
+
# so we need to process it in special way.
|
96
|
+
if node.receiver.nil?
|
97
|
+
location = node.location
|
98
|
+
add_lines_range(location.start_line, location.end_line - 1)
|
99
|
+
else
|
100
|
+
add_call_range(node)
|
101
|
+
return
|
102
|
+
end
|
103
|
+
when SyntaxTree::DefNode
|
93
104
|
add_def_range(node)
|
94
105
|
when SyntaxTree::StringConcat
|
95
106
|
add_string_concat(node)
|
@@ -192,19 +203,19 @@ module RubyLsp
|
|
192
203
|
@partial_range = nil
|
193
204
|
end
|
194
205
|
|
195
|
-
sig { params(node: T.any(SyntaxTree::
|
206
|
+
sig { params(node: T.any(SyntaxTree::CallNode, SyntaxTree::CommandCall)).void }
|
196
207
|
def add_call_range(node)
|
197
208
|
receiver = T.let(node.receiver, SyntaxTree::Node)
|
198
209
|
loop do
|
199
210
|
case receiver
|
200
|
-
when SyntaxTree::
|
211
|
+
when SyntaxTree::CallNode
|
201
212
|
visit(receiver.arguments)
|
202
213
|
receiver = receiver.receiver
|
203
214
|
when SyntaxTree::MethodAddBlock
|
204
215
|
visit(receiver.block)
|
205
216
|
receiver = receiver.call
|
206
217
|
|
207
|
-
if receiver.is_a?(SyntaxTree::
|
218
|
+
if receiver.is_a?(SyntaxTree::CallNode) || receiver.is_a?(SyntaxTree::CommandCall)
|
208
219
|
receiver = receiver.receiver
|
209
220
|
end
|
210
221
|
else
|
@@ -212,13 +223,17 @@ module RubyLsp
|
|
212
223
|
end
|
213
224
|
end
|
214
225
|
|
215
|
-
add_lines_range(receiver.location.start_line, node.location.end_line - 1)
|
226
|
+
add_lines_range(receiver.location.start_line, node.location.end_line - 1) if receiver
|
216
227
|
|
217
228
|
visit(node.arguments)
|
218
229
|
end
|
219
230
|
|
220
|
-
sig { params(node:
|
231
|
+
sig { params(node: SyntaxTree::DefNode).void }
|
221
232
|
def add_def_range(node)
|
233
|
+
# For an endless method with no arguments, `node.params` returns `nil` for Ruby 3.0, but a `Syntax::Params`
|
234
|
+
# for Ruby 3.1
|
235
|
+
return unless node.params
|
236
|
+
|
222
237
|
params_location = node.params.location
|
223
238
|
|
224
239
|
if params_location.start_line < params_location.end_line
|
@@ -228,7 +243,12 @@ module RubyLsp
|
|
228
243
|
add_lines_range(location.start_line, location.end_line - 1)
|
229
244
|
end
|
230
245
|
|
231
|
-
|
246
|
+
bodystmt = node.bodystmt
|
247
|
+
if bodystmt.is_a?(SyntaxTree::BodyStmt)
|
248
|
+
visit(bodystmt.statements)
|
249
|
+
else
|
250
|
+
visit(bodystmt)
|
251
|
+
end
|
232
252
|
end
|
233
253
|
|
234
254
|
sig { params(node: SyntaxTree::Node, statements: SyntaxTree::Statements).void }
|
@@ -11,6 +11,8 @@ module RubyLsp
|
|
11
11
|
# request uses RuboCop to fix auto-correctable offenses in the document. This requires enabling format on save and
|
12
12
|
# registering the ruby-lsp as the Ruby formatter.
|
13
13
|
#
|
14
|
+
# If RuboCop is not available, the request will fall back to SyntaxTree.
|
15
|
+
#
|
14
16
|
# # Example
|
15
17
|
#
|
16
18
|
# ```ruby
|
@@ -20,28 +20,37 @@ module RubyLsp
|
|
20
20
|
class Hover < BaseRequest
|
21
21
|
extend T::Sig
|
22
22
|
|
23
|
+
ALLOWED_TARGETS = T.let(
|
24
|
+
[
|
25
|
+
SyntaxTree::Command,
|
26
|
+
SyntaxTree::CallNode,
|
27
|
+
SyntaxTree::ConstPathRef,
|
28
|
+
],
|
29
|
+
T::Array[T.class_of(SyntaxTree::Node)],
|
30
|
+
)
|
31
|
+
|
23
32
|
sig { params(document: Document, position: Document::PositionShape).void }
|
24
33
|
def initialize(document, position)
|
25
34
|
super(document)
|
26
35
|
|
27
|
-
@position = T.let(
|
36
|
+
@position = T.let(document.create_scanner.find_char_position(position), Integer)
|
28
37
|
end
|
29
38
|
|
30
39
|
sig { override.returns(T.nilable(LanguageServer::Protocol::Interface::Hover)) }
|
31
40
|
def run
|
32
41
|
return unless @document.parsed?
|
33
42
|
|
34
|
-
target,
|
35
|
-
|
36
|
-
)
|
43
|
+
target, parent = locate(T.must(@document.tree), @position)
|
44
|
+
target = parent if !ALLOWED_TARGETS.include?(target.class) && ALLOWED_TARGETS.include?(parent.class)
|
37
45
|
|
38
46
|
case target
|
39
47
|
when SyntaxTree::Command
|
40
48
|
message = target.message
|
41
49
|
generate_rails_document_link_hover(message.value, message)
|
42
|
-
when SyntaxTree::
|
43
|
-
|
44
|
-
|
50
|
+
when SyntaxTree::CallNode
|
51
|
+
return if target.message == :call
|
52
|
+
|
53
|
+
generate_rails_document_link_hover(target.message.value, target.message)
|
45
54
|
when SyntaxTree::ConstPathRef
|
46
55
|
constant_name = full_constant_name(target)
|
47
56
|
generate_rails_document_link_hover(constant_name, target)
|
@@ -40,7 +40,7 @@ module RubyLsp
|
|
40
40
|
return unless node.exception.nil?
|
41
41
|
|
42
42
|
loc = node.location
|
43
|
-
return unless
|
43
|
+
return unless visible?(node, @range)
|
44
44
|
|
45
45
|
@hints << LanguageServer::Protocol::Interface::InlayHint.new(
|
46
46
|
position: { line: loc.start_line - 1, character: loc.start_column + RESCUE_STRING_LENGTH },
|
@@ -18,18 +18,21 @@ module RubyLsp
|
|
18
18
|
class OnTypeFormatting < BaseRequest
|
19
19
|
extend T::Sig
|
20
20
|
|
21
|
-
END_REGEXES = T.let(
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
END_REGEXES = T.let(
|
22
|
+
[
|
23
|
+
/(if|unless|for|while|class|module|until|def|case).*/,
|
24
|
+
/.*\sdo/,
|
25
|
+
],
|
26
|
+
T::Array[Regexp],
|
27
|
+
)
|
25
28
|
|
26
29
|
sig { params(document: Document, position: Document::PositionShape, trigger_character: String).void }
|
27
30
|
def initialize(document, position, trigger_character)
|
28
31
|
super(document)
|
29
32
|
|
30
|
-
scanner =
|
31
|
-
line_begin = position[:line] == 0 ? 0 : scanner.
|
32
|
-
line_end = scanner.
|
33
|
+
scanner = document.create_scanner
|
34
|
+
line_begin = position[:line] == 0 ? 0 : scanner.find_char_position({ line: position[:line] - 1, character: 0 })
|
35
|
+
line_end = scanner.find_char_position(position)
|
33
36
|
line = T.must(@document.source[line_begin..line_end])
|
34
37
|
|
35
38
|
@indentation = T.let(find_indentation(line), Integer)
|
@@ -41,17 +44,17 @@ module RubyLsp
|
|
41
44
|
|
42
45
|
sig { override.returns(T.nilable(T.all(T::Array[Interface::TextEdit], Object))) }
|
43
46
|
def run
|
44
|
-
handle_comment_line
|
45
|
-
|
46
|
-
return @edits unless @document.syntax_errors?
|
47
|
-
|
48
47
|
case @trigger_character
|
49
48
|
when "{"
|
50
|
-
handle_curly_brace
|
49
|
+
handle_curly_brace if @document.syntax_error?
|
51
50
|
when "|"
|
52
|
-
handle_pipe
|
51
|
+
handle_pipe if @document.syntax_error?
|
53
52
|
when "\n"
|
54
|
-
|
53
|
+
if (comment_match = @previous_line.match(/^#(\s*)/))
|
54
|
+
handle_comment_line(T.must(comment_match[1]))
|
55
|
+
elsif @document.syntax_error?
|
56
|
+
handle_statement_end
|
57
|
+
end
|
55
58
|
end
|
56
59
|
|
57
60
|
@edits
|
@@ -85,14 +88,8 @@ module RubyLsp
|
|
85
88
|
move_cursor_to(@position[:line], @indentation + 2)
|
86
89
|
end
|
87
90
|
|
88
|
-
sig { void }
|
89
|
-
def handle_comment_line
|
90
|
-
return unless @trigger_character == "\n"
|
91
|
-
|
92
|
-
is_comment_match = @previous_line.match(/^#(\s*)/)
|
93
|
-
return unless is_comment_match
|
94
|
-
|
95
|
-
spaces = T.must(is_comment_match[1])
|
91
|
+
sig { params(spaces: String).void }
|
92
|
+
def handle_comment_line(spaces)
|
96
93
|
add_edit_with_text("##{spaces}")
|
97
94
|
move_cursor_to(@position[:line], @indentation + spaces.size + 1)
|
98
95
|
end
|
@@ -11,6 +11,8 @@ module RubyLsp
|
|
11
11
|
#
|
12
12
|
# Trigger this request with: Ctrl + Shift + -> or Ctrl + Shift + <-
|
13
13
|
#
|
14
|
+
# Note that if using VSCode Neovim, you will need to be in Insert mode for this to work correctly.
|
15
|
+
#
|
14
16
|
# # Example
|
15
17
|
#
|
16
18
|
# ```ruby
|
@@ -21,44 +23,44 @@ module RubyLsp
|
|
21
23
|
class SelectionRanges < BaseRequest
|
22
24
|
extend T::Sig
|
23
25
|
|
24
|
-
NODES_THAT_CAN_BE_PARENTS = T.let(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
SyntaxTree::
|
61
|
-
|
26
|
+
NODES_THAT_CAN_BE_PARENTS = T.let(
|
27
|
+
[
|
28
|
+
SyntaxTree::Assign,
|
29
|
+
SyntaxTree::ArrayLiteral,
|
30
|
+
SyntaxTree::Begin,
|
31
|
+
SyntaxTree::BlockNode,
|
32
|
+
SyntaxTree::CallNode,
|
33
|
+
SyntaxTree::Case,
|
34
|
+
SyntaxTree::ClassDeclaration,
|
35
|
+
SyntaxTree::Command,
|
36
|
+
SyntaxTree::DefNode,
|
37
|
+
SyntaxTree::Elsif,
|
38
|
+
SyntaxTree::Else,
|
39
|
+
SyntaxTree::EmbDoc,
|
40
|
+
SyntaxTree::Ensure,
|
41
|
+
SyntaxTree::For,
|
42
|
+
SyntaxTree::HashLiteral,
|
43
|
+
SyntaxTree::Heredoc,
|
44
|
+
SyntaxTree::HeredocBeg,
|
45
|
+
SyntaxTree::HshPtn,
|
46
|
+
SyntaxTree::IfNode,
|
47
|
+
SyntaxTree::In,
|
48
|
+
SyntaxTree::Lambda,
|
49
|
+
SyntaxTree::MethodAddBlock,
|
50
|
+
SyntaxTree::ModuleDeclaration,
|
51
|
+
SyntaxTree::Params,
|
52
|
+
SyntaxTree::Rescue,
|
53
|
+
SyntaxTree::RescueEx,
|
54
|
+
SyntaxTree::StringConcat,
|
55
|
+
SyntaxTree::StringLiteral,
|
56
|
+
SyntaxTree::UnlessNode,
|
57
|
+
SyntaxTree::UntilNode,
|
58
|
+
SyntaxTree::VCall,
|
59
|
+
SyntaxTree::When,
|
60
|
+
SyntaxTree::WhileNode,
|
61
|
+
].freeze,
|
62
|
+
T::Array[T.class_of(SyntaxTree::Node)],
|
63
|
+
)
|
62
64
|
|
63
65
|
sig { params(document: Document).void }
|
64
66
|
def initialize(document)
|
@@ -22,52 +22,61 @@ module RubyLsp
|
|
22
22
|
extend T::Sig
|
23
23
|
include SyntaxTree::WithEnvironment
|
24
24
|
|
25
|
-
TOKEN_TYPES = T.let(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
25
|
+
TOKEN_TYPES = T.let(
|
26
|
+
{
|
27
|
+
namespace: 0,
|
28
|
+
type: 1,
|
29
|
+
class: 2,
|
30
|
+
enum: 3,
|
31
|
+
interface: 4,
|
32
|
+
struct: 5,
|
33
|
+
typeParameter: 6,
|
34
|
+
parameter: 7,
|
35
|
+
variable: 8,
|
36
|
+
property: 9,
|
37
|
+
enumMember: 10,
|
38
|
+
event: 11,
|
39
|
+
function: 12,
|
40
|
+
method: 13,
|
41
|
+
macro: 14,
|
42
|
+
keyword: 15,
|
43
|
+
modifier: 16,
|
44
|
+
comment: 17,
|
45
|
+
string: 18,
|
46
|
+
number: 19,
|
47
|
+
regexp: 20,
|
48
|
+
operator: 21,
|
49
|
+
decorator: 22,
|
50
|
+
}.freeze,
|
51
|
+
T::Hash[Symbol, Integer],
|
52
|
+
)
|
53
|
+
|
54
|
+
TOKEN_MODIFIERS = T.let(
|
55
|
+
{
|
56
|
+
declaration: 0,
|
57
|
+
definition: 1,
|
58
|
+
readonly: 2,
|
59
|
+
static: 3,
|
60
|
+
deprecated: 4,
|
61
|
+
abstract: 5,
|
62
|
+
async: 6,
|
63
|
+
modification: 7,
|
64
|
+
documentation: 8,
|
65
|
+
default_library: 9,
|
66
|
+
}.freeze,
|
67
|
+
T::Hash[Symbol, Integer],
|
68
|
+
)
|
69
|
+
|
70
|
+
SPECIAL_RUBY_METHODS = T.let(
|
71
|
+
[
|
72
|
+
Module.instance_methods(false),
|
73
|
+
Kernel.instance_methods(false),
|
74
|
+
Kernel.methods(false),
|
75
|
+
Bundler::Dsl.instance_methods(false),
|
76
|
+
Module.private_instance_methods(false),
|
77
|
+
].flatten.map(&:to_s),
|
78
|
+
T::Array[String],
|
79
|
+
)
|
71
80
|
|
72
81
|
class SemanticToken < T::Struct
|
73
82
|
const :location, SyntaxTree::Location
|
@@ -76,13 +85,20 @@ module RubyLsp
|
|
76
85
|
const :modifier, T::Array[Integer]
|
77
86
|
end
|
78
87
|
|
79
|
-
sig
|
80
|
-
|
88
|
+
sig do
|
89
|
+
params(
|
90
|
+
document: Document,
|
91
|
+
range: T.nilable(T::Range[Integer]),
|
92
|
+
encoder: T.nilable(Support::SemanticTokenEncoder),
|
93
|
+
).void
|
94
|
+
end
|
95
|
+
def initialize(document, range: nil, encoder: nil)
|
81
96
|
super(document)
|
82
97
|
|
83
98
|
@encoder = encoder
|
84
99
|
@tokens = T.let([], T::Array[SemanticToken])
|
85
100
|
@tree = T.let(T.must(document.tree), SyntaxTree::Node)
|
101
|
+
@range = range
|
86
102
|
@special_methods = T.let(nil, T.nilable(T::Array[String]))
|
87
103
|
end
|
88
104
|
|
@@ -103,24 +119,32 @@ module RubyLsp
|
|
103
119
|
@encoder.encode(@tokens)
|
104
120
|
end
|
105
121
|
|
106
|
-
sig { override.params(node: SyntaxTree::
|
122
|
+
sig { override.params(node: SyntaxTree::CallNode).void }
|
107
123
|
def visit_call(node)
|
124
|
+
return super unless visible?(node, @range)
|
125
|
+
|
108
126
|
visit(node.receiver)
|
109
127
|
|
110
128
|
message = node.message
|
111
|
-
|
129
|
+
unless message == :call || special_method?(message.value)
|
130
|
+
add_token(message.location, :method)
|
131
|
+
end
|
112
132
|
|
113
133
|
visit(node.arguments)
|
114
134
|
end
|
115
135
|
|
116
136
|
sig { override.params(node: SyntaxTree::Command).void }
|
117
137
|
def visit_command(node)
|
138
|
+
return super unless visible?(node, @range)
|
139
|
+
|
118
140
|
add_token(node.message.location, :method) unless special_method?(node.message.value)
|
119
141
|
visit(node.arguments)
|
120
142
|
end
|
121
143
|
|
122
144
|
sig { override.params(node: SyntaxTree::CommandCall).void }
|
123
145
|
def visit_command_call(node)
|
146
|
+
return super unless visible?(node, @range)
|
147
|
+
|
124
148
|
visit(node.receiver)
|
125
149
|
add_token(node.message.location, :method)
|
126
150
|
visit(node.arguments)
|
@@ -128,41 +152,26 @@ module RubyLsp
|
|
128
152
|
|
129
153
|
sig { override.params(node: SyntaxTree::Const).void }
|
130
154
|
def visit_const(node)
|
155
|
+
return super unless visible?(node, @range)
|
156
|
+
|
131
157
|
add_token(node.location, :namespace)
|
132
158
|
end
|
133
159
|
|
134
|
-
sig { override.params(node: SyntaxTree::
|
160
|
+
sig { override.params(node: SyntaxTree::DefNode).void }
|
135
161
|
def visit_def(node)
|
136
|
-
|
137
|
-
visit(node.params)
|
138
|
-
visit(node.bodystmt)
|
139
|
-
end
|
140
|
-
|
141
|
-
sig { override.params(node: SyntaxTree::DefEndless).void }
|
142
|
-
def visit_def_endless(node)
|
143
|
-
add_token(node.name.location, :method, [:declaration])
|
144
|
-
visit(node.paren)
|
145
|
-
visit(node.operator)
|
146
|
-
visit(node.statement)
|
147
|
-
end
|
162
|
+
return super unless visible?(node, @range)
|
148
163
|
|
149
|
-
sig { override.params(node: SyntaxTree::Defs).void }
|
150
|
-
def visit_defs(node)
|
151
|
-
visit(node.target)
|
152
|
-
visit(node.operator)
|
153
164
|
add_token(node.name.location, :method, [:declaration])
|
154
165
|
visit(node.params)
|
155
166
|
visit(node.bodystmt)
|
156
|
-
|
157
|
-
|
158
|
-
sig { override.params(node: SyntaxTree::FCall).void }
|
159
|
-
def visit_fcall(node)
|
160
|
-
add_token(node.value.location, :method) unless special_method?(node.value.value)
|
161
|
-
visit(node.arguments)
|
167
|
+
visit(node.target) if node.target
|
168
|
+
visit(node.operator) if node.operator
|
162
169
|
end
|
163
170
|
|
164
171
|
sig { override.params(node: SyntaxTree::Kw).void }
|
165
172
|
def visit_kw(node)
|
173
|
+
return super unless visible?(node, @range)
|
174
|
+
|
166
175
|
case node.value
|
167
176
|
when "self"
|
168
177
|
add_token(node.location, :variable, [:default_library])
|
@@ -171,6 +180,8 @@ module RubyLsp
|
|
171
180
|
|
172
181
|
sig { override.params(node: SyntaxTree::Params).void }
|
173
182
|
def visit_params(node)
|
183
|
+
return super unless visible?(node, @range)
|
184
|
+
|
174
185
|
node.keywords.each do |keyword,|
|
175
186
|
location = keyword.location
|
176
187
|
add_token(location_without_colon(location), :parameter)
|
@@ -191,6 +202,8 @@ module RubyLsp
|
|
191
202
|
|
192
203
|
sig { override.params(node: SyntaxTree::Field).void }
|
193
204
|
def visit_field(node)
|
205
|
+
return super unless visible?(node, @range)
|
206
|
+
|
194
207
|
add_token(node.name.location, :method)
|
195
208
|
|
196
209
|
super
|
@@ -198,6 +211,8 @@ module RubyLsp
|
|
198
211
|
|
199
212
|
sig { override.params(node: SyntaxTree::VarField).void }
|
200
213
|
def visit_var_field(node)
|
214
|
+
return super unless visible?(node, @range)
|
215
|
+
|
201
216
|
value = node.value
|
202
217
|
|
203
218
|
case value
|
@@ -211,6 +226,8 @@ module RubyLsp
|
|
211
226
|
|
212
227
|
sig { override.params(node: SyntaxTree::VarRef).void }
|
213
228
|
def visit_var_ref(node)
|
229
|
+
return super unless visible?(node, @range)
|
230
|
+
|
214
231
|
value = node.value
|
215
232
|
|
216
233
|
case value
|
@@ -224,11 +241,15 @@ module RubyLsp
|
|
224
241
|
|
225
242
|
sig { override.params(node: SyntaxTree::VCall).void }
|
226
243
|
def visit_vcall(node)
|
244
|
+
return super unless visible?(node, @range)
|
245
|
+
|
227
246
|
add_token(node.value.location, :method) unless special_method?(node.value.value)
|
228
247
|
end
|
229
248
|
|
230
249
|
sig { override.params(node: SyntaxTree::ClassDeclaration).void }
|
231
250
|
def visit_class(node)
|
251
|
+
return super unless visible?(node, @range)
|
252
|
+
|
232
253
|
add_token(node.constant.location, :class, [:declaration])
|
233
254
|
add_token(node.superclass.location, :class) if node.superclass
|
234
255
|
visit(node.bodystmt)
|
@@ -236,6 +257,8 @@ module RubyLsp
|
|
236
257
|
|
237
258
|
sig { override.params(node: SyntaxTree::ModuleDeclaration).void }
|
238
259
|
def visit_module(node)
|
260
|
+
return super unless visible?(node, @range)
|
261
|
+
|
239
262
|
add_token(node.constant.location, :class, [:declaration])
|
240
263
|
visit(node.bodystmt)
|
241
264
|
end
|