ruby-lsp-rake 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +12 -0
- data/img/dependency_task_links_on_hover.png +0 -0
- data/lib/Rakefile +9 -0
- data/lib/ruby/lsp/rake/version.rb +9 -0
- data/lib/ruby/lsp/rake.rb +12 -0
- data/lib/ruby_lsp/ruby_lsp_rake/addon.rb +29 -0
- data/lib/ruby_lsp/ruby_lsp_rake/hover.rb +43 -0
- data/lib/ruby_lsp/ruby_lsp_rake/indexing_enhancement.rb +44 -0
- data/sig/ruby/lsp/rake.rbs +8 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d62c520f6161c9188a81725ba3d7a0344b79ac6616e8f5067cb3c6bf53005f8
|
4
|
+
data.tar.gz: 4e2d992c8cfe1707c989ecce92c766bed76b5a225897e92a0d1d24c3145446dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 04d0ee7602ec8ce503c8ebb9a5fb439efdc8825038a339eed233121e4df7bf232a5ae168bd5e3e4af5a566c7fde27de83fd2accf7ecf841a58b4b4d8a2ad366c
|
7
|
+
data.tar.gz: c39ce4f0873a88375151e0e99559e65914fd4c168dd347691aabffb7778c3bf23743347a6802cc1e02056635866c22f4424a6609c0c961b176fe6b618ca41d74
|
data/.rubocop.yml
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Koji NAKAMURA
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# ruby-lsp-rake
|
2
|
+
|
3
|
+
A Ruby LSP addon that adds extra editor functionality for Rake.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
If you haven't already done so, you'll need to first [set up Ruby LSP](https://shopify.github.io/ruby-lsp/#usage).
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
bundle add ruby-lsp-rake --group development
|
13
|
+
```
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
gem install ruby-lsp-rake
|
19
|
+
```
|
20
|
+
|
21
|
+
## Indexing Configuration
|
22
|
+
|
23
|
+
To index tasks defined in `Rakefile` files, configure `rubyLsp.indexing.includedPatterns` as shown below.
|
24
|
+
|
25
|
+
```
|
26
|
+
{
|
27
|
+
"rubyLsp.indexing": {
|
28
|
+
"includedPatterns": ["**/Rakefile"]
|
29
|
+
}
|
30
|
+
}
|
31
|
+
```
|
32
|
+
|
33
|
+
see also: https://shopify.github.io/ruby-lsp/#configuring-code-indexing
|
34
|
+
|
35
|
+
## Features
|
36
|
+
|
37
|
+
### Dependency task links on hover
|
38
|
+
|
39
|
+
Add a link to the location where the dependency task is defined to the hover content.
|
40
|
+
|
41
|
+
![depenency_task_links_on_hover](img/dependency_task_links_on_hover.png)
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kozy4324/ruby-lsp-rake.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
Binary file
|
data/lib/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ruby_lsp/addon"
|
4
|
+
require_relative "indexing_enhancement"
|
5
|
+
require_relative "hover"
|
6
|
+
|
7
|
+
module RubyLsp
|
8
|
+
module Rake
|
9
|
+
class Addon < ::RubyLsp::Addon # rubocop:disable Style/Documentation
|
10
|
+
def activate(global_state, _message_queue)
|
11
|
+
@index = global_state.index
|
12
|
+
end
|
13
|
+
|
14
|
+
def deactivate; end
|
15
|
+
|
16
|
+
def name
|
17
|
+
"Ruby LSP Rake go to task def"
|
18
|
+
end
|
19
|
+
|
20
|
+
def version
|
21
|
+
"0.1.0"
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_hover_listener(response_builder, node_context, dispatcher)
|
25
|
+
Hover.new(response_builder, node_context, dispatcher, @index)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLsp
|
4
|
+
module Rake
|
5
|
+
class Hover # rubocop:disable Style/Documentation
|
6
|
+
include Requests::Support::Common
|
7
|
+
|
8
|
+
def initialize(response_builder, node_context, dispatcher, index)
|
9
|
+
@response_builder = response_builder
|
10
|
+
@node_context = node_context
|
11
|
+
dispatcher.register(self, :on_string_node_enter)
|
12
|
+
@index = index
|
13
|
+
end
|
14
|
+
|
15
|
+
def on_string_node_enter(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
16
|
+
call_node_name = @node_context.call_node&.name
|
17
|
+
return unless call_node_name == :task
|
18
|
+
|
19
|
+
name = case node
|
20
|
+
when Prism::StringNode
|
21
|
+
node.content
|
22
|
+
when Prism::SymbolNode
|
23
|
+
node.value
|
24
|
+
end
|
25
|
+
|
26
|
+
task_name = "task_#{name}"
|
27
|
+
return unless @index.indexed? task_name
|
28
|
+
|
29
|
+
entries = @index[task_name]
|
30
|
+
contents = entries.map do |entry|
|
31
|
+
label = "task :#{name}"
|
32
|
+
loc = entry.location
|
33
|
+
uri = URI::Generic.from_path(
|
34
|
+
path: entry.file_path,
|
35
|
+
fragment: "L#{loc.start_line},#{loc.start_column + 1}-#{loc.end_line},#{loc.end_column + 1}"
|
36
|
+
)
|
37
|
+
"[#{label}](#{uri})"
|
38
|
+
end
|
39
|
+
@response_builder.push("Definitions: #{contents.join(", ")}", category: :documentation)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLsp
|
4
|
+
module Rake
|
5
|
+
class IndexingEnhancement < RubyIndexer::Enhancement # rubocop:disable Style/Documentation
|
6
|
+
def on_call_node_enter(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
7
|
+
return unless @listener.current_owner.nil?
|
8
|
+
return unless node.name == :task
|
9
|
+
|
10
|
+
arguments = node.arguments&.arguments
|
11
|
+
return unless arguments
|
12
|
+
|
13
|
+
arg = arguments.first
|
14
|
+
name = case arg
|
15
|
+
when Prism::StringNode
|
16
|
+
arg.content
|
17
|
+
when Prism::SymbolNode
|
18
|
+
arg.value
|
19
|
+
when Prism::KeywordHashNode
|
20
|
+
case arg.child_nodes.first
|
21
|
+
when Prism::AssocNode
|
22
|
+
case arg.child_nodes.first.key
|
23
|
+
when Prism::StringNode
|
24
|
+
arg.child_nodes.first.key.content
|
25
|
+
when Prism::SymbolNode
|
26
|
+
arg.child_nodes.first.key.value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
return if name.nil?
|
32
|
+
|
33
|
+
location = node.location
|
34
|
+
@listener.add_method(
|
35
|
+
"task_#{name}",
|
36
|
+
location,
|
37
|
+
nil
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def on_call_node_leave(node); end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-lsp-rake
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Koji NAKAMURA
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-lsp
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.22.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.22.1
|
27
|
+
description: A Ruby LSP addon that adds extra editor functionality for Rake
|
28
|
+
email:
|
29
|
+
- kozy4324@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rubocop.yml"
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- img/dependency_task_links_on_hover.png
|
39
|
+
- lib/Rakefile
|
40
|
+
- lib/ruby/lsp/rake.rb
|
41
|
+
- lib/ruby/lsp/rake/version.rb
|
42
|
+
- lib/ruby_lsp/ruby_lsp_rake/addon.rb
|
43
|
+
- lib/ruby_lsp/ruby_lsp_rake/hover.rb
|
44
|
+
- lib/ruby_lsp/ruby_lsp_rake/indexing_enhancement.rb
|
45
|
+
- sig/ruby/lsp/rake.rbs
|
46
|
+
homepage: https://github.com/kozy4324/ruby-lsp-rake
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata:
|
50
|
+
allowed_push_host: https://rubygems.org
|
51
|
+
homepage_uri: https://github.com/kozy4324/ruby-lsp-rake
|
52
|
+
source_code_uri: https://github.com/kozy4324/ruby-lsp-rake
|
53
|
+
changelog_uri: https://github.com/kozy4324/ruby-lsp-rake/releases
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.0.0
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.5.23
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A Ruby LSP addon for Rake
|
73
|
+
test_files: []
|