solargraph 0.57.0 → 0.58.1
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 +4 -4
- data/.gitattributes +2 -0
- data/.github/workflows/linting.yml +4 -2
- data/.github/workflows/plugins.yml +61 -27
- data/.github/workflows/rspec.yml +19 -4
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +90 -1438
- data/CHANGELOG.md +30 -0
- data/Rakefile +1 -1
- data/bin/solargraph +3 -0
- data/lib/solargraph/api_map/constants.rb +107 -46
- data/lib/solargraph/api_map/index.rb +32 -8
- data/lib/solargraph/api_map/source_to_yard.rb +5 -2
- data/lib/solargraph/api_map/store.rb +22 -12
- data/lib/solargraph/api_map.rb +27 -33
- data/lib/solargraph/complex_type/type_methods.rb +5 -0
- data/lib/solargraph/complex_type/unique_type.rb +12 -5
- data/lib/solargraph/complex_type.rb +19 -2
- data/lib/solargraph/convention/active_support_concern.rb +1 -1
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +1 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -2
- data/lib/solargraph/doc_map.rb +9 -6
- data/lib/solargraph/environ.rb +1 -1
- data/lib/solargraph/equality.rb +1 -0
- data/lib/solargraph/gem_pins.rb +4 -0
- data/lib/solargraph/language_server/host.rb +10 -4
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -2
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +1 -1
- data/lib/solargraph/language_server/progress.rb +1 -1
- data/lib/solargraph/language_server/request.rb +3 -1
- data/lib/solargraph/library.rb +3 -3
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/page.rb +0 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +1 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +2 -12
- data/lib/solargraph/parser/parser_gem/node_methods.rb +1 -14
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +64 -8
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +12 -3
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +4 -5
- data/lib/solargraph/pin/base.rb +29 -8
- data/lib/solargraph/pin/base_variable.rb +5 -3
- data/lib/solargraph/pin/block.rb +3 -2
- data/lib/solargraph/pin/callable.rb +6 -2
- data/lib/solargraph/pin/closure.rb +3 -7
- data/lib/solargraph/pin/delegated_method.rb +0 -1
- data/lib/solargraph/pin/local_variable.rb +0 -4
- data/lib/solargraph/pin/method.rb +20 -4
- data/lib/solargraph/pin/parameter.rb +6 -2
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference.rb +2 -11
- data/lib/solargraph/pin/search.rb +3 -0
- data/lib/solargraph/pin_cache.rb +5 -5
- data/lib/solargraph/position.rb +1 -0
- data/lib/solargraph/range.rb +4 -0
- data/lib/solargraph/rbs_map/conversions.rb +22 -1
- data/lib/solargraph/rbs_map/core_fills.rb +18 -0
- data/lib/solargraph/rbs_map/core_map.rb +11 -7
- data/lib/solargraph/rbs_map.rb +2 -2
- data/lib/solargraph/shell.rb +82 -1
- data/lib/solargraph/source/chain/call.rb +7 -3
- data/lib/solargraph/source/chain/constant.rb +3 -66
- data/lib/solargraph/source/chain/if.rb +1 -1
- data/lib/solargraph/source/chain/link.rb +1 -1
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +2 -0
- data/lib/solargraph/source/encoding_fixes.rb +23 -23
- data/lib/solargraph/source.rb +1 -1
- data/lib/solargraph/source_map/clip.rb +17 -25
- data/lib/solargraph/source_map/mapper.rb +0 -2
- data/lib/solargraph/source_map.rb +8 -3
- data/lib/solargraph/type_checker/rules.rb +23 -9
- data/lib/solargraph/type_checker.rb +133 -71
- data/lib/solargraph/version.rb +5 -5
- data/lib/solargraph/workspace/config.rb +21 -3
- data/lib/solargraph/workspace/require_paths.rb +0 -1
- data/lib/solargraph/workspace.rb +14 -19
- data/lib/solargraph/yard_map/mapper/to_method.rb +2 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -0
- data/lib/solargraph/yard_map/to_method.rb +2 -1
- data/lib/solargraph/yardoc.rb +27 -4
- data/rbs/fills/bundler/0/bundler.rbs +4271 -0
- data/rbs/fills/open3/0/open3.rbs +172 -0
- data/rbs/fills/rubygems/0/basic_specification.rbs +326 -0
- data/rbs/fills/rubygems/0/errors.rbs +364 -0
- data/rbs/fills/rubygems/0/spec_fetcher.rbs +107 -0
- data/rbs/fills/rubygems/0/specification.rbs +1753 -0
- data/rbs_collection.yaml +4 -4
- data/sig/shims/ast/0/node.rbs +5 -0
- data/sig/shims/ast/2.4/.rbs_meta.yaml +9 -0
- data/sig/shims/ast/2.4/ast.rbs +73 -0
- data/sig/shims/parser/3.2.0.1/manifest.yaml +7 -0
- data/sig/shims/parser/3.2.0.1/parser.rbs +201 -0
- data/sig/shims/parser/3.2.0.1/polyfill.rbs +4 -0
- data/solargraph.gemspec +15 -4
- metadata +67 -12
- data/lib/solargraph/parser/node_methods.rb +0 -97
- /data/rbs/fills/{tuple.rbs → tuple/tuple.rbs} +0 -0
data/lib/solargraph/workspace.rb
CHANGED
|
@@ -19,11 +19,17 @@ module Solargraph
|
|
|
19
19
|
attr_reader :gemnames
|
|
20
20
|
alias source_gems gemnames
|
|
21
21
|
|
|
22
|
-
# @param directory [String]
|
|
22
|
+
# @param directory [String] TODO: Remove '' and '*' special cases
|
|
23
23
|
# @param config [Config, nil]
|
|
24
24
|
# @param server [Hash]
|
|
25
25
|
def initialize directory = '', config = nil, server = {}
|
|
26
|
-
|
|
26
|
+
raise ArgumentError, 'directory must be a String' unless directory.is_a?(String)
|
|
27
|
+
|
|
28
|
+
@directory = if ['*', ''].include?(directory)
|
|
29
|
+
directory
|
|
30
|
+
else
|
|
31
|
+
File.absolute_path(directory)
|
|
32
|
+
end
|
|
27
33
|
@config = config
|
|
28
34
|
@server = server
|
|
29
35
|
load_sources
|
|
@@ -44,6 +50,12 @@ module Solargraph
|
|
|
44
50
|
@config ||= Solargraph::Workspace::Config.new(directory)
|
|
45
51
|
end
|
|
46
52
|
|
|
53
|
+
# @param level [Symbol]
|
|
54
|
+
# @return [TypeChecker::Rules]
|
|
55
|
+
def rules(level)
|
|
56
|
+
@rules ||= TypeChecker::Rules.new(level, config.type_checker_rules)
|
|
57
|
+
end
|
|
58
|
+
|
|
47
59
|
# Merge the source. A merge will update the existing source for the file
|
|
48
60
|
# or add it to the sources if the workspace is configured to include it.
|
|
49
61
|
# The source is ignored if the configuration excludes it.
|
|
@@ -114,23 +126,6 @@ module Solargraph
|
|
|
114
126
|
false
|
|
115
127
|
end
|
|
116
128
|
|
|
117
|
-
# True if the workspace contains at least one gemspec file.
|
|
118
|
-
#
|
|
119
|
-
# @return [Boolean]
|
|
120
|
-
def gemspec?
|
|
121
|
-
!gemspecs.empty?
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Get an array of all gemspec files in the workspace.
|
|
125
|
-
#
|
|
126
|
-
# @return [Array<String>]
|
|
127
|
-
def gemspecs
|
|
128
|
-
return [] if directory.empty? || directory == '*'
|
|
129
|
-
@gemspecs ||= Dir[File.join(directory, '**/*.gemspec')].select do |gs|
|
|
130
|
-
config.allow? gs
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
129
|
# @return [String, nil]
|
|
135
130
|
def rbs_collection_path
|
|
136
131
|
@gem_rbs_collection ||= read_rbs_collection_path
|
|
@@ -11,7 +11,7 @@ module Solargraph
|
|
|
11
11
|
["Rails::Engine", :class, "find_root_with_flag"] => :public
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
# @param code_object [YARD::CodeObjects::
|
|
14
|
+
# @param code_object [YARD::CodeObjects::MethodObject]
|
|
15
15
|
# @param name [String, nil]
|
|
16
16
|
# @param scope [Symbol, nil]
|
|
17
17
|
# @param visibility [Symbol, nil]
|
|
@@ -85,6 +85,7 @@ module Solargraph
|
|
|
85
85
|
# HACK: Skip `nil` and `self` parameters that are sometimes emitted
|
|
86
86
|
# for methods defined in C
|
|
87
87
|
# See https://github.com/castwide/solargraph/issues/345
|
|
88
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
88
89
|
code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
|
|
89
90
|
Solargraph::Pin::Parameter.new(
|
|
90
91
|
location: location,
|
|
@@ -15,6 +15,7 @@ module Solargraph
|
|
|
15
15
|
# HACK: Skip `nil` and `self` parameters that are sometimes emitted
|
|
16
16
|
# for methods defined in C
|
|
17
17
|
# See https://github.com/castwide/solargraph/issues/345
|
|
18
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
18
19
|
code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
|
|
19
20
|
Solargraph::Pin::Parameter.new(
|
|
20
21
|
location: location,
|
|
@@ -57,7 +58,7 @@ module Solargraph
|
|
|
57
58
|
|
|
58
59
|
include Helpers
|
|
59
60
|
|
|
60
|
-
# @param code_object [YARD::CodeObjects::
|
|
61
|
+
# @param code_object [YARD::CodeObjects::MethodObject]
|
|
61
62
|
# @param name [String, nil]
|
|
62
63
|
# @param scope [Symbol, nil]
|
|
63
64
|
# @param visibility [Symbol, nil]
|
data/lib/solargraph/yardoc.rb
CHANGED
|
@@ -18,15 +18,21 @@ module Solargraph
|
|
|
18
18
|
path = PinCache.yardoc_path gemspec
|
|
19
19
|
return path if cached?(gemspec)
|
|
20
20
|
|
|
21
|
+
unless Dir.exist? gemspec.gem_dir
|
|
22
|
+
# Can happen in at least some (old?) RubyGems versions when we
|
|
23
|
+
# have a gemspec describing a standard library like bundler.
|
|
24
|
+
#
|
|
25
|
+
# https://github.com/apiology/solargraph/actions/runs/17650140201/job/50158676842?pr=10
|
|
26
|
+
Solargraph.logger.info { "Bad info from gemspec - #{gemspec.gem_dir} does not exist" }
|
|
27
|
+
return path
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
|
|
22
31
|
cmd = "yardoc --db #{path} --no-output --plugin solargraph"
|
|
23
32
|
yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" }
|
|
24
33
|
Solargraph.logger.debug { "Running: #{cmd}" }
|
|
25
34
|
# @todo set these up to run in parallel
|
|
26
|
-
|
|
27
|
-
# @sg-ignore RBS gem doesn't reflect that Open3.* also include
|
|
28
|
-
# kwopts from Process.spawn()
|
|
29
|
-
stdout_and_stderr_str, status = Open3.capture2e(cmd, chdir: gemspec.gem_dir)
|
|
35
|
+
stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir)
|
|
30
36
|
unless status.success?
|
|
31
37
|
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" }
|
|
32
38
|
Solargraph.logger.info stdout_and_stderr_str
|
|
@@ -60,5 +66,22 @@ module Solargraph
|
|
|
60
66
|
YARD::Registry.load! PinCache.yardoc_path gemspec
|
|
61
67
|
YARD::Registry.all
|
|
62
68
|
end
|
|
69
|
+
|
|
70
|
+
# If the BUNDLE_GEMFILE environment variable is set, we need to
|
|
71
|
+
# make sure it's an absolute path, as we'll be changing
|
|
72
|
+
# directories.
|
|
73
|
+
#
|
|
74
|
+
# 'bundle exec' sets an absolute path here, but at least the
|
|
75
|
+
# overcommit gem does not, breaking on-the-fly documention with a
|
|
76
|
+
# spawned yardoc command from our current bundle
|
|
77
|
+
#
|
|
78
|
+
# @return [Hash{String => String}] a hash of environment variables to override
|
|
79
|
+
def current_bundle_env_tweaks
|
|
80
|
+
tweaks = {}
|
|
81
|
+
if ENV['BUNDLE_GEMFILE'] && !ENV['BUNDLE_GEMFILE'].empty?
|
|
82
|
+
tweaks['BUNDLE_GEMFILE'] = File.expand_path(ENV['BUNDLE_GEMFILE'])
|
|
83
|
+
end
|
|
84
|
+
tweaks
|
|
85
|
+
end
|
|
63
86
|
end
|
|
64
87
|
end
|