solargraph 0.56.0 → 0.57.0
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/.github/workflows/linting.yml +125 -0
- data/.github/workflows/plugins.yml +148 -6
- data/.github/workflows/rspec.yml +39 -4
- data/.github/workflows/typecheck.yml +5 -2
- data/.gitignore +5 -0
- data/.overcommit.yml +72 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +2627 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +56 -1
- data/README.md +8 -4
- data/Rakefile +125 -13
- data/lib/solargraph/api_map/cache.rb +3 -2
- data/lib/solargraph/api_map/constants.rb +218 -0
- data/lib/solargraph/api_map/index.rb +20 -26
- data/lib/solargraph/api_map/source_to_yard.rb +10 -4
- data/lib/solargraph/api_map/store.rb +126 -18
- data/lib/solargraph/api_map.rb +212 -234
- data/lib/solargraph/bench.rb +1 -0
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +7 -7
- data/lib/solargraph/complex_type.rb +5 -1
- data/lib/solargraph/convention/active_support_concern.rb +111 -0
- data/lib/solargraph/convention/base.rb +17 -0
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -0
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +91 -0
- data/lib/solargraph/convention/data_definition.rb +105 -0
- data/lib/solargraph/convention/gemspec.rb +3 -2
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +4 -2
- data/lib/solargraph/convention/struct_definition.rb +87 -24
- data/lib/solargraph/convention.rb +32 -2
- data/lib/solargraph/diagnostics/rubocop.rb +6 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -1
- data/lib/solargraph/doc_map.rb +48 -17
- data/lib/solargraph/environ.rb +9 -2
- data/lib/solargraph/gem_pins.rb +17 -11
- data/lib/solargraph/language_server/host/dispatch.rb +2 -0
- data/lib/solargraph/language_server/host/message_worker.rb +3 -0
- data/lib/solargraph/language_server/host.rb +2 -1
- data/lib/solargraph/language_server/message/base.rb +2 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +16 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +1 -0
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +2 -0
- data/lib/solargraph/language_server/progress.rb +8 -0
- data/lib/solargraph/language_server/request.rb +1 -0
- data/lib/solargraph/library.rb +47 -30
- data/lib/solargraph/location.rb +2 -0
- data/lib/solargraph/logging.rb +11 -2
- data/lib/solargraph/page.rb +4 -0
- data/lib/solargraph/parser/comment_ripper.rb +8 -1
- data/lib/solargraph/parser/flow_sensitive_typing.rb +32 -4
- data/lib/solargraph/parser/node_methods.rb +2 -2
- data/lib/solargraph/parser/node_processor/base.rb +10 -5
- data/lib/solargraph/parser/node_processor.rb +24 -8
- data/lib/solargraph/parser/parser_gem/class_methods.rb +1 -1
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_methods.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +1 -21
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +2 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +7 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +0 -22
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +35 -14
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/region.rb +3 -0
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/pin/base.rb +65 -8
- data/lib/solargraph/pin/base_variable.rb +1 -2
- data/lib/solargraph/pin/callable.rb +9 -0
- data/lib/solargraph/pin/closure.rb +2 -0
- data/lib/solargraph/pin/common.rb +6 -2
- data/lib/solargraph/pin/constant.rb +2 -0
- data/lib/solargraph/pin/delegated_method.rb +1 -0
- data/lib/solargraph/pin/local_variable.rb +4 -1
- data/lib/solargraph/pin/method.rb +12 -7
- data/lib/solargraph/pin/method_alias.rb +3 -0
- data/lib/solargraph/pin/parameter.rb +18 -8
- data/lib/solargraph/pin/proxy_type.rb +1 -0
- data/lib/solargraph/pin/reference/override.rb +15 -1
- data/lib/solargraph/pin/reference/superclass.rb +5 -0
- data/lib/solargraph/pin/reference.rb +26 -0
- data/lib/solargraph/pin/search.rb +3 -1
- data/lib/solargraph/pin/signature.rb +2 -0
- data/lib/solargraph/pin/symbol.rb +5 -0
- data/lib/solargraph/pin_cache.rb +64 -4
- data/lib/solargraph/position.rb +2 -0
- data/lib/solargraph/range.rb +1 -0
- data/lib/solargraph/rbs_map/conversions.rb +47 -18
- data/lib/solargraph/rbs_map/core_map.rb +3 -0
- data/lib/solargraph/rbs_map.rb +15 -2
- data/lib/solargraph/shell.rb +3 -0
- data/lib/solargraph/source/chain/link.rb +10 -1
- data/lib/solargraph/source/chain.rb +9 -2
- data/lib/solargraph/source/change.rb +2 -2
- data/lib/solargraph/source/cursor.rb +2 -3
- data/lib/solargraph/source/source_chainer.rb +1 -1
- data/lib/solargraph/source.rb +5 -2
- data/lib/solargraph/source_map/clip.rb +1 -1
- data/lib/solargraph/source_map/data.rb +4 -0
- data/lib/solargraph/source_map/mapper.rb +4 -2
- data/lib/solargraph/source_map.rb +21 -14
- data/lib/solargraph/type_checker/param_def.rb +2 -0
- data/lib/solargraph/type_checker/rules.rb +8 -0
- data/lib/solargraph/type_checker.rb +173 -120
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +1 -3
- data/lib/solargraph/workspace/require_paths.rb +98 -0
- data/lib/solargraph/workspace.rb +24 -48
- data/lib/solargraph/yard_map/helpers.rb +29 -1
- data/lib/solargraph/yard_map/mapper/to_constant.rb +5 -5
- data/lib/solargraph/yard_map/mapper/to_method.rb +3 -8
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +7 -7
- data/lib/solargraph/yardoc.rb +18 -3
- data/lib/solargraph.rb +15 -0
- data/rbs/fills/tuple.rbs +2 -3
- data/sig/shims/parser/3.2.0.1/builders/default.rbs +195 -0
- data/sig/shims/thor/1.2.0.1/.rbs_meta.yaml +9 -0
- data/sig/shims/thor/1.2.0.1/manifest.yaml +7 -0
- data/sig/shims/thor/1.2.0.1/thor.rbs +17 -0
- data/solargraph.gemspec +14 -4
- metadata +128 -11
- data/lib/.rubocop.yml +0 -22
data/lib/solargraph/workspace.rb
CHANGED
@@ -10,15 +10,11 @@ module Solargraph
|
|
10
10
|
#
|
11
11
|
class Workspace
|
12
12
|
autoload :Config, 'solargraph/workspace/config'
|
13
|
+
autoload :RequirePaths, 'solargraph/workspace/require_paths'
|
13
14
|
|
14
15
|
# @return [String]
|
15
16
|
attr_reader :directory
|
16
17
|
|
17
|
-
# The require paths associated with the workspace.
|
18
|
-
#
|
19
|
-
# @return [Array<String>]
|
20
|
-
attr_reader :require_paths
|
21
|
-
|
22
18
|
# @return [Array<String>]
|
23
19
|
attr_reader :gemnames
|
24
20
|
alias source_gems gemnames
|
@@ -32,10 +28,17 @@ module Solargraph
|
|
32
28
|
@server = server
|
33
29
|
load_sources
|
34
30
|
@gemnames = []
|
35
|
-
@require_paths = generate_require_paths
|
36
31
|
require_plugins
|
37
32
|
end
|
38
33
|
|
34
|
+
# The require paths associated with the workspace.
|
35
|
+
#
|
36
|
+
# @return [Array<String>]
|
37
|
+
def require_paths
|
38
|
+
# @todo are the semantics of '*' the same as '', meaning 'don't send back any require paths'?
|
39
|
+
@require_paths ||= RequirePaths.new(directory_or_nil, config).generate
|
40
|
+
end
|
41
|
+
|
39
42
|
# @return [Solargraph::Workspace::Config]
|
40
43
|
def config
|
41
44
|
@config ||= Solargraph::Workspace::Config.new(directory)
|
@@ -133,6 +136,7 @@ module Solargraph
|
|
133
136
|
@gem_rbs_collection ||= read_rbs_collection_path
|
134
137
|
end
|
135
138
|
|
139
|
+
# @return [String, nil]
|
136
140
|
def rbs_collection_config_path
|
137
141
|
@rbs_collection_config_path ||= begin
|
138
142
|
unless directory.empty? || directory == '*'
|
@@ -155,6 +159,20 @@ module Solargraph
|
|
155
159
|
server['commandPath'] || 'solargraph'
|
156
160
|
end
|
157
161
|
|
162
|
+
# @return [String, nil]
|
163
|
+
def directory_or_nil
|
164
|
+
return nil if directory.empty? || directory == '*'
|
165
|
+
directory
|
166
|
+
end
|
167
|
+
|
168
|
+
# True if the workspace has a root Gemfile.
|
169
|
+
#
|
170
|
+
# @todo Handle projects with custom Bundler/Gemfile setups (see DocMap#gemspecs_required_from_bundler)
|
171
|
+
#
|
172
|
+
def gemfile?
|
173
|
+
directory && File.file?(File.join(directory, 'Gemfile'))
|
174
|
+
end
|
175
|
+
|
158
176
|
private
|
159
177
|
|
160
178
|
# The language server configuration (or an empty hash if the workspace was
|
@@ -184,48 +202,6 @@ module Solargraph
|
|
184
202
|
end
|
185
203
|
end
|
186
204
|
|
187
|
-
# Generate require paths from gemspecs if they exist or assume the default
|
188
|
-
# lib directory.
|
189
|
-
#
|
190
|
-
# @return [Array<String>]
|
191
|
-
def generate_require_paths
|
192
|
-
return configured_require_paths unless gemspec?
|
193
|
-
result = []
|
194
|
-
gemspecs.each do |file|
|
195
|
-
base = File.dirname(file)
|
196
|
-
# HACK: Evaluating gemspec files violates the goal of not running
|
197
|
-
# workspace code, but this is how Gem::Specification.load does it
|
198
|
-
# anyway.
|
199
|
-
cmd = ['ruby', '-e', "require 'rubygems'; require 'json'; spec = eval(File.read('#{file}'), TOPLEVEL_BINDING, '#{file}'); return unless Gem::Specification === spec; puts({name: spec.name, paths: spec.require_paths}.to_json)"]
|
200
|
-
o, e, s = Open3.capture3(*cmd)
|
201
|
-
if s.success?
|
202
|
-
begin
|
203
|
-
hash = o && !o.empty? ? JSON.parse(o.split("\n").last) : {}
|
204
|
-
next if hash.empty?
|
205
|
-
@gemnames.push hash['name']
|
206
|
-
result.concat(hash['paths'].map { |path| File.join(base, path) })
|
207
|
-
rescue StandardError => e
|
208
|
-
Solargraph.logger.warn "Error reading #{file}: [#{e.class}] #{e.message}"
|
209
|
-
end
|
210
|
-
else
|
211
|
-
Solargraph.logger.warn "Error reading #{file}"
|
212
|
-
Solargraph.logger.warn e
|
213
|
-
end
|
214
|
-
end
|
215
|
-
result.concat(config.require_paths.map { |p| File.join(directory, p) })
|
216
|
-
result.push File.join(directory, 'lib') if result.empty?
|
217
|
-
result
|
218
|
-
end
|
219
|
-
|
220
|
-
# Get additional require paths defined in the configuration.
|
221
|
-
#
|
222
|
-
# @return [Array<String>]
|
223
|
-
def configured_require_paths
|
224
|
-
return ['lib'] if directory.empty?
|
225
|
-
return [File.join(directory, 'lib')] if config.require_paths.empty?
|
226
|
-
config.require_paths.map { |p| File.join(directory, p) }
|
227
|
-
end
|
228
|
-
|
229
205
|
# @return [void]
|
230
206
|
def require_plugins
|
231
207
|
config.plugins.each do |plugin|
|
@@ -7,10 +7,38 @@ module Solargraph
|
|
7
7
|
# @param spec [Gem::Specification, nil]
|
8
8
|
# @return [Solargraph::Location, nil]
|
9
9
|
def object_location code_object, spec
|
10
|
-
|
10
|
+
if spec.nil? || code_object.nil? || code_object.file.nil? || code_object.line.nil?
|
11
|
+
if code_object.namespace.is_a?(YARD::CodeObjects::NamespaceObject)
|
12
|
+
# If the code object is a namespace, use the namespace's location
|
13
|
+
return object_location(code_object.namespace, spec)
|
14
|
+
end
|
15
|
+
return Solargraph::Location.new(__FILE__, Solargraph::Range.from_to(__LINE__ - 1, 0, __LINE__ - 1, 0))
|
16
|
+
end
|
11
17
|
file = File.join(spec.full_gem_path, code_object.file)
|
12
18
|
Solargraph::Location.new(file, Solargraph::Range.from_to(code_object.line - 1, 0, code_object.line - 1, 0))
|
13
19
|
end
|
20
|
+
|
21
|
+
# @param code_object [YARD::CodeObjects::Base]
|
22
|
+
# @param spec [Gem::Specification, nil]
|
23
|
+
# @return [Solargraph::Pin::Namespace]
|
24
|
+
def create_closure_namespace_for(code_object, spec)
|
25
|
+
code_object_for_location = code_object
|
26
|
+
# code_object.namespace is sometimes a YARD proxy object pointing to a method path ("Object#new")
|
27
|
+
code_object_for_location = code_object.namespace if code_object.namespace.is_a?(YARD::CodeObjects::NamespaceObject)
|
28
|
+
namespace_location = object_location(code_object_for_location, spec)
|
29
|
+
ns_name = code_object.namespace.to_s
|
30
|
+
if ns_name.empty?
|
31
|
+
Solargraph::Pin::ROOT_PIN
|
32
|
+
else
|
33
|
+
Solargraph::Pin::Namespace.new(
|
34
|
+
name: ns_name,
|
35
|
+
closure: Pin::ROOT_PIN,
|
36
|
+
gates: [code_object.namespace.to_s],
|
37
|
+
source: :yardoc,
|
38
|
+
location: namespace_location
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
14
42
|
end
|
15
43
|
end
|
16
44
|
end
|
@@ -7,12 +7,12 @@ module Solargraph
|
|
7
7
|
extend YardMap::Helpers
|
8
8
|
|
9
9
|
# @param code_object [YARD::CodeObjects::Base]
|
10
|
+
# @param closure [Pin::Closure, nil]
|
11
|
+
# @param spec [Gem::Specification, nil]
|
12
|
+
# @return [Pin::Constant]
|
10
13
|
def self.make code_object, closure = nil, spec = nil
|
11
|
-
closure ||=
|
12
|
-
|
13
|
-
gates: [code_object.namespace.to_s],
|
14
|
-
source: :yardoc,
|
15
|
-
)
|
14
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
15
|
+
|
16
16
|
Pin::Constant.new(
|
17
17
|
location: object_location(code_object, spec),
|
18
18
|
closure: closure,
|
@@ -19,12 +19,7 @@ module Solargraph
|
|
19
19
|
# @param spec [Gem::Specification, nil]
|
20
20
|
# @return [Solargraph::Pin::Method]
|
21
21
|
def self.make code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
22
|
-
closure ||=
|
23
|
-
name: code_object.namespace.to_s,
|
24
|
-
gates: [code_object.namespace.to_s],
|
25
|
-
type: code_object.namespace.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
26
|
-
source: :yardoc,
|
27
|
-
)
|
22
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
28
23
|
location = object_location(code_object, spec)
|
29
24
|
name ||= code_object.name.to_s
|
30
25
|
return_type = ComplexType::SELF if name == 'new'
|
@@ -32,8 +27,8 @@ module Solargraph
|
|
32
27
|
final_scope = scope || code_object.scope
|
33
28
|
override_key = [closure.path, final_scope, name]
|
34
29
|
final_visibility = VISIBILITY_OVERRIDE[override_key]
|
35
|
-
final_visibility ||= VISIBILITY_OVERRIDE[
|
36
|
-
final_visibility ||= :private if closure.path == 'Kernel' && Kernel.private_instance_methods(false).include?(name)
|
30
|
+
final_visibility ||= VISIBILITY_OVERRIDE[[closure.path, final_scope]]
|
31
|
+
final_visibility ||= :private if closure.path == 'Kernel' && Kernel.private_instance_methods(false).include?(name.to_sym)
|
37
32
|
final_visibility ||= visibility
|
38
33
|
final_visibility ||= :private if code_object.module_function? && final_scope == :instance
|
39
34
|
final_visibility ||= :public if code_object.module_function? && final_scope == :class
|
@@ -7,15 +7,15 @@ module Solargraph
|
|
7
7
|
extend YardMap::Helpers
|
8
8
|
|
9
9
|
# @param code_object [YARD::CodeObjects::NamespaceObject]
|
10
|
+
# @param spec [Gem::Specification, nil]
|
11
|
+
# @param closure [Pin::Closure, nil]
|
12
|
+
# @return [Pin::Namespace]
|
10
13
|
def self.make code_object, spec, closure = nil
|
11
|
-
closure ||=
|
12
|
-
|
13
|
-
|
14
|
-
gates: [code_object.namespace.to_s],
|
15
|
-
source: :yardoc,
|
16
|
-
)
|
14
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
15
|
+
location = object_location(code_object, spec)
|
16
|
+
|
17
17
|
Pin::Namespace.new(
|
18
|
-
location:
|
18
|
+
location: location,
|
19
19
|
name: code_object.name.to_s,
|
20
20
|
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
21
21
|
type: code_object.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
data/lib/solargraph/yardoc.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'open3'
|
4
|
+
|
3
5
|
module Solargraph
|
4
6
|
# Methods for caching and loading YARD documentation for gems.
|
5
7
|
#
|
@@ -9,15 +11,25 @@ module Solargraph
|
|
9
11
|
# Build and cache a gem's yardoc and return the path. If the cache already
|
10
12
|
# exists, do nothing and return the path.
|
11
13
|
#
|
14
|
+
# @param yard_plugins [Array<String>] The names of YARD plugins to use.
|
12
15
|
# @param gemspec [Gem::Specification]
|
13
16
|
# @return [String] The path to the cached yardoc.
|
14
|
-
def cache(gemspec)
|
17
|
+
def cache(yard_plugins, gemspec)
|
15
18
|
path = PinCache.yardoc_path gemspec
|
16
19
|
return path if cached?(gemspec)
|
17
20
|
|
18
21
|
Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
|
19
|
-
|
20
|
-
|
22
|
+
cmd = "yardoc --db #{path} --no-output --plugin solargraph"
|
23
|
+
yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" }
|
24
|
+
Solargraph.logger.debug { "Running: #{cmd}" }
|
25
|
+
# @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)
|
30
|
+
unless status.success?
|
31
|
+
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" }
|
32
|
+
Solargraph.logger.info stdout_and_stderr_str
|
21
33
|
end
|
22
34
|
path
|
23
35
|
end
|
@@ -30,6 +42,9 @@ module Solargraph
|
|
30
42
|
File.exist?(yardoc)
|
31
43
|
end
|
32
44
|
|
45
|
+
# True if another process is currently building the yardoc cache.
|
46
|
+
#
|
47
|
+
# @param gemspec [Gem::Specification]
|
33
48
|
def processing?(gemspec)
|
34
49
|
yardoc = File.join(PinCache.yardoc_path(gemspec), 'processing')
|
35
50
|
File.exist?(yardoc)
|
data/lib/solargraph.rb
CHANGED
@@ -53,6 +53,8 @@ module Solargraph
|
|
53
53
|
dir = File.dirname(__FILE__)
|
54
54
|
VIEWS_PATH = File.join(dir, 'solargraph', 'views')
|
55
55
|
|
56
|
+
CHDIR_MUTEX = Mutex.new
|
57
|
+
|
56
58
|
# @param type [Symbol] Type of assert.
|
57
59
|
def self.asserts_on?(type)
|
58
60
|
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
|
@@ -65,6 +67,10 @@ module Solargraph
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
70
|
+
# @param type [Symbol] The type of assertion to perform.
|
71
|
+
# @param msg [String, nil] An optional message to log
|
72
|
+
# @param block [Proc] A block that returns a message to log
|
73
|
+
# @return [void]
|
68
74
|
def self.assert_or_log(type, msg = nil, &block)
|
69
75
|
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
|
70
76
|
logger.info msg, &block
|
@@ -79,6 +85,11 @@ module Solargraph
|
|
79
85
|
|
80
86
|
# A helper method that runs Bundler.with_unbundled_env or falls back to
|
81
87
|
# Bundler.with_clean_env for earlier versions of Bundler.
|
88
|
+
#
|
89
|
+
# @generic T
|
90
|
+
# @yieldreturn [generic<T>]
|
91
|
+
# @sg-ignore dynamic call, but both functions behave the same
|
92
|
+
# @return [generic<T>]
|
82
93
|
def self.with_clean_env &block
|
83
94
|
meth = if Bundler.respond_to?(:with_original_env)
|
84
95
|
:with_original_env
|
@@ -88,3 +99,7 @@ module Solargraph
|
|
88
99
|
Bundler.send meth, &block
|
89
100
|
end
|
90
101
|
end
|
102
|
+
|
103
|
+
# Ensure that ParserGem node processors are properly loaded to avoid conflicts
|
104
|
+
# with Convention node processors
|
105
|
+
require 'solargraph/parser/parser_gem/node_processors'
|
data/rbs/fills/tuple.rbs
CHANGED
@@ -45,7 +45,6 @@ module Solargraph
|
|
45
45
|
| (7 index) -> H
|
46
46
|
| (8 index) -> I
|
47
47
|
| (9 index) -> J
|
48
|
-
| (0 index) -> K
|
49
48
|
| (int index) -> nil
|
50
49
|
|
51
50
|
# <!--
|
@@ -133,7 +132,7 @@ module Solargraph
|
|
133
132
|
| [T] (7 index, T default) -> (H | T)
|
134
133
|
| [T] (8 index, T default) -> (I | T)
|
135
134
|
| [T] (9 index, T default) -> (J | T)
|
136
|
-
| [T] (int index, T default) -> (A | B | C | D | E | F |G | H | I | J | T)
|
135
|
+
| [T] (int index, T default) -> (A | B | C | D | E | F | G | H | I | J | T)
|
137
136
|
| [T] (0 index) { (int index) -> T } -> (A | T)
|
138
137
|
| [T] (1 index) { (int index) -> T } -> (B | T)
|
139
138
|
| [T] (2 index) { (int index) -> T } -> (C | T)
|
@@ -144,7 +143,7 @@ module Solargraph
|
|
144
143
|
| [T] (7 index) { (int index) -> T } -> (H | T)
|
145
144
|
| [T] (8 index) { (int index) -> T } -> (I | T)
|
146
145
|
| [T] (9 index) { (int index) -> T } -> (J | T)
|
147
|
-
| [T] (int index) { (int index) -> T } -> (A | B | C | D | E | F |G | H | I | J | T)
|
146
|
+
| [T] (int index) { (int index) -> T } -> (A | B | C | D | E | F | G | H | I | J | T)
|
148
147
|
end
|
149
148
|
end
|
150
149
|
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
##
|
5
|
+
# Default AST builder. Uses {AST::Node}s.
|
6
|
+
#
|
7
|
+
module Builders
|
8
|
+
class Default
|
9
|
+
##
|
10
|
+
# AST compatibility attribute; since `-> {}` is not semantically
|
11
|
+
# equivalent to `lambda {}`, all new code should set this attribute
|
12
|
+
# to true.
|
13
|
+
#
|
14
|
+
# If set to false (the default), `-> {}` is emitted as
|
15
|
+
# `s(:block, s(:send, nil, :lambda), s(:args), nil)`.
|
16
|
+
#
|
17
|
+
# If set to true, `-> {}` is emitted as
|
18
|
+
# `s(:block, s(:lambda), s(:args), nil)`.
|
19
|
+
#
|
20
|
+
# @return [Boolean]
|
21
|
+
attr_accessor self.emit_lambda: bool
|
22
|
+
|
23
|
+
##
|
24
|
+
# AST compatibility attribute; block arguments of `m { |a| }` are
|
25
|
+
# not semantically equivalent to block arguments of `m { |a,| }` or `m { |a, b| }`,
|
26
|
+
# all new code should set this attribute to true.
|
27
|
+
#
|
28
|
+
# If set to false (the default), arguments of `m { |a| }` are emitted as
|
29
|
+
# `s(:args, s(:arg, :a))`.
|
30
|
+
#
|
31
|
+
# If set to true, arguments of `m { |a| }` are emitted as
|
32
|
+
# `s(:args, s(:procarg0, :a)).
|
33
|
+
#
|
34
|
+
# @return [Boolean]
|
35
|
+
attr_accessor self.emit_procarg0: bool
|
36
|
+
|
37
|
+
##
|
38
|
+
# AST compatibility attribute; locations of `__ENCODING__` are not the same
|
39
|
+
# as locations of `Encoding::UTF_8` causing problems during rewriting,
|
40
|
+
# all new code should set this attribute to true.
|
41
|
+
#
|
42
|
+
# If set to false (the default), `__ENCODING__` is emitted as
|
43
|
+
# ` s(:const, s(:const, nil, :Encoding), :UTF_8)`.
|
44
|
+
#
|
45
|
+
# If set to true, `__ENCODING__` is emitted as
|
46
|
+
# `s(:__ENCODING__)`.
|
47
|
+
#
|
48
|
+
# @return [Boolean]
|
49
|
+
attr_accessor self.emit_encoding: bool
|
50
|
+
|
51
|
+
##
|
52
|
+
# AST compatibility attribute; indexed assignment, `x[] = 1`, is not
|
53
|
+
# semantically equivalent to calling the method directly, `x.[]=(1)`.
|
54
|
+
# Specifically, in the former case, the expression's value is always 1,
|
55
|
+
# and in the latter case, the expression's value is the return value
|
56
|
+
# of the `[]=` method.
|
57
|
+
#
|
58
|
+
# If set to false (the default), `self[1]` is emitted as
|
59
|
+
# `s(:send, s(:self), :[], s(:int, 1))`, and `self[1] = 2` is
|
60
|
+
# emitted as `s(:send, s(:self), :[]=, s(:int, 1), s(:int, 2))`.
|
61
|
+
#
|
62
|
+
# If set to true, `self[1]` is emitted as
|
63
|
+
# `s(:index, s(:self), s(:int, 1))`, and `self[1] = 2` is
|
64
|
+
# emitted as `s(:indexasgn, s(:self), s(:int, 1), s(:int, 2))`.
|
65
|
+
#
|
66
|
+
# @return [Boolean]
|
67
|
+
attr_accessor self.emit_index: bool
|
68
|
+
|
69
|
+
##
|
70
|
+
# AST compatibility attribute; causes a single non-mlhs
|
71
|
+
# block argument to be wrapped in s(:procarg0).
|
72
|
+
#
|
73
|
+
# If set to false (the default), block arguments `|a|` are emitted as
|
74
|
+
# `s(:args, s(:procarg0, :a))`
|
75
|
+
#
|
76
|
+
# If set to true, block arguments `|a|` are emitted as
|
77
|
+
# `s(:args, s(:procarg0, s(:arg, :a))`
|
78
|
+
#
|
79
|
+
# @return [Boolean]
|
80
|
+
attr_accessor self.emit_arg_inside_procarg0: bool
|
81
|
+
|
82
|
+
##
|
83
|
+
# AST compatibility attribute; arguments forwarding initially
|
84
|
+
# didn't have support for leading arguments
|
85
|
+
# (i.e. `def m(a, ...); end` was a syntax error). However, Ruby 3.0
|
86
|
+
# added support for any number of arguments in front of the `...`.
|
87
|
+
#
|
88
|
+
# If set to false (the default):
|
89
|
+
# 1. `def m(...) end` is emitted as
|
90
|
+
# s(:def, :m, s(:forward_args), nil)
|
91
|
+
# 2. `def m(a, b, ...) end` is emitted as
|
92
|
+
# s(:def, :m,
|
93
|
+
# s(:args, s(:arg, :a), s(:arg, :b), s(:forward_arg)))
|
94
|
+
#
|
95
|
+
# If set to true it uses a single format:
|
96
|
+
# 1. `def m(...) end` is emitted as
|
97
|
+
# s(:def, :m, s(:args, s(:forward_arg)))
|
98
|
+
# 2. `def m(a, b, ...) end` is emitted as
|
99
|
+
# s(:def, :m, s(:args, s(:arg, :a), s(:arg, :b), s(:forward_arg)))
|
100
|
+
#
|
101
|
+
# It does't matter that much on 2.7 (because there can't be any leading arguments),
|
102
|
+
# but on 3.0 it should be better enabled to use a single AST format.
|
103
|
+
#
|
104
|
+
# @return [Boolean]
|
105
|
+
attr_accessor self.emit_forward_arg: bool
|
106
|
+
|
107
|
+
##
|
108
|
+
# AST compatibility attribute; Starting from Ruby 2.7 keyword arguments
|
109
|
+
# of method calls that are passed explicitly as a hash (i.e. with curly braces)
|
110
|
+
# are treated as positional arguments and Ruby 2.7 emits a warning on such method
|
111
|
+
# call. Ruby 3.0 given an ArgumentError.
|
112
|
+
#
|
113
|
+
# If set to false (the default) the last hash argument is emitted as `hash`:
|
114
|
+
#
|
115
|
+
# ```
|
116
|
+
# (send nil :foo
|
117
|
+
# (hash
|
118
|
+
# (pair
|
119
|
+
# (sym :bar)
|
120
|
+
# (int 42))))
|
121
|
+
# ```
|
122
|
+
#
|
123
|
+
# If set to true it is emitted as `kwargs`:
|
124
|
+
#
|
125
|
+
# ```
|
126
|
+
# (send nil :foo
|
127
|
+
# (kwargs
|
128
|
+
# (pair
|
129
|
+
# (sym :bar)
|
130
|
+
# (int 42))))
|
131
|
+
# ```
|
132
|
+
#
|
133
|
+
# Note that `kwargs` node is just a replacement for `hash` argument,
|
134
|
+
# so if there's are multiple arguments (or a `kwsplat`) all of them
|
135
|
+
# are wrapped into `kwargs` instead of `hash`:
|
136
|
+
#
|
137
|
+
# ```
|
138
|
+
# (send nil :foo
|
139
|
+
# (kwargs
|
140
|
+
# (pair
|
141
|
+
# (sym :a)
|
142
|
+
# (int 42))
|
143
|
+
# (kwsplat
|
144
|
+
# (send nil :b))
|
145
|
+
# (pair
|
146
|
+
# (sym :c)
|
147
|
+
# (int 10))))
|
148
|
+
# ```
|
149
|
+
attr_accessor self.emit_kwargs: bool
|
150
|
+
|
151
|
+
##
|
152
|
+
# AST compatibility attribute; Starting from 3.0 Ruby returns
|
153
|
+
# true/false from single-line pattern matching with `in` keyword.
|
154
|
+
#
|
155
|
+
# Before 3.0 there was an exception if given value doesn't match pattern.
|
156
|
+
#
|
157
|
+
# NOTE: This attribute affects only Ruby 2.7 grammar.
|
158
|
+
# 3.0 grammar always emits `match_pattern`/`match_pattern_p`
|
159
|
+
#
|
160
|
+
# If compatibility attribute set to false `foo in bar` is emitted as `in_match`:
|
161
|
+
#
|
162
|
+
# ```
|
163
|
+
# (in-match
|
164
|
+
# (send nil :foo)
|
165
|
+
# (match-var :bar))
|
166
|
+
# ```
|
167
|
+
#
|
168
|
+
# If set to true it's emitted as `match_pattern_p`:
|
169
|
+
# ```
|
170
|
+
# (match-pattern-p
|
171
|
+
# (send nil :foo)
|
172
|
+
# (match-var :bar))
|
173
|
+
# ```
|
174
|
+
attr_accessor self.emit_match_pattern: bool
|
175
|
+
|
176
|
+
##
|
177
|
+
# If set to true (the default), `__FILE__` and `__LINE__` are transformed to
|
178
|
+
# literal nodes. For example, `s(:str, "lib/foo.rb")` and `s(:int, 10)`.
|
179
|
+
#
|
180
|
+
# If set to false, `__FILE__` and `__LINE__` are emitted as-is,
|
181
|
+
# i.e. as `s(:__FILE__)` and `s(:__LINE__)` nodes.
|
182
|
+
#
|
183
|
+
# Source maps are identical in both cases.
|
184
|
+
#
|
185
|
+
# @return [Boolean]
|
186
|
+
attr_accessor emit_file_line_as_literals: bool
|
187
|
+
|
188
|
+
def value: (untyped token) -> untyped
|
189
|
+
|
190
|
+
def string_value: (untyped token) -> String
|
191
|
+
|
192
|
+
def loc: (untyped token) -> untyped
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# manifest.yaml describes dependencies which do not appear in the gemspec.
|
2
|
+
# If this gem includes such dependencies, comment-out the following lines and
|
3
|
+
# declare the dependencies.
|
4
|
+
# If all dependencies appear in the gemspec, you should remove this file.
|
5
|
+
#
|
6
|
+
# dependencies:
|
7
|
+
# - name: pathname
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Thor
|
2
|
+
class Group
|
3
|
+
end
|
4
|
+
|
5
|
+
module Actions
|
6
|
+
class CreateFile
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_file: (String destination, String data, ?verbose: bool) -> String
|
10
|
+
| (String destination, ?verbose: bool) { () -> String } -> String
|
11
|
+
end
|
12
|
+
|
13
|
+
class Error
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.start: (Array[String] given_args, ?Hash[Symbol, untyped] config) -> void
|
17
|
+
end
|
data/solargraph.gemspec
CHANGED
@@ -11,7 +11,10 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.authors = ["Fred Snyder"]
|
12
12
|
s.email = 'admin@castwide.com'
|
13
13
|
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
14
|
-
|
14
|
+
# @sg-ignore Need backtick support
|
15
|
+
# @type [String]
|
16
|
+
all_files = `git ls-files -z`
|
17
|
+
all_files.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
18
|
end
|
16
19
|
s.homepage = 'https://solargraph.org'
|
17
20
|
s.license = 'MIT'
|
@@ -35,19 +38,26 @@ Gem::Specification.new do |s|
|
|
35
38
|
s.add_runtime_dependency 'ostruct', '~> 0.6'
|
36
39
|
s.add_runtime_dependency 'parser', '~> 3.0'
|
37
40
|
s.add_runtime_dependency 'prism', '~> 1.4'
|
38
|
-
s.add_runtime_dependency 'rbs', '
|
41
|
+
s.add_runtime_dependency 'rbs', ['>= 3.6.1', '<= 4.0.0.dev.4']
|
39
42
|
s.add_runtime_dependency 'reverse_markdown', '~> 3.0'
|
40
|
-
s.add_runtime_dependency 'rubocop', '~> 1.
|
43
|
+
s.add_runtime_dependency 'rubocop', '~> 1.76'
|
41
44
|
s.add_runtime_dependency 'thor', '~> 1.0'
|
42
45
|
s.add_runtime_dependency 'tilt', '~> 2.0'
|
43
46
|
s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24'
|
44
47
|
s.add_runtime_dependency 'yard-solargraph', '~> 0.1'
|
48
|
+
s.add_runtime_dependency 'yard-activesupport-concern', '~> 0.0'
|
45
49
|
|
46
50
|
s.add_development_dependency 'pry', '~> 0.15'
|
47
51
|
s.add_development_dependency 'public_suffix', '~> 3.1'
|
48
52
|
s.add_development_dependency 'rake', '~> 13.2'
|
49
53
|
s.add_development_dependency 'rspec', '~> 3.5'
|
50
|
-
s.add_development_dependency '
|
54
|
+
s.add_development_dependency 'rubocop-rake', '~> 0.7'
|
55
|
+
s.add_development_dependency 'rubocop-rspec', '~> 3.6'
|
56
|
+
s.add_development_dependency 'rubocop-yard', '~> 1.0'
|
57
|
+
s.add_development_dependency 'simplecov', '~> 0.21'
|
58
|
+
s.add_development_dependency 'simplecov-lcov', '~> 0.8'
|
59
|
+
s.add_development_dependency 'undercover', '~> 0.7'
|
60
|
+
s.add_development_dependency 'overcommit', '~> 0.68.0'
|
51
61
|
s.add_development_dependency 'webmock', '~> 3.6'
|
52
62
|
# work around missing yard dependency needed as of Ruby 3.5
|
53
63
|
s.add_development_dependency 'irb', '~> 1.15'
|