ruby-lsp-rspec 0.1.13 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79c44a257a6397dd3c0fc255c4bcc32b8766d1430f6c5f3e8fb31349615b549a
|
4
|
+
data.tar.gz: 31f87a129243a71c60759e239a7e48b0333dfdb85da5e48b34c6dfa48fea53d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ab1b4fb860e5cc8793b46e6c18d5dd819f97288530ad8ed37f6fc975e3ad3e8ac36e25a77ce7665f85a805a3926f4adf9e8a352d8112f68d958588d50cbb3b8
|
7
|
+
data.tar.gz: ddb9bd8072cff3153d2db93af3bef525127b4c4a1dff871dd75dd4265e7959c1c8f944e9b81084c0d99dd2ddd406cfdeabd33f3663d548472413822725a4cf79
|
@@ -6,6 +6,8 @@ require "ruby_lsp/internal"
|
|
6
6
|
|
7
7
|
require_relative "code_lens"
|
8
8
|
require_relative "document_symbol"
|
9
|
+
require_relative "definition"
|
10
|
+
require_relative "indexing_enhancement"
|
9
11
|
|
10
12
|
module RubyLsp
|
11
13
|
module RSpec
|
@@ -13,11 +15,19 @@ module RubyLsp
|
|
13
15
|
extend T::Sig
|
14
16
|
|
15
17
|
sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
|
16
|
-
def activate(global_state, message_queue)
|
18
|
+
def activate(global_state, message_queue)
|
19
|
+
@index = T.let(global_state.index, T.nilable(RubyIndexer::Index))
|
20
|
+
global_state.index.register_enhancement(IndexingEnhancement.new)
|
21
|
+
end
|
17
22
|
|
18
23
|
sig { override.void }
|
19
24
|
def deactivate; end
|
20
25
|
|
26
|
+
sig { override.returns(String) }
|
27
|
+
def version
|
28
|
+
VERSION
|
29
|
+
end
|
30
|
+
|
21
31
|
# Creates a new CodeLens listener. This method is invoked on every CodeLens request
|
22
32
|
sig do
|
23
33
|
override.params(
|
@@ -42,6 +52,21 @@ module RubyLsp
|
|
42
52
|
DocumentSymbol.new(response_builder, dispatcher)
|
43
53
|
end
|
44
54
|
|
55
|
+
sig do
|
56
|
+
override.params(
|
57
|
+
response_builder: ResponseBuilders::CollectionResponseBuilder[T.any(
|
58
|
+
Interface::Location,
|
59
|
+
Interface::LocationLink,
|
60
|
+
)],
|
61
|
+
uri: URI::Generic,
|
62
|
+
node_context: NodeContext,
|
63
|
+
dispatcher: Prism::Dispatcher,
|
64
|
+
).void
|
65
|
+
end
|
66
|
+
def create_definition_listener(response_builder, uri, node_context, dispatcher)
|
67
|
+
Definition.new(response_builder, uri, node_context, T.must(@index), dispatcher)
|
68
|
+
end
|
69
|
+
|
45
70
|
sig { override.returns(String) }
|
46
71
|
def name
|
47
72
|
"Ruby LSP RSpec"
|
@@ -21,6 +21,7 @@ module RubyLsp
|
|
21
21
|
@path = T.let(T.must(uri.to_standardized_path), String)
|
22
22
|
@group_id = T.let(1, Integer)
|
23
23
|
@group_id_stack = T.let([], T::Array[Integer])
|
24
|
+
@anonymous_example_count = T.let(0, Integer)
|
24
25
|
dispatcher.register(self, :on_call_node_enter, :on_call_node_leave)
|
25
26
|
|
26
27
|
@base_command = T.let(
|
@@ -93,7 +94,8 @@ module RubyLsp
|
|
93
94
|
argument.slice
|
94
95
|
end
|
95
96
|
else
|
96
|
-
|
97
|
+
@anonymous_example_count += 1
|
98
|
+
"<unnamed-#{@anonymous_example_count}>"
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RubyLsp
|
5
|
+
module RSpec
|
6
|
+
class Definition
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
include ::RubyLsp::Requests::Support::Common
|
10
|
+
|
11
|
+
sig do
|
12
|
+
params(
|
13
|
+
response_builder: ResponseBuilders::CollectionResponseBuilder[T.any(
|
14
|
+
Interface::Location,
|
15
|
+
Interface::LocationLink,
|
16
|
+
)],
|
17
|
+
uri: URI::Generic,
|
18
|
+
node_context: NodeContext,
|
19
|
+
index: RubyIndexer::Index,
|
20
|
+
dispatcher: Prism::Dispatcher,
|
21
|
+
).void
|
22
|
+
end
|
23
|
+
def initialize(response_builder, uri, node_context, index, dispatcher)
|
24
|
+
@response_builder = response_builder
|
25
|
+
@uri = uri
|
26
|
+
@node_context = node_context
|
27
|
+
@index = index
|
28
|
+
dispatcher.register(self, :on_call_node_enter)
|
29
|
+
end
|
30
|
+
|
31
|
+
sig { params(node: Prism::CallNode).void }
|
32
|
+
def on_call_node_enter(node)
|
33
|
+
message = node.message
|
34
|
+
return unless message
|
35
|
+
|
36
|
+
return if @node_context.locals_for_scope.include?(message)
|
37
|
+
|
38
|
+
entries = @index[message]
|
39
|
+
return unless entries
|
40
|
+
return if entries.empty?
|
41
|
+
|
42
|
+
entries.each do |entry|
|
43
|
+
# Technically, let can be defined in a different file, but we're not going to handle that case yet
|
44
|
+
next unless entry.file_path == @uri.to_standardized_path
|
45
|
+
|
46
|
+
@response_builder << Interface::LocationLink.new(
|
47
|
+
target_uri: URI::Generic.from_path(path: entry.file_path).to_s,
|
48
|
+
target_range: range_from_location(entry.location),
|
49
|
+
target_selection_range: range_from_location(entry.name_location),
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RubyLsp
|
5
|
+
module RSpec
|
6
|
+
class IndexingEnhancement
|
7
|
+
extend T::Sig
|
8
|
+
include RubyIndexer::Enhancement
|
9
|
+
|
10
|
+
sig do
|
11
|
+
override.params(
|
12
|
+
index: RubyIndexer::Index,
|
13
|
+
owner: T.nilable(RubyIndexer::Entry::Namespace),
|
14
|
+
node: Prism::CallNode,
|
15
|
+
file_path: String,
|
16
|
+
).void
|
17
|
+
end
|
18
|
+
def on_call_node(index, owner, node, file_path)
|
19
|
+
return if node.receiver
|
20
|
+
|
21
|
+
name = node.name
|
22
|
+
|
23
|
+
case name
|
24
|
+
when :let, :let!
|
25
|
+
block_node = node.block
|
26
|
+
return unless block_node
|
27
|
+
|
28
|
+
arguments = node.arguments
|
29
|
+
return unless arguments
|
30
|
+
|
31
|
+
return if arguments.arguments.count != 1
|
32
|
+
|
33
|
+
method_name_node = T.must(arguments.arguments.first)
|
34
|
+
|
35
|
+
method_name = case method_name_node
|
36
|
+
when Prism::StringNode
|
37
|
+
method_name_node.slice
|
38
|
+
when Prism::SymbolNode
|
39
|
+
method_name_node.unescaped
|
40
|
+
end
|
41
|
+
|
42
|
+
return unless method_name
|
43
|
+
|
44
|
+
index.add(RubyIndexer::Entry::Method.new(
|
45
|
+
method_name,
|
46
|
+
file_path,
|
47
|
+
block_node.location,
|
48
|
+
block_node.location,
|
49
|
+
nil,
|
50
|
+
index.configuration.encoding,
|
51
|
+
[RubyIndexer::Entry::Signature.new([])],
|
52
|
+
RubyIndexer::Entry::Visibility::PUBLIC,
|
53
|
+
owner,
|
54
|
+
))
|
55
|
+
when :subject, :subject!
|
56
|
+
block_node = node.block
|
57
|
+
return unless block_node
|
58
|
+
|
59
|
+
arguments = node.arguments
|
60
|
+
|
61
|
+
if arguments && arguments.arguments.count == 1
|
62
|
+
method_name_node = T.must(arguments.arguments.first)
|
63
|
+
end
|
64
|
+
|
65
|
+
method_name = if method_name_node
|
66
|
+
case method_name_node
|
67
|
+
when Prism::StringNode
|
68
|
+
method_name_node.slice
|
69
|
+
when Prism::SymbolNode
|
70
|
+
method_name_node.unescaped
|
71
|
+
end
|
72
|
+
else
|
73
|
+
"subject"
|
74
|
+
end
|
75
|
+
|
76
|
+
return unless method_name
|
77
|
+
|
78
|
+
index.add(RubyIndexer::Entry::Method.new(
|
79
|
+
method_name,
|
80
|
+
file_path,
|
81
|
+
block_node.location,
|
82
|
+
block_node.location,
|
83
|
+
nil,
|
84
|
+
index.configuration.encoding,
|
85
|
+
[RubyIndexer::Entry::Signature.new([])],
|
86
|
+
RubyIndexer::Entry::Visibility::PUBLIC,
|
87
|
+
owner,
|
88
|
+
))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Lo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-lsp
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.19.0
|
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.
|
26
|
+
version: 0.19.0
|
27
27
|
description: RSpec addon for ruby-lsp
|
28
28
|
email:
|
29
29
|
- stan001212@gmail.com
|
@@ -41,7 +41,9 @@ files:
|
|
41
41
|
- lib/ruby-lsp-rspec.rb
|
42
42
|
- lib/ruby_lsp/ruby_lsp_rspec/addon.rb
|
43
43
|
- lib/ruby_lsp/ruby_lsp_rspec/code_lens.rb
|
44
|
+
- lib/ruby_lsp/ruby_lsp_rspec/definition.rb
|
44
45
|
- lib/ruby_lsp/ruby_lsp_rspec/document_symbol.rb
|
46
|
+
- lib/ruby_lsp/ruby_lsp_rspec/indexing_enhancement.rb
|
45
47
|
- lib/ruby_lsp_rspec/version.rb
|
46
48
|
homepage: https://github.com/st0012/ruby-lsp-rspec
|
47
49
|
licenses:
|