ruby-lsp-rake 0.1.2 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce713fb8a5b8ecee3bd1780c8344ef38d985036e109a1cebcbdbf3bf52e7d7ea
4
- data.tar.gz: 183d590260d622db38fa372447d0c7e63aa236c1ddff07bc53d340e1d5498f86
3
+ metadata.gz: cf8328d935d374570d5da89ecdf66a791f731e5fefb9a10e2c8338c5f22b6fa3
4
+ data.tar.gz: 86cdb9a4c43c22a7027f284b8e32b0f18c62daa0b9bb8a7f2648b741a7cd0ae6
5
5
  SHA512:
6
- metadata.gz: 189fd8f28e3360e2202e00cec299e5244dd5c5d1c1f87eff15a26083722e6ac3ddfe39dc6d90af9482887320c24e5a45180b0e9c27d57b73e2c0edc1971d16c6
7
- data.tar.gz: 8b1246e01ec96c57d273b07206af6525a7fb2ba364a8577066a04e0cc0ca6991318f3b29c002976d44aadb766f0306465f3292c2cac92447a605d3a04777909c
6
+ metadata.gz: 3ea090a9fd5e15947adedc3a70c0baab2847e7857946a91cd25cac24dad3f295a0d637dee8bde10bfd58e4c1a67c9cfa2ddc8f1fdaddc749604651e2178824e4
7
+ data.tar.gz: 7196a513486c450f53877cca1de1980793aedaa34196f23527dbd999138d634e1ae79bafc82607cb0cc667caa7af228527d79597034653ecb1dca928e1a0ab20
data/Rakefile CHANGED
@@ -10,3 +10,10 @@ require "rubocop/rake_task"
10
10
  RuboCop::RakeTask.new
11
11
 
12
12
  task default: %i[test rubocop]
13
+
14
+ namespace :srb do
15
+ desc "Run sorbet type check"
16
+ task :tc do
17
+ sh "bundle exec srb tc"
18
+ end
19
+ end
Binary file
@@ -4,7 +4,7 @@
4
4
  module Ruby
5
5
  module Lsp
6
6
  module Rake
7
- VERSION = "0.1.2"
7
+ VERSION = "0.1.4"
8
8
  end
9
9
  end
10
10
  end
@@ -10,7 +10,7 @@ module RubyLsp
10
10
  class Addon < ::RubyLsp::Addon # rubocop:disable Style/Documentation
11
11
  def activate(global_state, _message_queue)
12
12
  @index = global_state.index
13
- @index.configuration.apply_config({ "included_patterns" => ["**/Rakefile"] })
13
+ @index.configuration.apply_config({ "included_patterns" => ["**/Rakefile", "lib/../Rakefile"] })
14
14
  end
15
15
 
16
16
  def deactivate; end
@@ -9,8 +9,7 @@ module RubyLsp
9
9
  def initialize(response_builder, node_context, dispatcher, index)
10
10
  @response_builder = response_builder
11
11
  @node_context = node_context
12
- dispatcher.register(self, :on_string_node_enter)
13
- dispatcher.register(self, :on_symbol_node_enter)
12
+ dispatcher.register(self, :on_string_node_enter, :on_symbol_node_enter)
14
13
  @index = index
15
14
  end
16
15
 
@@ -33,20 +32,51 @@ module RubyLsp
33
32
  node.value
34
33
  end
35
34
 
36
- task_name = "task_#{name}"
35
+ arg = @node_context.call_node.arguments&.arguments&.first
36
+ case arg
37
+ when Prism::KeywordHashNode
38
+ kh = arg.child_nodes.first
39
+ case kh
40
+ when Prism::AssocNode
41
+ v = kh.value
42
+ case v
43
+ when Prism::StringNode
44
+ return unless name == v.content
45
+ when Prism::SymbolNode
46
+ return unless name == v.value
47
+ when Prism::ArrayNode
48
+ return unless v.elements.find do |node|
49
+ name == case node
50
+ when Prism::StringNode
51
+ node.content
52
+ when Prism::SymbolNode
53
+ node.value
54
+ end
55
+ end
56
+ end
57
+ end
58
+ else
59
+ return
60
+ end
61
+
62
+ task_name = "task:#{name}"
37
63
  return unless @index.indexed? task_name
38
64
 
65
+ # refer to: https://github.com/Shopify/ruby-lsp/blob/896617a0c5f7a22ebe12912a481bf1b59db14c12/lib/ruby_lsp/requests/support/common.rb#L83
66
+ content = +""
39
67
  entries = @index[task_name]
40
- contents = entries.map do |entry|
41
- label = "task :#{name}"
68
+ links = entries.map do |entry|
42
69
  loc = entry.location
43
70
  uri = T.unsafe(URI::Generic).from_path(
44
71
  path: entry.file_path,
45
72
  fragment: "L#{loc.start_line},#{loc.start_column + 1}-#{loc.end_line},#{loc.end_column + 1}"
46
73
  )
47
- "[#{label}](#{uri})"
74
+ content << "\n\n#{entry.comments}" unless entry.comments.empty?
75
+ "[#{entry.file_name}](#{uri})"
48
76
  end
49
- @response_builder.push("Definitions: #{contents.join(", ")}", category: :documentation)
77
+ @response_builder.push("```\nrake #{name}\n```", category: :title)
78
+ @response_builder.push("Definitions: #{links.join(" | ")}", category: :links)
79
+ @response_builder.push(content, category: :documentation)
50
80
  end
51
81
  end
52
82
  end
@@ -4,9 +4,13 @@
4
4
  module RubyLsp
5
5
  module Rake
6
6
  class IndexingEnhancement < RubyIndexer::Enhancement # rubocop:disable Style/Documentation
7
+ @last_desc = nil
8
+
7
9
  def on_call_node_enter(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
10
+ @last_desc = nil unless node.name == :task
11
+
8
12
  return unless @listener.current_owner.nil?
9
- return unless node.name == :task
13
+ return unless node.name == :task || node.name == :desc
10
14
 
11
15
  arguments = node.arguments&.arguments
12
16
  return unless arguments
@@ -33,12 +37,20 @@ module RubyLsp
33
37
 
34
38
  return if name.nil?
35
39
 
40
+ if node.name == :desc
41
+ @last_desc = name
42
+ return
43
+ end
44
+
36
45
  location = node.location
37
46
  @listener.add_method(
38
- "task_#{name}",
47
+ "task:#{name}",
39
48
  location,
40
- []
49
+ [],
50
+ comments: @last_desc
41
51
  )
52
+
53
+ @last_desc = nil
42
54
  end
43
55
 
44
56
  def on_call_node_leave(node); 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.2
4
+ version: 0.1.4
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 00:00:00.000000000 Z
11
+ date: 2024-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-lsp