ruby-lsp-rake 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +22 -0
- data/lib/ruby/lsp/rake/version.rb +1 -1
- data/lib/ruby_lsp/ruby_lsp_rake/addon.rb +14 -1
- data/lib/ruby_lsp/ruby_lsp_rake/hover.rb +15 -3
- data/lib/ruby_lsp/ruby_lsp_rake/indexing_enhancement.rb +31 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cdf5ce3b286b6f1824bcff07f386aff744fee063debf045a33f0a104ccb9a58
|
4
|
+
data.tar.gz: 0f61d107e42ac8412f3f4ac53425c6d8dc0e4c90e11bcab050ee8a1aaa80719c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44d24d9356c0893323402638a91d564562c66728233445901c32c0502aa6fbfa95ff5ed1cf6b6f94d80031e4f180a2b2b578e96080dd68f9c9c53f14e5b02358
|
7
|
+
data.tar.gz: 98bb06c07335e47d6064101ed3761299215b3f25a5c090006931a257a74e3eb1ba4f5fbf7ad7f916779cafaf49b786fc266756abe14666de1a4140c16a9397f2
|
data/Rakefile
CHANGED
@@ -17,3 +17,25 @@ namespace :srb do
|
|
17
17
|
sh "bundle exec srb tc"
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
task aaa: %i[bbb ccc:ddd eee:fff]
|
22
|
+
|
23
|
+
task :bbb do
|
24
|
+
puts :bbb
|
25
|
+
end
|
26
|
+
|
27
|
+
namespace :ccc do
|
28
|
+
task ddd: :eee do
|
29
|
+
puts "ccc:ddd"
|
30
|
+
end
|
31
|
+
|
32
|
+
task :eee do
|
33
|
+
puts "ccc:eee"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace :eee do
|
38
|
+
task :fff do
|
39
|
+
puts "eee:fff"
|
40
|
+
end
|
41
|
+
end
|
@@ -8,21 +8,34 @@ require_relative "hover"
|
|
8
8
|
module RubyLsp
|
9
9
|
module Rake
|
10
10
|
class Addon < ::RubyLsp::Addon # rubocop:disable Style/Documentation
|
11
|
-
|
11
|
+
extend T::Sig
|
12
|
+
|
13
|
+
sig { override.params(global_state: GlobalState, outgoing_queue: Thread::Queue).void }
|
14
|
+
def activate(global_state, outgoing_queue) # rubocop:disable Lint/UnusedMethodArgument
|
12
15
|
@index = global_state.index
|
13
16
|
@index.configuration.apply_config({ "included_patterns" => ["**/Rakefile", "lib/../Rakefile"] })
|
14
17
|
end
|
15
18
|
|
19
|
+
sig { override.void }
|
16
20
|
def deactivate; end
|
17
21
|
|
22
|
+
sig { override.returns(String) }
|
18
23
|
def name
|
19
24
|
"A Ruby LSP addon that adds extra editor functionality for Rake"
|
20
25
|
end
|
21
26
|
|
27
|
+
sig { override.returns(String) }
|
22
28
|
def version
|
23
29
|
::Ruby::Lsp::Rake::VERSION
|
24
30
|
end
|
25
31
|
|
32
|
+
sig do
|
33
|
+
override.params(
|
34
|
+
response_builder: ResponseBuilders::Hover,
|
35
|
+
node_context: NodeContext,
|
36
|
+
dispatcher: Prism::Dispatcher
|
37
|
+
).void
|
38
|
+
end
|
26
39
|
def create_hover_listener(response_builder, node_context, dispatcher)
|
27
40
|
Hover.new(response_builder, node_context, dispatcher, @index)
|
28
41
|
end
|
@@ -4,8 +4,17 @@
|
|
4
4
|
module RubyLsp
|
5
5
|
module Rake
|
6
6
|
class Hover # rubocop:disable Style/Documentation
|
7
|
+
extend T::Sig
|
7
8
|
include Requests::Support::Common
|
8
9
|
|
10
|
+
sig do
|
11
|
+
override.params(
|
12
|
+
response_builder: ResponseBuilders::Hover,
|
13
|
+
node_context: NodeContext,
|
14
|
+
dispatcher: Prism::Dispatcher,
|
15
|
+
index: RubyIndexer::Index
|
16
|
+
).void
|
17
|
+
end
|
9
18
|
def initialize(response_builder, node_context, dispatcher, index)
|
10
19
|
@response_builder = response_builder
|
11
20
|
@node_context = node_context
|
@@ -13,14 +22,17 @@ module RubyLsp
|
|
13
22
|
@index = index
|
14
23
|
end
|
15
24
|
|
25
|
+
sig { params(node: Prism::StringNode).void }
|
16
26
|
def on_string_node_enter(node)
|
17
27
|
handle_prerequisite(node)
|
18
28
|
end
|
19
29
|
|
30
|
+
sig { params(node: Prism::SymbolNode).void }
|
20
31
|
def on_symbol_node_enter(node)
|
21
32
|
handle_prerequisite(node)
|
22
33
|
end
|
23
34
|
|
35
|
+
sig { params(node: T.any(Prism::StringNode, Prism::SymbolNode)).void }
|
24
36
|
def handle_prerequisite(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
25
37
|
call_node_name = @node_context.call_node&.name
|
26
38
|
return unless call_node_name == :task
|
@@ -32,7 +44,7 @@ module RubyLsp
|
|
32
44
|
node.value
|
33
45
|
end
|
34
46
|
|
35
|
-
arg = @node_context.call_node
|
47
|
+
arg = @node_context.call_node&.arguments&.arguments&.first
|
36
48
|
case arg
|
37
49
|
when Prism::KeywordHashNode
|
38
50
|
kh = arg.child_nodes.first
|
@@ -65,7 +77,7 @@ module RubyLsp
|
|
65
77
|
# refer to: https://github.com/Shopify/ruby-lsp/blob/896617a0c5f7a22ebe12912a481bf1b59db14c12/lib/ruby_lsp/requests/support/common.rb#L83
|
66
78
|
content = +""
|
67
79
|
entries = @index[task_name]
|
68
|
-
links = entries
|
80
|
+
links = entries&.map do |entry|
|
69
81
|
loc = entry.location
|
70
82
|
uri = T.unsafe(URI::Generic).from_path(
|
71
83
|
path: entry.file_path,
|
@@ -75,7 +87,7 @@ module RubyLsp
|
|
75
87
|
"[#{entry.file_name}](#{uri})"
|
76
88
|
end
|
77
89
|
@response_builder.push("```\nrake #{name}\n```", category: :title)
|
78
|
-
@response_builder.push("Definitions: #{links
|
90
|
+
@response_builder.push("Definitions: #{links&.join(" | ")}", category: :links)
|
79
91
|
@response_builder.push(content, category: :documentation)
|
80
92
|
end
|
81
93
|
end
|
@@ -4,13 +4,21 @@
|
|
4
4
|
module RubyLsp
|
5
5
|
module Rake
|
6
6
|
class IndexingEnhancement < RubyIndexer::Enhancement # rubocop:disable Style/Documentation
|
7
|
-
|
7
|
+
extend T::Sig
|
8
8
|
|
9
|
+
sig { params(listener: RubyIndexer::DeclarationListener).void }
|
10
|
+
def initialize(listener)
|
11
|
+
super(listener)
|
12
|
+
@namespace_stack = []
|
13
|
+
@last_desc = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
sig { override.params(node: Prism::CallNode).void }
|
9
17
|
def on_call_node_enter(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
10
18
|
@last_desc = nil unless node.name == :task
|
11
19
|
|
12
20
|
return unless @listener.current_owner.nil?
|
13
|
-
return unless node.name == :task || node.name == :desc
|
21
|
+
return unless node.name == :task || node.name == :desc || node.name == :namespace
|
14
22
|
|
15
23
|
arguments = node.arguments&.arguments
|
16
24
|
return unless arguments
|
@@ -37,23 +45,36 @@ module RubyLsp
|
|
37
45
|
|
38
46
|
return if name.nil?
|
39
47
|
|
48
|
+
if node.name == :namespace
|
49
|
+
@namespace_stack << name
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
40
53
|
if node.name == :desc
|
41
54
|
@last_desc = name
|
42
55
|
return
|
43
56
|
end
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
58
|
+
ary = [*@namespace_stack, name]
|
59
|
+
(1..(ary.size)).each do |i|
|
60
|
+
@listener.add_method(
|
61
|
+
"task:#{ary[-i..].join(":")}",
|
62
|
+
node.location,
|
63
|
+
[],
|
64
|
+
comments: @last_desc
|
65
|
+
)
|
66
|
+
end
|
52
67
|
|
53
68
|
@last_desc = nil
|
54
69
|
end
|
55
70
|
|
56
|
-
|
71
|
+
sig { override.params(node: Prism::CallNode).void }
|
72
|
+
def on_call_node_leave(node)
|
73
|
+
return unless @listener.current_owner.nil?
|
74
|
+
return unless node.name == :namespace
|
75
|
+
|
76
|
+
@namespace_stack.pop
|
77
|
+
end
|
57
78
|
end
|
58
79
|
end
|
59
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koji NAKAMURA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-lsp
|