solargraph 0.50.0 → 0.51.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +4 -6
- data/CHANGELOG.md +18 -0
- data/SPONSORS.md +1 -2
- data/lib/solargraph/cache.rb +1 -1
- data/lib/solargraph/complex_type.rb +7 -0
- data/lib/solargraph/convention.rb +0 -2
- data/lib/solargraph/language_server/host.rb +11 -1
- data/lib/solargraph/language_server/message/initialize.rb +8 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -0
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/library.rb +17 -1
- data/lib/solargraph/parser/rubyvm/class_methods.rb +4 -0
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_methods.rb +3 -1
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +10 -4
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/rubyvm/node_processors.rb +1 -0
- data/lib/solargraph/parser.rb +2 -2
- data/lib/solargraph/pin/block.rb +1 -1
- data/lib/solargraph/pin/delegated_method.rb +97 -0
- data/lib/solargraph/pin/method.rb +5 -0
- data/lib/solargraph/pin/search.rb +1 -1
- data/lib/solargraph/pin.rb +1 -0
- data/lib/solargraph/range.rb +2 -4
- data/lib/solargraph/rbs_map/conversions.rb +8 -6
- data/lib/solargraph/rbs_map/core_fills.rb +7 -1
- data/lib/solargraph/rbs_map/core_map.rb +1 -1
- data/lib/solargraph/rbs_map/stdlib_map.rb +3 -0
- data/lib/solargraph/source_map/clip.rb +14 -0
- data/lib/solargraph/source_map.rb +15 -2
- data/lib/solargraph/type_checker.rb +33 -21
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +6 -5
- data/lib/solargraph/yard_map.rb +14 -6
- data/solargraph.gemspec +7 -4
- metadata +70 -21
- data/lib/solargraph/convention/rspec.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925e6692e134d83820ade3224a10e1e25ba8b7f65c5a8399b185574f225ad8e7
|
4
|
+
data.tar.gz: 319f943451956ac714e110f48db851391cfb5c4b2ceb1e3e8d2eb2d22dc56c05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df03f1f0ed8e51f8c286395c4b87b1c254c78a897761ec71a9af896ef86c01e6d4285530ddf2e40c72f17afb6b5d87be11e219cc46859d7d7b7c2e05e24687bf
|
7
|
+
data.tar.gz: dd6b4f96bc8e6361bcfd313129a4ba9d680c8db45484deea040ec5fa6ba5a8873dcefa2980af4824d26f2ecc16d68bd5b5554e4978ae71853e22df49ed427894
|
data/.github/workflows/rspec.yml
CHANGED
@@ -22,19 +22,17 @@ jobs:
|
|
22
22
|
runs-on: ubuntu-latest
|
23
23
|
strategy:
|
24
24
|
matrix:
|
25
|
-
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
25
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', 'head']
|
26
26
|
|
27
27
|
steps:
|
28
28
|
- uses: actions/checkout@v3
|
29
29
|
- name: Set up Ruby
|
30
|
-
|
31
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
-
# uses: ruby/setup-ruby@v1
|
33
|
-
uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
|
30
|
+
uses: ruby/setup-ruby@v1
|
34
31
|
with:
|
35
32
|
ruby-version: ${{ matrix.ruby-version }}
|
36
33
|
bundler-cache: false
|
37
|
-
-
|
34
|
+
- name: Install gems
|
35
|
+
run: bundle install
|
38
36
|
- name: Set up yardocs
|
39
37
|
run: bundle exec yard gems
|
40
38
|
- name: Run tests
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 0.51.0 - January 19, 2025
|
2
|
+
- Resolve self in yieldself tags
|
3
|
+
- Include absolute paths in config (#674)
|
4
|
+
- Enable diagnostics by default
|
5
|
+
- Fix cache resolution (#704)
|
6
|
+
- Modify rubocop option for rubocop < 1.30 (#665)
|
7
|
+
- Include absolute paths in config (#674)
|
8
|
+
- Enable diagnostics by default
|
9
|
+
- Remove RSpec convention (#716)
|
10
|
+
- Include convention pins in document_symbols (#724)
|
11
|
+
- Remove e2mmap dependency (#699)
|
12
|
+
- Update rbs to 3.0
|
13
|
+
- Relax reverse_markdown dependency (#729)
|
14
|
+
- Fix Ruby 3.4 and move all parsing to whitequark (#739)
|
15
|
+
- Add Pin::DelegatedMethod (#602)
|
16
|
+
- Complete global methods from a file inside namespaces (#714)
|
17
|
+
- gemspec dashes and required path slashes (#697)
|
18
|
+
|
1
19
|
## 0.50.0 - December 5, 2023
|
2
20
|
- Remove .travis.yml as its not longer used (#627)
|
3
21
|
- Fix empty string case when processing requires (#644)
|
data/SPONSORS.md
CHANGED
@@ -7,11 +7,10 @@ The following people and organizations provide funding or other resources. [Beco
|
|
7
7
|
## Linked Sponsors
|
8
8
|
|
9
9
|
- **[Calyptix Security](https://www.calyptix.com/)**
|
10
|
-
- **[Lightward](https://lightward.com)**
|
11
10
|
|
12
11
|
## Named Sponsors
|
13
12
|
|
14
13
|
- Akira Yamada
|
15
|
-
- Jesus Castello
|
16
14
|
- Joel Drapper
|
17
15
|
- Spencer
|
16
|
+
- Vince Broz
|
data/lib/solargraph/cache.rb
CHANGED
@@ -10,7 +10,7 @@ module Solargraph
|
|
10
10
|
# The directory is not stored in a variable so it can be overridden
|
11
11
|
# in specs.
|
12
12
|
ENV['SOLARGRAPH_CACHE'] ||
|
13
|
-
ENV['XDG_CACHE_HOME'] ? File.join(ENV['XDG_CACHE_HOME'], 'solargraph') :
|
13
|
+
(ENV['XDG_CACHE_HOME'] ? File.join(ENV['XDG_CACHE_HOME'], 'solargraph') : nil) ||
|
14
14
|
File.join(Dir.home, '.cache', 'solargraph')
|
15
15
|
end
|
16
16
|
|
@@ -67,11 +67,18 @@ module Solargraph
|
|
67
67
|
def select &block
|
68
68
|
@items.select &block
|
69
69
|
end
|
70
|
+
|
71
|
+
# @return [String]
|
70
72
|
def namespace
|
71
73
|
# cache this attr for high frequency call
|
72
74
|
@namespace ||= method_missing(:namespace).to_s
|
73
75
|
end
|
74
76
|
|
77
|
+
# @return [Array<String>]
|
78
|
+
def namespaces
|
79
|
+
@items.map(&:namespace)
|
80
|
+
end
|
81
|
+
|
75
82
|
def method_missing name, *args, &block
|
76
83
|
return if @items.first.nil?
|
77
84
|
return @items.first.send(name, *args, &block) if respond_to_missing?(name)
|
@@ -9,7 +9,6 @@ module Solargraph
|
|
9
9
|
module Convention
|
10
10
|
autoload :Base, 'solargraph/convention/base'
|
11
11
|
autoload :Gemfile, 'solargraph/convention/gemfile'
|
12
|
-
autoload :Rspec, 'solargraph/convention/rspec'
|
13
12
|
autoload :Gemspec, 'solargraph/convention/gemspec'
|
14
13
|
autoload :Rakefile, 'solargraph/convention/rakefile'
|
15
14
|
|
@@ -43,7 +42,6 @@ module Solargraph
|
|
43
42
|
|
44
43
|
register Gemfile
|
45
44
|
register Gemspec
|
46
|
-
register Rspec
|
47
45
|
register Rakefile
|
48
46
|
end
|
49
47
|
end
|
@@ -533,6 +533,15 @@ module Solargraph
|
|
533
533
|
library.definitions_at(uri_to_file(uri), line, column)
|
534
534
|
end
|
535
535
|
|
536
|
+
# @param uri [String]
|
537
|
+
# @param line [Integer]
|
538
|
+
# @param column [Integer]
|
539
|
+
# @return [Array<Solargraph::Pin::Base>]
|
540
|
+
def type_definitions_at uri, line, column
|
541
|
+
library = library_for(uri)
|
542
|
+
library.type_definitions_at(uri_to_file(uri), line, column)
|
543
|
+
end
|
544
|
+
|
536
545
|
# @param uri [String]
|
537
546
|
# @param line [Integer]
|
538
547
|
# @param column [Integer]
|
@@ -630,10 +639,11 @@ module Solargraph
|
|
630
639
|
'hover' => true,
|
631
640
|
'symbols' => true,
|
632
641
|
'definitions' => true,
|
642
|
+
'typeDefinitions' => true,
|
633
643
|
'rename' => true,
|
634
644
|
'references' => true,
|
635
645
|
'autoformat' => false,
|
636
|
-
'diagnostics' =>
|
646
|
+
'diagnostics' => true,
|
637
647
|
'formatting' => false,
|
638
648
|
'folding' => true,
|
639
649
|
'highlights' => true,
|
@@ -34,6 +34,7 @@ module Solargraph
|
|
34
34
|
result[:capabilities].merge! static_document_formatting unless dynamic_registration_for?('textDocument', 'formatting')
|
35
35
|
result[:capabilities].merge! static_document_symbols unless dynamic_registration_for?('textDocument', 'documentSymbol')
|
36
36
|
result[:capabilities].merge! static_definitions unless dynamic_registration_for?('textDocument', 'definition')
|
37
|
+
result[:capabilities].merge! static_type_definitions unless dynamic_registration_for?('textDocument', 'typeDefinition')
|
37
38
|
result[:capabilities].merge! static_rename unless dynamic_registration_for?('textDocument', 'rename')
|
38
39
|
result[:capabilities].merge! static_references unless dynamic_registration_for?('textDocument', 'references')
|
39
40
|
result[:capabilities].merge! static_workspace_symbols unless dynamic_registration_for?('workspace', 'symbol')
|
@@ -121,6 +122,13 @@ module Solargraph
|
|
121
122
|
}
|
122
123
|
end
|
123
124
|
|
125
|
+
def static_type_definitions
|
126
|
+
return {} unless host.options['type_definitions']
|
127
|
+
{
|
128
|
+
definitionProvider: true
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
124
132
|
def static_rename
|
125
133
|
{
|
126
134
|
renameProvider: {prepareProvider: true}
|
@@ -6,6 +6,8 @@ class Solargraph::LanguageServer::Message::TextDocument::DocumentSymbol < Solarg
|
|
6
6
|
def process
|
7
7
|
pins = host.document_symbols params['textDocument']['uri']
|
8
8
|
info = pins.map do |pin|
|
9
|
+
next nil unless pin.location&.filename
|
10
|
+
|
9
11
|
result = {
|
10
12
|
name: pin.name,
|
11
13
|
containerName: pin.namespace,
|
@@ -17,7 +19,8 @@ class Solargraph::LanguageServer::Message::TextDocument::DocumentSymbol < Solarg
|
|
17
19
|
deprecated: pin.deprecated?
|
18
20
|
}
|
19
21
|
result
|
20
|
-
end
|
22
|
+
end.compact
|
23
|
+
|
21
24
|
set_result info
|
22
25
|
end
|
23
26
|
end
|
@@ -17,17 +17,17 @@ module Solargraph
|
|
17
17
|
args = cli_args(file_uri, config)
|
18
18
|
|
19
19
|
require_rubocop(config['version'])
|
20
|
-
options, paths = RuboCop::Options.new.parse(args)
|
20
|
+
options, paths = ::RuboCop::Options.new.parse(args)
|
21
21
|
options[:stdin] = original
|
22
22
|
corrections = redirect_stdout do
|
23
|
-
RuboCop::Runner.new(options, RuboCop::ConfigStore.new).run(paths)
|
23
|
+
::RuboCop::Runner.new(options, ::RuboCop::ConfigStore.new).run(paths)
|
24
24
|
end
|
25
25
|
result = options[:stdin]
|
26
26
|
|
27
27
|
log_corrections(corrections)
|
28
28
|
|
29
29
|
format original, result
|
30
|
-
rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
|
30
|
+
rescue ::RuboCop::ValidationError, ::RuboCop::ConfigNotFoundError => e
|
31
31
|
set_error(Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}")
|
32
32
|
end
|
33
33
|
|
@@ -54,7 +54,7 @@ module Solargraph
|
|
54
54
|
def cli_args file_uri, config
|
55
55
|
file = UriHelpers.uri_to_file(file_uri)
|
56
56
|
args = [
|
57
|
-
config['cops'] == 'all' ? '
|
57
|
+
config['cops'] == 'all' ? '-A' : '-a',
|
58
58
|
'--cache', 'false',
|
59
59
|
'--format', formatter_class(config).name,
|
60
60
|
]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph::LanguageServer::Message::TextDocument
|
4
|
+
class TypeDefinition < Base
|
5
|
+
def process
|
6
|
+
@line = params['position']['line']
|
7
|
+
@column = params['position']['character']
|
8
|
+
set_result(code_location || [])
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def code_location
|
14
|
+
suggestions = host.type_definitions_at(params['textDocument']['uri'], @line, @column)
|
15
|
+
return nil if suggestions.empty?
|
16
|
+
suggestions.reject { |pin| pin.location.nil? || pin.location.filename.nil? }.map do |pin|
|
17
|
+
{
|
18
|
+
uri: file_to_uri(pin.location.filename),
|
19
|
+
range: pin.location.range.to_hash
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -15,6 +15,7 @@ module Solargraph
|
|
15
15
|
autoload :DiagnosticsQueue, 'solargraph/language_server/message/text_document/diagnostics_queue'
|
16
16
|
autoload :OnTypeFormatting, 'solargraph/language_server/message/text_document/on_type_formatting'
|
17
17
|
autoload :Definition, 'solargraph/language_server/message/text_document/definition'
|
18
|
+
autoload :TypeDefinition, 'solargraph/language_server/message/text_document/type_definition'
|
18
19
|
autoload :DocumentSymbol, 'solargraph/language_server/message/text_document/document_symbol'
|
19
20
|
autoload :Formatting, 'solargraph/language_server/message/text_document/formatting'
|
20
21
|
autoload :References, 'solargraph/language_server/message/text_document/references'
|
@@ -66,6 +66,7 @@ module Solargraph
|
|
66
66
|
register 'textDocument/didClose', TextDocument::DidClose
|
67
67
|
register 'textDocument/hover', TextDocument::Hover
|
68
68
|
register 'textDocument/definition', TextDocument::Definition
|
69
|
+
register 'textDocument/typeDefinition', TextDocument::TypeDefinition
|
69
70
|
register 'textDocument/formatting', TextDocument::Formatting
|
70
71
|
register 'textDocument/onTypeFormatting', TextDocument::OnTypeFormatting
|
71
72
|
register 'textDocument/documentSymbol', TextDocument::DocumentSymbol
|
data/lib/solargraph/library.rb
CHANGED
@@ -97,7 +97,7 @@ module Solargraph
|
|
97
97
|
def create filename, text
|
98
98
|
result = false
|
99
99
|
mutex.synchronize do
|
100
|
-
next unless contain?(filename) || open?(filename)
|
100
|
+
next unless contain?(filename) || open?(filename)
|
101
101
|
@synchronized = false
|
102
102
|
source = Solargraph::Source.load_string(text, filename)
|
103
103
|
workspace.merge(source)
|
@@ -199,6 +199,22 @@ module Solargraph
|
|
199
199
|
handle_file_not_found(filename, e)
|
200
200
|
end
|
201
201
|
|
202
|
+
# Get type definition suggestions for the expression at the specified file and
|
203
|
+
# location.
|
204
|
+
#
|
205
|
+
# @param filename [String] The file to analyze
|
206
|
+
# @param line [Integer] The zero-based line number
|
207
|
+
# @param column [Integer] The zero-based column number
|
208
|
+
# @return [Array<Solargraph::Pin::Base>]
|
209
|
+
# @todo Take filename/position instead of filename/line/column
|
210
|
+
def type_definitions_at filename, line, column
|
211
|
+
position = Position.new(line, column)
|
212
|
+
cursor = Source::Cursor.new(read(filename), position)
|
213
|
+
api_map.clip(cursor).types
|
214
|
+
rescue FileNotFoundError => e
|
215
|
+
handle_file_not_found filename, e
|
216
|
+
end
|
217
|
+
|
202
218
|
# Get signature suggestions for the method at the specified file and
|
203
219
|
# location.
|
204
220
|
#
|
@@ -108,9 +108,13 @@ module Solargraph
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def node_range node
|
111
|
+
if node.nil?
|
112
|
+
nil
|
113
|
+
else
|
111
114
|
st = Position.new(node.first_lineno - 1, node.first_column)
|
112
115
|
en = Position.new(node.last_lineno - 1, node.last_column)
|
113
116
|
Range.new(st, en)
|
117
|
+
end
|
114
118
|
end
|
115
119
|
|
116
120
|
def recipient_node tree
|
@@ -98,7 +98,7 @@ module Solargraph
|
|
98
98
|
result.concat generate_links(n.children.last)
|
99
99
|
elsif n.type == :OR
|
100
100
|
result.push Chain::Or.new([NodeChainer.chain(n.children[0], @filename), NodeChainer.chain(n.children[1], @filename)])
|
101
|
-
elsif n.type == :
|
101
|
+
elsif n.type == :BEGIN
|
102
102
|
result.concat generate_links(n.children[0])
|
103
103
|
elsif n.type == :BLOCK_PASS
|
104
104
|
result.push Chain::BlockVariable.new("&#{n.children[1].children[0].to_s}")
|
@@ -32,10 +32,12 @@ module Solargraph
|
|
32
32
|
def infer_literal_node_type node
|
33
33
|
return nil unless Parser.is_ast_node?(node)
|
34
34
|
case node.type
|
35
|
-
when :LIT, :STR
|
35
|
+
when :LIT, :STR, :SYM
|
36
36
|
"::#{node.children.first.class.to_s}"
|
37
37
|
when :DSTR
|
38
38
|
"::String"
|
39
|
+
when :INTEGER
|
40
|
+
'::Integer'
|
39
41
|
when :ARRAY, :ZARRAY, :LIST, :ZLIST
|
40
42
|
'::Array'
|
41
43
|
when :HASH
|
@@ -22,7 +22,7 @@ module Solargraph
|
|
22
22
|
locals.push Solargraph::Pin::LocalVariable.new(
|
23
23
|
location: loc,
|
24
24
|
closure: region.closure,
|
25
|
-
name: node.children[1].children.first.
|
25
|
+
name: node.children[1].children.first.to_s,
|
26
26
|
comments: "@type [#{types.join(',')}]",
|
27
27
|
presence: presence
|
28
28
|
)
|
@@ -34,9 +34,15 @@ module Solargraph
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def exception_variable?
|
37
|
-
|
38
|
-
Parser.is_ast_node?(node.children[1]
|
39
|
-
|
37
|
+
if RUBY_VERSION =~ /^3\.4\./
|
38
|
+
Parser.is_ast_node?(node.children[1]) &&
|
39
|
+
# Parser.is_ast_node?(node.children[1].children.first) &&
|
40
|
+
node.children[1].type == :LASGN
|
41
|
+
else
|
42
|
+
Parser.is_ast_node?(node.children[1]) &&
|
43
|
+
Parser.is_ast_node?(node.children[1].children.first) &&
|
44
|
+
node.children[1].children.first.type == :LASGN
|
45
|
+
end
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
@@ -43,7 +43,7 @@ module Solargraph
|
|
43
43
|
if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
|
44
44
|
node.children.last.children[0..-2].each do |child|
|
45
45
|
# next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
|
46
|
-
if child.type == :LIT || child.type == :STR
|
46
|
+
if child.type == :LIT || child.type == :STR || child.type == :SYM
|
47
47
|
name = child.children[0].to_s
|
48
48
|
matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
|
49
49
|
matches.each do |pin|
|
@@ -175,7 +175,7 @@ module Solargraph
|
|
175
175
|
NodeProcessor.process node.children.last.children[0], region.update(visibility: :module_function), pins, locals
|
176
176
|
else
|
177
177
|
node.children.last.children[0..-2].each do |x|
|
178
|
-
next unless [:LIT, :STR].include?(x.type)
|
178
|
+
next unless [:LIT, :STR, :SYM].include?(x.type)
|
179
179
|
cn = x.children[0].to_s
|
180
180
|
ref = pins.select { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }.first
|
181
181
|
unless ref.nil?
|
data/lib/solargraph/parser.rb
CHANGED
data/lib/solargraph/pin/block.rb
CHANGED
@@ -63,7 +63,7 @@ module Solargraph
|
|
63
63
|
if receiver_pin && receiver_pin.docstring
|
64
64
|
ys = receiver_pin.docstring.tag(:yieldself)
|
65
65
|
if ys && ys.types && !ys.types.empty?
|
66
|
-
return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
|
66
|
+
return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace).self_to(receiver_pin.full_context.namespace)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
nil
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Solargraph
|
4
|
+
module Pin
|
5
|
+
# A DelegatedMethod is a more complicated version of a MethodAlias that
|
6
|
+
# allows aliasing a method from a different closure (class/module etc).
|
7
|
+
class DelegatedMethod < Pin::Method
|
8
|
+
# A DelegatedMethod can be constructed with either a :resolved_method
|
9
|
+
# pin, or a :receiver_chain. When a :receiver_chain is supplied, it
|
10
|
+
# will be used to *dynamically* resolve a receiver type within the
|
11
|
+
# given closure/scope, and the delegated method will then be resolved
|
12
|
+
# to a method pin on that type.
|
13
|
+
#
|
14
|
+
# @param resolved_method [Method] an already resolved method pin.
|
15
|
+
# @param receiver [Source::Chain] the source code used to resolve the receiver for this delegated method.
|
16
|
+
# @param receiver_method_name [String] the method name that will be called on the receiver (defaults to :name).
|
17
|
+
def initialize(method: nil, receiver: nil, name: method&.name, receiver_method_name: name, **splat)
|
18
|
+
raise ArgumentError, 'either :method or :receiver is required' if (method && receiver) || (!method && !receiver)
|
19
|
+
super(name: name, **splat)
|
20
|
+
|
21
|
+
@receiver_chain = receiver
|
22
|
+
@resolved_method = method
|
23
|
+
@receiver_method_name = receiver_method_name
|
24
|
+
end
|
25
|
+
|
26
|
+
%i[comments parameters return_type location].each do |method|
|
27
|
+
define_method(method) do
|
28
|
+
@resolved_method ? @resolved_method.send(method) : super()
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
%i[typify realize infer probe].each do |method|
|
33
|
+
# @param api_map [ApiMap]
|
34
|
+
define_method(method) do |api_map|
|
35
|
+
resolve_method(api_map)
|
36
|
+
@resolved_method ? @resolved_method.send(method, api_map) : super(api_map)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def resolvable?(api_map)
|
41
|
+
resolve_method(api_map)
|
42
|
+
!!@resolved_method
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# Resolves the receiver chain and method name to a method pin, resetting any previously resolution.
|
48
|
+
#
|
49
|
+
# @param api_map [ApiMap]
|
50
|
+
# @return [Pin::Method, nil]
|
51
|
+
def resolve_method api_map
|
52
|
+
return if @resolved_method
|
53
|
+
|
54
|
+
resolver = @receiver_chain.define(api_map, self, []).first
|
55
|
+
|
56
|
+
unless resolver
|
57
|
+
Solargraph.logger.warn \
|
58
|
+
"Delegated receiver for #{path} was resolved to nil from `#{print_chain(@receiver_chain)}'"
|
59
|
+
return
|
60
|
+
end
|
61
|
+
|
62
|
+
receiver_type = resolver.return_type
|
63
|
+
|
64
|
+
return if receiver_type.undefined?
|
65
|
+
|
66
|
+
receiver_path, method_scope =
|
67
|
+
if @receiver_chain.constant?
|
68
|
+
# HACK: the `return_type` of a constant is Class<Whatever>, but looking up a method expects
|
69
|
+
# the arguments `"Whatever"` and `scope: :class`.
|
70
|
+
[receiver_type.to_s.sub(/^Class<(.+)>$/, '\1'), :class]
|
71
|
+
else
|
72
|
+
[receiver_type.to_s, :instance]
|
73
|
+
end
|
74
|
+
|
75
|
+
method_stack = api_map.get_method_stack(receiver_path, @receiver_method_name, scope: method_scope)
|
76
|
+
@resolved_method = method_stack.first
|
77
|
+
end
|
78
|
+
|
79
|
+
# helper to print a source chain as code, probably not 100% correct.
|
80
|
+
#
|
81
|
+
# @param chain [Source::Chain]
|
82
|
+
def print_chain(chain)
|
83
|
+
out = +''
|
84
|
+
chain.links.each_with_index do |link, index|
|
85
|
+
if index > 0
|
86
|
+
if Source::Chain::Constant
|
87
|
+
out << '::' unless link.word.start_with?('::')
|
88
|
+
else
|
89
|
+
out << '.'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
out << link.word
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -130,6 +130,11 @@ module Solargraph
|
|
130
130
|
end
|
131
131
|
@documentation += "\n\n" unless @documentation.empty?
|
132
132
|
@documentation += "Visibility: #{visibility}"
|
133
|
+
example_tags = docstring.tags(:example)
|
134
|
+
unless example_tags.empty?
|
135
|
+
@documentation += "\n\nExamples:\n\n"
|
136
|
+
@documentation += example_tags.map(&:text).join("\n")
|
137
|
+
end
|
133
138
|
end
|
134
139
|
@documentation.to_s
|
135
140
|
end
|
@@ -49,7 +49,7 @@ module Solargraph
|
|
49
49
|
# @return [Float]
|
50
50
|
def fuzzy_string_match str1, str2
|
51
51
|
return (1.0 + (str2.length.to_f / str1.length.to_f)) if str1.downcase.include?(str2.downcase)
|
52
|
-
JaroWinkler.
|
52
|
+
JaroWinkler.similarity(str1, str2, ignore_case: true)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/lib/solargraph/pin.rb
CHANGED
@@ -12,6 +12,7 @@ module Solargraph
|
|
12
12
|
autoload :Method, 'solargraph/pin/method'
|
13
13
|
autoload :Signature, 'solargraph/pin/signature'
|
14
14
|
autoload :MethodAlias, 'solargraph/pin/method_alias'
|
15
|
+
autoload :DelegatedMethod, 'solargraph/pin/delegated_method'
|
15
16
|
autoload :BaseVariable, 'solargraph/pin/base_variable'
|
16
17
|
autoload :InstanceVariable, 'solargraph/pin/instance_variable'
|
17
18
|
autoload :ClassVariable, 'solargraph/pin/class_variable'
|
data/lib/solargraph/range.rb
CHANGED
@@ -65,10 +65,8 @@ module Solargraph
|
|
65
65
|
# @param node [RubyVM::AbstractSyntaxTree::Node, Parser::AST::Node]
|
66
66
|
# @return [Range]
|
67
67
|
def self.from_node node
|
68
|
-
if
|
69
|
-
|
70
|
-
Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
|
71
|
-
end
|
68
|
+
if Parser.rubyvm? && node.is_a?(RubyVM::AbstractSyntaxTree::Node)
|
69
|
+
Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
|
72
70
|
elsif node&.loc && node.loc.expression
|
73
71
|
from_expr(node.loc.expression)
|
74
72
|
end
|
@@ -40,7 +40,7 @@ module Solargraph
|
|
40
40
|
when RBS::AST::Declarations::Interface
|
41
41
|
# STDERR.puts "Skipping interface #{decl.name.relative!}"
|
42
42
|
interface_decl_to_pin decl
|
43
|
-
when RBS::AST::Declarations::
|
43
|
+
when RBS::AST::Declarations::TypeAlias
|
44
44
|
type_aliases[decl.name.to_s] = decl
|
45
45
|
when RBS::AST::Declarations::Module
|
46
46
|
module_decl_to_pin decl
|
@@ -222,17 +222,19 @@ module Solargraph
|
|
222
222
|
# @param decl [RBS::AST::Members::MethodDefinition]
|
223
223
|
# @param pin [Pin::Method]
|
224
224
|
def method_def_to_sigs decl, pin
|
225
|
-
decl.
|
226
|
-
parameters, return_type = parts_of_function(
|
227
|
-
block = if
|
228
|
-
|
225
|
+
decl.overloads.map do |overload|
|
226
|
+
parameters, return_type = parts_of_function(overload.method_type, pin)
|
227
|
+
block = if overload.method_type.block
|
228
|
+
Pin::Signature.new(*parts_of_function(overload.method_type.block, pin))
|
229
229
|
end
|
230
|
-
return_type = ComplexType.try_parse(method_type_to_tag(
|
230
|
+
return_type = ComplexType.try_parse(method_type_to_tag(overload.method_type))
|
231
231
|
Pin::Signature.new(parameters, return_type, block)
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
235
|
def parts_of_function type, pin
|
236
|
+
return [[Solargraph::Pin::Parameter.new(decl: :restarg, name: 'arg', closure: pin)], ComplexType.try_parse(method_type_to_tag(type))] if defined?(RBS::Types::UntypedFunction) && type.type.is_a?(RBS::Types::UntypedFunction)
|
237
|
+
|
236
238
|
parameters = []
|
237
239
|
arg_num = -1
|
238
240
|
type.type.required_positionals.each do |param|
|
@@ -15,6 +15,11 @@ module Solargraph
|
|
15
15
|
'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
|
16
16
|
].map { |k| Pin::Keyword.new(k) }
|
17
17
|
|
18
|
+
MISSING = [
|
19
|
+
Solargraph::Pin::Method.new(name: 'tap', scope: :instance, closure: Solargraph::Pin::Namespace.new(name: 'Object')),
|
20
|
+
Solargraph::Pin::Method.new(name: 'class', scope: :instance, closure: Solargraph::Pin::Namespace.new(name: 'Object'), comments: '@return [Class<self>]')
|
21
|
+
]
|
22
|
+
|
18
23
|
YIELDPARAMS = [
|
19
24
|
Override.from_comment('Object#tap', %(
|
20
25
|
@return [self]
|
@@ -55,7 +60,8 @@ module Solargraph
|
|
55
60
|
end
|
56
61
|
ERRNOS = errnos
|
57
62
|
|
58
|
-
ALL = KEYWORDS + YIELDPARAMS + YIELDPARAM_SINGLE_PARAMETERS + CLASS_RETURN_TYPES + ERRNOS
|
63
|
+
ALL = KEYWORDS + MISSING + YIELDPARAMS + YIELDPARAM_SINGLE_PARAMETERS + CLASS_RETURN_TYPES + ERRNOS
|
59
64
|
end
|
60
65
|
end
|
61
66
|
end
|
67
|
+
|
@@ -12,7 +12,7 @@ module Solargraph
|
|
12
12
|
if cache
|
13
13
|
pins.replace cache
|
14
14
|
else
|
15
|
-
loader = RBS::EnvironmentLoader.new(repository: RBS::Repository.new(no_stdlib:
|
15
|
+
loader = RBS::EnvironmentLoader.new(repository: RBS::Repository.new(no_stdlib: false))
|
16
16
|
environment = RBS::Environment.from_loader(loader).resolve_type_names
|
17
17
|
environment.declarations.each { |decl| convert_decl_to_pin(decl, Solargraph::Pin::ROOT_PIN) }
|
18
18
|
pins.concat RbsMap::CoreFills::ALL
|
@@ -18,6 +18,9 @@ module Solargraph
|
|
18
18
|
pins.replace cache
|
19
19
|
else
|
20
20
|
super
|
21
|
+
if library == 'yaml'
|
22
|
+
pins.push Solargraph::Pin::Constant.new(name: 'YAML', comments: '@return [Module<Psych>]', closure: Pin::ROOT_PIN)
|
23
|
+
end
|
21
24
|
Cache.save('stdlib', "#{library}.ser", pins)
|
22
25
|
end
|
23
26
|
end
|
@@ -17,10 +17,16 @@ module Solargraph
|
|
17
17
|
def define
|
18
18
|
return [] if cursor.comment? || cursor.chain.literal?
|
19
19
|
result = cursor.chain.define(api_map, block, locals)
|
20
|
+
result.concat file_global_methods
|
20
21
|
result.concat((source_map.pins + source_map.locals).select{ |p| p.name == cursor.word && p.location.range.contain?(cursor.position) }) if result.empty?
|
21
22
|
result
|
22
23
|
end
|
23
24
|
|
25
|
+
# @return [Array<Pin::Base>]
|
26
|
+
def types
|
27
|
+
infer.namespaces.map { |namespace| api_map.get_path_pins(namespace) }.flatten
|
28
|
+
end
|
29
|
+
|
24
30
|
# @return [Completion]
|
25
31
|
def complete
|
26
32
|
return package_completions([]) if !source_map.source.parsed? || cursor.string?
|
@@ -214,6 +220,7 @@ module Solargraph
|
|
214
220
|
return package_completions(api_map.get_global_variable_pins)
|
215
221
|
end
|
216
222
|
result.concat locals
|
223
|
+
result.concat file_global_methods unless block.binder.namespace.empty?
|
217
224
|
result.concat api_map.get_constants(context_pin.context.namespace, *gates)
|
218
225
|
result.concat api_map.get_methods(block.binder.namespace, scope: block.binder.scope, visibility: [:public, :private, :protected])
|
219
226
|
result.concat api_map.get_methods('Kernel')
|
@@ -224,6 +231,13 @@ module Solargraph
|
|
224
231
|
end
|
225
232
|
package_completions(result)
|
226
233
|
end
|
234
|
+
|
235
|
+
def file_global_methods
|
236
|
+
return [] if cursor.word.empty?
|
237
|
+
source_map.pins.select do |pin|
|
238
|
+
pin.is_a?(Pin::Method) && pin.namespace == '' && pin.name.start_with?(cursor.word)
|
239
|
+
end
|
240
|
+
end
|
227
241
|
end
|
228
242
|
end
|
229
243
|
end
|
@@ -30,6 +30,7 @@ module Solargraph
|
|
30
30
|
@pins = pins
|
31
31
|
@locals = locals
|
32
32
|
environ.merge Convention.for_local(self) unless filename.nil?
|
33
|
+
self.convention_pins = environ.pins
|
33
34
|
@pin_class_hash = pins.to_set.classify(&:class).transform_values(&:to_a)
|
34
35
|
@pin_select_cache = {}
|
35
36
|
end
|
@@ -65,11 +66,12 @@ module Solargraph
|
|
65
66
|
@environ ||= Environ.new
|
66
67
|
end
|
67
68
|
|
69
|
+
# all pins except Solargraph::Pin::Reference::Reference
|
68
70
|
# @return [Array<Pin::Base>]
|
69
71
|
def document_symbols
|
70
|
-
@document_symbols ||= pins.select
|
72
|
+
@document_symbols ||= (pins + convention_pins).select do |pin|
|
71
73
|
pin.path && !pin.path.empty?
|
72
|
-
|
74
|
+
end
|
73
75
|
end
|
74
76
|
|
75
77
|
# @param query [String]
|
@@ -159,6 +161,17 @@ module Solargraph
|
|
159
161
|
|
160
162
|
private
|
161
163
|
|
164
|
+
# @return [Array<Pin::Base>]
|
165
|
+
def convention_pins
|
166
|
+
@convention_pins || []
|
167
|
+
end
|
168
|
+
|
169
|
+
def convention_pins=(pins)
|
170
|
+
# unmemoizing the document_symbols in case it was called from any of convnetions
|
171
|
+
@document_symbols = nil
|
172
|
+
@convention_pins = pins
|
173
|
+
end
|
174
|
+
|
162
175
|
# @param line [Integer]
|
163
176
|
# @param character [Integer]
|
164
177
|
# @param klasses [Array<Class>]
|
@@ -254,12 +254,20 @@ module Solargraph
|
|
254
254
|
result
|
255
255
|
end
|
256
256
|
|
257
|
+
# @param chain [Solargraph::Source::Chain]
|
258
|
+
# @param api_map [Solargraph::ApiMap]
|
259
|
+
# @param block_pin [Solargraph::Pin::Base]
|
260
|
+
# @param locals [Array<Solargraph::Pin::Base>]
|
261
|
+
# @param location [Solargraph::Location]
|
257
262
|
def argument_problems_for chain, api_map, block_pin, locals, location
|
258
263
|
result = []
|
259
264
|
base = chain
|
260
265
|
until base.links.length == 1 && base.undefined?
|
261
266
|
pins = base.define(api_map, block_pin, locals)
|
262
|
-
|
267
|
+
|
268
|
+
if pins.first.is_a?(Pin::DelegatedMethod) && !pins.first.resolvable?(api_map)
|
269
|
+
# Do nothing, as we can't find the actual method implementation
|
270
|
+
elsif pins.first.is_a?(Pin::Method)
|
263
271
|
# @type [Pin::Method]
|
264
272
|
pin = pins.first
|
265
273
|
ap = if base.links.last.is_a?(Solargraph::Source::Chain::ZSuper)
|
@@ -279,9 +287,14 @@ module Solargraph
|
|
279
287
|
errors = []
|
280
288
|
sig.parameters.each_with_index do |par, idx|
|
281
289
|
argchain = base.links.last.arguments[idx]
|
282
|
-
if argchain.nil?
|
283
|
-
|
284
|
-
|
290
|
+
if argchain.nil?
|
291
|
+
if par.decl == :arg
|
292
|
+
errors.push Problem.new(location, "Not enough arguments to #{pin.path}")
|
293
|
+
next
|
294
|
+
else
|
295
|
+
last = base.links.last.arguments.last
|
296
|
+
argchain = last if last && [:kwsplat, :hash].include?(last.node.type)
|
297
|
+
end
|
285
298
|
end
|
286
299
|
if argchain
|
287
300
|
if par.decl != :arg
|
@@ -317,30 +330,29 @@ module Solargraph
|
|
317
330
|
result
|
318
331
|
end
|
319
332
|
|
320
|
-
def kwarg_problems_for argchain, api_map, block_pin, locals, location, pin, params,
|
333
|
+
def kwarg_problems_for argchain, api_map, block_pin, locals, location, pin, params, idx
|
321
334
|
result = []
|
322
335
|
kwargs = convert_hash(argchain.node)
|
323
|
-
pin.signatures.first.parameters[
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
next if ptype.undefined?
|
336
|
+
par = pin.signatures.first.parameters[idx]
|
337
|
+
argchain = kwargs[par.name.to_sym]
|
338
|
+
if par.decl == :kwrestarg || (par.decl == :optarg && idx == pin.parameters.length - 1 && par.asgn_code == '{}')
|
339
|
+
result.concat kwrestarg_problems_for(api_map, block_pin, locals, location, pin, params, kwargs)
|
340
|
+
else
|
341
|
+
if argchain
|
342
|
+
data = params[par.name]
|
343
|
+
if data.nil?
|
344
|
+
# @todo Some level (strong, I guess) should require the param here
|
345
|
+
else
|
346
|
+
ptype = data[:qualified]
|
347
|
+
unless ptype.undefined?
|
336
348
|
argtype = argchain.infer(api_map, block_pin, locals)
|
337
349
|
if argtype.defined? && ptype && !any_types_match?(api_map, ptype, argtype)
|
338
350
|
result.push Problem.new(location, "Wrong argument type for #{pin.path}: #{par.name} expected #{ptype}, received #{argtype}")
|
339
351
|
end
|
340
352
|
end
|
341
|
-
elsif par.decl == :kwarg
|
342
|
-
result.push Problem.new(location, "Call to #{pin.path} is missing keyword argument #{par.name}")
|
343
353
|
end
|
354
|
+
elsif par.decl == :kwarg
|
355
|
+
result.push Problem.new(location, "Call to #{pin.path} is missing keyword argument #{par.name}")
|
344
356
|
end
|
345
357
|
end
|
346
358
|
result
|
@@ -542,7 +554,7 @@ module Solargraph
|
|
542
554
|
def without_ignored problems
|
543
555
|
problems.reject do |problem|
|
544
556
|
node = source_map.source.node_at(problem.location.range.start.line, problem.location.range.start.column)
|
545
|
-
source_map.source.comments_for(node)&.include?('@sg-ignore')
|
557
|
+
node && source_map.source.comments_for(node)&.include?('@sg-ignore')
|
546
558
|
end
|
547
559
|
end
|
548
560
|
end
|
data/lib/solargraph/version.rb
CHANGED
@@ -19,7 +19,7 @@ module Solargraph
|
|
19
19
|
|
20
20
|
# @param directory [String]
|
21
21
|
def initialize directory = ''
|
22
|
-
@directory = directory
|
22
|
+
@directory = File.absolute_path(directory)
|
23
23
|
@raw_data = config_data
|
24
24
|
included
|
25
25
|
excluded
|
@@ -42,7 +42,8 @@ module Solargraph
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def allow? filename
|
45
|
-
filename.
|
45
|
+
filename = File.absolute_path(filename, directory)
|
46
|
+
filename.start_with?(directory) &&
|
46
47
|
!excluded.include?(filename) &&
|
47
48
|
excluded_directories.none? { |d| filename.start_with?(d) }
|
48
49
|
end
|
@@ -171,7 +172,7 @@ module Solargraph
|
|
171
172
|
# @return [Array<String>]
|
172
173
|
def process_globs globs
|
173
174
|
result = globs.flat_map do |glob|
|
174
|
-
Dir[File.
|
175
|
+
Dir[File.absolute_path(glob, directory)]
|
175
176
|
.map{ |f| f.gsub(/\\/, '/') }
|
176
177
|
.select { |f| File.file?(f) }
|
177
178
|
end
|
@@ -186,7 +187,7 @@ module Solargraph
|
|
186
187
|
def process_exclusions globs
|
187
188
|
remainder = globs.select do |glob|
|
188
189
|
if glob_is_directory?(glob)
|
189
|
-
exdir = File.
|
190
|
+
exdir = File.absolute_path(glob_to_directory(glob), directory)
|
190
191
|
included.delete_if { |file| file.start_with?(exdir) }
|
191
192
|
false
|
192
193
|
else
|
@@ -224,7 +225,7 @@ module Solargraph
|
|
224
225
|
def excluded_directories
|
225
226
|
@raw_data['exclude']
|
226
227
|
.select { |g| glob_is_directory?(g) }
|
227
|
-
.map { |g| File.
|
228
|
+
.map { |g| File.absolute_path(glob_to_directory(g), directory) }
|
228
229
|
end
|
229
230
|
end
|
230
231
|
end
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -220,9 +220,11 @@ module Solargraph
|
|
220
220
|
result = []
|
221
221
|
begin
|
222
222
|
name = r.split('/').first.to_s
|
223
|
-
return [] if name.empty?
|
224
|
-
|
225
|
-
|
223
|
+
return [] if name.empty?
|
224
|
+
|
225
|
+
spec = spec_for_require(r)
|
226
|
+
return [] if @source_gems.include?(spec.name) || @gem_paths.key?(spec.name)
|
227
|
+
@gem_paths[spec.name] = spec.full_gem_path
|
226
228
|
|
227
229
|
yd = yardoc_file_for_spec(spec)
|
228
230
|
# YARD detects gems for certain libraries that do not have a yardoc
|
@@ -282,13 +284,19 @@ module Solargraph
|
|
282
284
|
# @param path [String]
|
283
285
|
# @return [Gem::Specification]
|
284
286
|
def spec_for_require path
|
285
|
-
|
286
|
-
spec =
|
287
|
+
relatives = path.split('/')
|
288
|
+
spec = nil
|
289
|
+
while spec.nil? && !relatives.empty?
|
290
|
+
name = relatives.join('-')
|
291
|
+
spec = Gem::Specification.find_by_name(name, @gemset[name])
|
292
|
+
relatives.pop
|
293
|
+
end
|
294
|
+
raise Gem::LoadError if spec.nil?
|
287
295
|
|
288
296
|
# Avoid loading the spec again if it's going to be skipped anyway
|
289
297
|
return spec if @source_gems.include?(spec.name)
|
290
298
|
# Avoid loading the spec again if it's already the correct version
|
291
|
-
if @gemset[spec.name] && @gemset[spec.name]
|
299
|
+
if @gemset[spec.name] && spec.version != @gemset[spec.name]
|
292
300
|
begin
|
293
301
|
return Gem::Specification.find_by_name(spec.name, "= #{@gemset[spec.name]}")
|
294
302
|
rescue Gem::LoadError
|
data/solargraph.gemspec
CHANGED
@@ -27,13 +27,15 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency 'benchmark'
|
28
28
|
s.add_runtime_dependency 'bundler', '~> 2.0'
|
29
29
|
s.add_runtime_dependency 'diff-lcs', '~> 1.4'
|
30
|
-
s.add_runtime_dependency '
|
31
|
-
s.add_runtime_dependency 'jaro_winkler', '~> 1.5'
|
30
|
+
s.add_runtime_dependency 'jaro_winkler', '~> 1.6'
|
32
31
|
s.add_runtime_dependency 'kramdown', '~> 2.3'
|
33
32
|
s.add_runtime_dependency 'kramdown-parser-gfm', '~> 1.1'
|
33
|
+
s.add_runtime_dependency 'logger', '~> 1.6'
|
34
|
+
s.add_runtime_dependency 'observer', '~> 0.1'
|
35
|
+
s.add_runtime_dependency 'ostruct', '~> 0.6'
|
34
36
|
s.add_runtime_dependency 'parser', '~> 3.0'
|
35
|
-
s.add_runtime_dependency 'rbs', '~>
|
36
|
-
s.add_runtime_dependency 'reverse_markdown', '
|
37
|
+
s.add_runtime_dependency 'rbs', '~> 3.0'
|
38
|
+
s.add_runtime_dependency 'reverse_markdown', '>= 2.0', '< 4'
|
37
39
|
s.add_runtime_dependency 'rubocop', '~> 1.38'
|
38
40
|
s.add_runtime_dependency 'thor', '~> 1.0'
|
39
41
|
s.add_runtime_dependency 'tilt', '~> 2.0'
|
@@ -41,6 +43,7 @@ Gem::Specification.new do |s|
|
|
41
43
|
|
42
44
|
s.add_development_dependency 'pry'
|
43
45
|
s.add_development_dependency 'public_suffix', '~> 3.1'
|
46
|
+
s.add_development_dependency 'rake', '~> 13.2'
|
44
47
|
s.add_development_dependency 'rspec', '~> 3.5'
|
45
48
|
s.add_development_dependency 'simplecov', '~> 0.14'
|
46
49
|
s.add_development_dependency 'webmock', '~> 3.6'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.51.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -67,61 +67,89 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: jaro_winkler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.6'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: kramdown
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.3'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.3'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: kramdown
|
98
|
+
name: kramdown-parser-gfm
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1.1'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1.1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: logger
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
117
|
+
version: '1.6'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
124
|
+
version: '1.6'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: observer
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.1'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: ostruct
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.6'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.6'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: parser
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +170,34 @@ dependencies:
|
|
142
170
|
requirements:
|
143
171
|
- - "~>"
|
144
172
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
173
|
+
version: '3.0'
|
146
174
|
type: :runtime
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
178
|
- - "~>"
|
151
179
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
180
|
+
version: '3.0'
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: reverse_markdown
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
156
184
|
requirements:
|
157
|
-
- - "
|
185
|
+
- - ">="
|
158
186
|
- !ruby/object:Gem::Version
|
159
187
|
version: '2.0'
|
188
|
+
- - "<"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '4'
|
160
191
|
type: :runtime
|
161
192
|
prerelease: false
|
162
193
|
version_requirements: !ruby/object:Gem::Requirement
|
163
194
|
requirements:
|
164
|
-
- - "
|
195
|
+
- - ">="
|
165
196
|
- !ruby/object:Gem::Version
|
166
197
|
version: '2.0'
|
198
|
+
- - "<"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '4'
|
167
201
|
- !ruby/object:Gem::Dependency
|
168
202
|
name: rubocop
|
169
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,6 +288,20 @@ dependencies:
|
|
254
288
|
- - "~>"
|
255
289
|
- !ruby/object:Gem::Version
|
256
290
|
version: '3.1'
|
291
|
+
- !ruby/object:Gem::Dependency
|
292
|
+
name: rake
|
293
|
+
requirement: !ruby/object:Gem::Requirement
|
294
|
+
requirements:
|
295
|
+
- - "~>"
|
296
|
+
- !ruby/object:Gem::Version
|
297
|
+
version: '13.2'
|
298
|
+
type: :development
|
299
|
+
prerelease: false
|
300
|
+
version_requirements: !ruby/object:Gem::Requirement
|
301
|
+
requirements:
|
302
|
+
- - "~>"
|
303
|
+
- !ruby/object:Gem::Version
|
304
|
+
version: '13.2'
|
257
305
|
- !ruby/object:Gem::Dependency
|
258
306
|
name: rspec
|
259
307
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,7 +380,6 @@ files:
|
|
332
380
|
- lib/solargraph/convention/gemfile.rb
|
333
381
|
- lib/solargraph/convention/gemspec.rb
|
334
382
|
- lib/solargraph/convention/rakefile.rb
|
335
|
-
- lib/solargraph/convention/rspec.rb
|
336
383
|
- lib/solargraph/converters/dd.rb
|
337
384
|
- lib/solargraph/converters/dl.rb
|
338
385
|
- lib/solargraph/converters/dt.rb
|
@@ -395,6 +442,7 @@ files:
|
|
395
442
|
- lib/solargraph/language_server/message/text_document/references.rb
|
396
443
|
- lib/solargraph/language_server/message/text_document/rename.rb
|
397
444
|
- lib/solargraph/language_server/message/text_document/signature_help.rb
|
445
|
+
- lib/solargraph/language_server/message/text_document/type_definition.rb
|
398
446
|
- lib/solargraph/language_server/message/workspace.rb
|
399
447
|
- lib/solargraph/language_server/message/workspace/did_change_configuration.rb
|
400
448
|
- lib/solargraph/language_server/message/workspace/did_change_watched_files.rb
|
@@ -477,6 +525,7 @@ files:
|
|
477
525
|
- lib/solargraph/pin/common.rb
|
478
526
|
- lib/solargraph/pin/constant.rb
|
479
527
|
- lib/solargraph/pin/conversions.rb
|
528
|
+
- lib/solargraph/pin/delegated_method.rb
|
480
529
|
- lib/solargraph/pin/documenting.rb
|
481
530
|
- lib/solargraph/pin/duck_method.rb
|
482
531
|
- lib/solargraph/pin/global_variable.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
module Convention
|
5
|
-
class Rspec < Base
|
6
|
-
def local source_map
|
7
|
-
return EMPTY_ENVIRON unless File.basename(source_map.filename) =~ /_spec\.rb$/
|
8
|
-
@environ ||= Environ.new(
|
9
|
-
requires: ['rspec'],
|
10
|
-
domains: ['RSpec::Matchers', 'RSpec::ExpectationGroups'],
|
11
|
-
pins: [
|
12
|
-
# This override is necessary due to an erroneous @return tag in
|
13
|
-
# rspec's YARD documentation.
|
14
|
-
# @todo The return types have been fixed (https://github.com/rspec/rspec-expectations/pull/1121)
|
15
|
-
Solargraph::Pin::Reference::Override.method_return('RSpec::Matchers#expect', 'RSpec::Expectations::ExpectationTarget')
|
16
|
-
].concat(extras)
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def extras
|
23
|
-
@@extras ||= SourceMap.load_string(%(
|
24
|
-
def describe(*args); end
|
25
|
-
def it(*args); end
|
26
|
-
)).pins
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|