solargraph 0.58.1 → 0.58.2
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/.gitignore +1 -0
- data/CHANGELOG.md +7 -1
- data/lib/solargraph/api_map/cache.rb +110 -110
- data/lib/solargraph/api_map/constants.rb +279 -279
- data/lib/solargraph/api_map/index.rb +193 -193
- data/lib/solargraph/api_map/source_to_yard.rb +97 -97
- data/lib/solargraph/api_map/store.rb +384 -384
- data/lib/solargraph/api_map.rb +945 -945
- data/lib/solargraph/complex_type/type_methods.rb +228 -228
- data/lib/solargraph/complex_type/unique_type.rb +482 -482
- data/lib/solargraph/complex_type.rb +444 -444
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +91 -91
- data/lib/solargraph/convention/data_definition.rb +105 -105
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +61 -61
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +102 -102
- data/lib/solargraph/convention/struct_definition.rb +164 -164
- data/lib/solargraph/diagnostics/require_not_found.rb +53 -53
- data/lib/solargraph/diagnostics/rubocop.rb +118 -118
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +68 -68
- data/lib/solargraph/diagnostics/type_check.rb +55 -55
- data/lib/solargraph/doc_map.rb +439 -439
- data/lib/solargraph/equality.rb +34 -34
- data/lib/solargraph/gem_pins.rb +98 -98
- data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
- data/lib/solargraph/language_server/host/dispatch.rb +130 -130
- data/lib/solargraph/language_server/host/message_worker.rb +112 -112
- data/lib/solargraph/language_server/host/sources.rb +99 -99
- data/lib/solargraph/language_server/host.rb +878 -878
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +114 -114
- data/lib/solargraph/language_server/message/extended/document.rb +23 -23
- data/lib/solargraph/language_server/message/text_document/completion.rb +56 -56
- data/lib/solargraph/language_server/message/text_document/definition.rb +40 -40
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +26 -26
- data/lib/solargraph/language_server/message/text_document/formatting.rb +148 -148
- data/lib/solargraph/language_server/message/text_document/hover.rb +58 -58
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +24 -24
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -25
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +23 -23
- data/lib/solargraph/library.rb +683 -683
- data/lib/solargraph/location.rb +82 -82
- data/lib/solargraph/logging.rb +37 -37
- data/lib/solargraph/parser/comment_ripper.rb +69 -69
- data/lib/solargraph/parser/flow_sensitive_typing.rb +255 -255
- data/lib/solargraph/parser/node_processor/base.rb +92 -92
- data/lib/solargraph/parser/node_processor.rb +62 -62
- data/lib/solargraph/parser/parser_gem/class_methods.rb +149 -149
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +166 -166
- data/lib/solargraph/parser/parser_gem/node_methods.rb +486 -486
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +22 -22
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +59 -59
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +15 -15
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +46 -46
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +53 -53
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +23 -23
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +40 -40
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +59 -59
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +98 -98
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +17 -17
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +38 -38
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +52 -52
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +291 -291
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors.rb +70 -70
- data/lib/solargraph/parser/region.rb +69 -69
- data/lib/solargraph/parser/snippet.rb +17 -17
- data/lib/solargraph/pin/base.rb +729 -729
- data/lib/solargraph/pin/base_variable.rb +126 -126
- data/lib/solargraph/pin/block.rb +104 -104
- data/lib/solargraph/pin/breakable.rb +9 -9
- data/lib/solargraph/pin/callable.rb +231 -231
- data/lib/solargraph/pin/closure.rb +72 -72
- data/lib/solargraph/pin/common.rb +79 -79
- data/lib/solargraph/pin/conversions.rb +123 -123
- data/lib/solargraph/pin/delegated_method.rb +120 -120
- data/lib/solargraph/pin/documenting.rb +114 -114
- data/lib/solargraph/pin/instance_variable.rb +34 -34
- data/lib/solargraph/pin/keyword.rb +20 -20
- data/lib/solargraph/pin/local_variable.rb +75 -75
- data/lib/solargraph/pin/method.rb +672 -672
- data/lib/solargraph/pin/method_alias.rb +34 -34
- data/lib/solargraph/pin/namespace.rb +115 -115
- data/lib/solargraph/pin/parameter.rb +275 -275
- data/lib/solargraph/pin/proxy_type.rb +39 -39
- data/lib/solargraph/pin/reference/override.rb +47 -47
- data/lib/solargraph/pin/reference/superclass.rb +15 -15
- data/lib/solargraph/pin/reference.rb +39 -39
- data/lib/solargraph/pin/search.rb +61 -61
- data/lib/solargraph/pin/signature.rb +61 -61
- data/lib/solargraph/pin/symbol.rb +53 -53
- data/lib/solargraph/pin/until.rb +18 -18
- data/lib/solargraph/pin/while.rb +18 -18
- data/lib/solargraph/pin.rb +44 -44
- data/lib/solargraph/pin_cache.rb +245 -245
- data/lib/solargraph/position.rb +132 -119
- data/lib/solargraph/range.rb +112 -112
- data/lib/solargraph/rbs_map/conversions.rb +823 -823
- data/lib/solargraph/rbs_map/core_map.rb +58 -58
- data/lib/solargraph/rbs_map/stdlib_map.rb +43 -43
- data/lib/solargraph/rbs_map.rb +163 -163
- data/lib/solargraph/shell.rb +352 -352
- data/lib/solargraph/source/chain/call.rb +337 -337
- data/lib/solargraph/source/chain/constant.rb +26 -26
- data/lib/solargraph/source/chain/hash.rb +34 -34
- data/lib/solargraph/source/chain/if.rb +28 -28
- data/lib/solargraph/source/chain/instance_variable.rb +13 -13
- data/lib/solargraph/source/chain/literal.rb +48 -48
- data/lib/solargraph/source/chain/or.rb +23 -23
- data/lib/solargraph/source/chain.rb +291 -291
- data/lib/solargraph/source/change.rb +82 -82
- data/lib/solargraph/source/cursor.rb +166 -166
- data/lib/solargraph/source/source_chainer.rb +194 -194
- data/lib/solargraph/source/updater.rb +55 -55
- data/lib/solargraph/source.rb +498 -498
- data/lib/solargraph/source_map/clip.rb +226 -226
- data/lib/solargraph/source_map/data.rb +34 -34
- data/lib/solargraph/source_map/mapper.rb +259 -259
- data/lib/solargraph/source_map.rb +212 -212
- data/lib/solargraph/type_checker/checks.rb +124 -124
- data/lib/solargraph/type_checker/param_def.rb +37 -37
- data/lib/solargraph/type_checker/problem.rb +32 -32
- data/lib/solargraph/type_checker/rules.rb +84 -84
- data/lib/solargraph/type_checker.rb +814 -814
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +255 -255
- data/lib/solargraph/workspace/require_paths.rb +97 -97
- data/lib/solargraph/workspace.rb +220 -220
- data/lib/solargraph/yard_map/helpers.rb +44 -44
- data/lib/solargraph/yard_map/mapper/to_method.rb +130 -130
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +31 -31
- data/lib/solargraph/yard_map/mapper.rb +79 -79
- data/lib/solargraph/yard_map/to_method.rb +89 -89
- data/lib/solargraph/yardoc.rb +87 -87
- data/lib/solargraph.rb +105 -105
- data/rbs_collection.yaml +1 -1
- metadata +12 -12
- /data/{sig → rbs}/shims/ast/0/node.rbs +0 -0
- /data/{sig → rbs}/shims/ast/2.4/.rbs_meta.yaml +0 -0
- /data/{sig → rbs}/shims/ast/2.4/ast.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/builders/default.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/manifest.yaml +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/parser.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/polyfill.rbs +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/.rbs_meta.yaml +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/manifest.yaml +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/thor.rbs +0 -0
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class YardMap
|
|
5
|
-
class ToMethod
|
|
6
|
-
module InnerMethods
|
|
7
|
-
module_function
|
|
8
|
-
|
|
9
|
-
# @param code_object [YARD::CodeObjects::Base]
|
|
10
|
-
# @param location [Solargraph::Location]
|
|
11
|
-
# @param comments [String]
|
|
12
|
-
# @return [Array<Solargraph::Pin::Parameter>]
|
|
13
|
-
def get_parameters code_object, location, comments
|
|
14
|
-
return [] unless code_object.is_a?(YARD::CodeObjects::MethodObject)
|
|
15
|
-
# HACK: Skip `nil` and `self` parameters that are sometimes emitted
|
|
16
|
-
# for methods defined in C
|
|
17
|
-
# See https://github.com/castwide/solargraph/issues/345
|
|
18
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
19
|
-
code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
|
|
20
|
-
Solargraph::Pin::Parameter.new(
|
|
21
|
-
location: location,
|
|
22
|
-
closure: self,
|
|
23
|
-
comments: comments,
|
|
24
|
-
name: arg_name(a),
|
|
25
|
-
presence: nil,
|
|
26
|
-
decl: arg_type(a),
|
|
27
|
-
asgn_code: a[1],
|
|
28
|
-
source: :yard_map
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# @param a [Array<String>]
|
|
34
|
-
# @return [String]
|
|
35
|
-
def arg_name a
|
|
36
|
-
a[0].gsub(/[^a-z0-9_]/i, '')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# @param a [Array]
|
|
40
|
-
# @return [::Symbol]
|
|
41
|
-
def arg_type a
|
|
42
|
-
if a[0].start_with?('**')
|
|
43
|
-
:kwrestarg
|
|
44
|
-
elsif a[0].start_with?('*')
|
|
45
|
-
:restarg
|
|
46
|
-
elsif a[0].start_with?('&')
|
|
47
|
-
:blockarg
|
|
48
|
-
elsif a[0].end_with?(':')
|
|
49
|
-
a[1] ? :kwoptarg : :kwarg
|
|
50
|
-
elsif a[1]
|
|
51
|
-
:optarg
|
|
52
|
-
else
|
|
53
|
-
:arg
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
private_constant :InnerMethods
|
|
58
|
-
|
|
59
|
-
include Helpers
|
|
60
|
-
|
|
61
|
-
# @param code_object [YARD::CodeObjects::MethodObject]
|
|
62
|
-
# @param name [String, nil]
|
|
63
|
-
# @param scope [Symbol, nil]
|
|
64
|
-
# @param visibility [Symbol, nil]
|
|
65
|
-
# @param closure [Solargraph::Pin::Base, nil]
|
|
66
|
-
# @param spec [Solargraph::Pin::Base, nil]
|
|
67
|
-
# @return [Solargraph::Pin::Method]
|
|
68
|
-
def make code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
|
69
|
-
closure ||= Solargraph::Pin::Namespace.new(
|
|
70
|
-
name: code_object.namespace.to_s,
|
|
71
|
-
gates: [code_object.namespace.to_s]
|
|
72
|
-
)
|
|
73
|
-
location = object_location(code_object, spec)
|
|
74
|
-
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
|
75
|
-
Pin::Method.new(
|
|
76
|
-
location: location,
|
|
77
|
-
closure: closure,
|
|
78
|
-
name: name || code_object.name.to_s,
|
|
79
|
-
comments: comments,
|
|
80
|
-
scope: scope || code_object.scope,
|
|
81
|
-
visibility: visibility || code_object.visibility,
|
|
82
|
-
parameters: InnerMethods.get_parameters(code_object, location, comments),
|
|
83
|
-
explicit: code_object.is_explicit?,
|
|
84
|
-
source: :yard_map
|
|
85
|
-
)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class YardMap
|
|
5
|
+
class ToMethod
|
|
6
|
+
module InnerMethods
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
# @param code_object [YARD::CodeObjects::Base]
|
|
10
|
+
# @param location [Solargraph::Location]
|
|
11
|
+
# @param comments [String]
|
|
12
|
+
# @return [Array<Solargraph::Pin::Parameter>]
|
|
13
|
+
def get_parameters code_object, location, comments
|
|
14
|
+
return [] unless code_object.is_a?(YARD::CodeObjects::MethodObject)
|
|
15
|
+
# HACK: Skip `nil` and `self` parameters that are sometimes emitted
|
|
16
|
+
# for methods defined in C
|
|
17
|
+
# See https://github.com/castwide/solargraph/issues/345
|
|
18
|
+
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
19
|
+
code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
|
|
20
|
+
Solargraph::Pin::Parameter.new(
|
|
21
|
+
location: location,
|
|
22
|
+
closure: self,
|
|
23
|
+
comments: comments,
|
|
24
|
+
name: arg_name(a),
|
|
25
|
+
presence: nil,
|
|
26
|
+
decl: arg_type(a),
|
|
27
|
+
asgn_code: a[1],
|
|
28
|
+
source: :yard_map
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @param a [Array<String>]
|
|
34
|
+
# @return [String]
|
|
35
|
+
def arg_name a
|
|
36
|
+
a[0].gsub(/[^a-z0-9_]/i, '')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @param a [Array]
|
|
40
|
+
# @return [::Symbol]
|
|
41
|
+
def arg_type a
|
|
42
|
+
if a[0].start_with?('**')
|
|
43
|
+
:kwrestarg
|
|
44
|
+
elsif a[0].start_with?('*')
|
|
45
|
+
:restarg
|
|
46
|
+
elsif a[0].start_with?('&')
|
|
47
|
+
:blockarg
|
|
48
|
+
elsif a[0].end_with?(':')
|
|
49
|
+
a[1] ? :kwoptarg : :kwarg
|
|
50
|
+
elsif a[1]
|
|
51
|
+
:optarg
|
|
52
|
+
else
|
|
53
|
+
:arg
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
private_constant :InnerMethods
|
|
58
|
+
|
|
59
|
+
include Helpers
|
|
60
|
+
|
|
61
|
+
# @param code_object [YARD::CodeObjects::MethodObject]
|
|
62
|
+
# @param name [String, nil]
|
|
63
|
+
# @param scope [Symbol, nil]
|
|
64
|
+
# @param visibility [Symbol, nil]
|
|
65
|
+
# @param closure [Solargraph::Pin::Base, nil]
|
|
66
|
+
# @param spec [Solargraph::Pin::Base, nil]
|
|
67
|
+
# @return [Solargraph::Pin::Method]
|
|
68
|
+
def make code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
|
69
|
+
closure ||= Solargraph::Pin::Namespace.new(
|
|
70
|
+
name: code_object.namespace.to_s,
|
|
71
|
+
gates: [code_object.namespace.to_s]
|
|
72
|
+
)
|
|
73
|
+
location = object_location(code_object, spec)
|
|
74
|
+
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
|
75
|
+
Pin::Method.new(
|
|
76
|
+
location: location,
|
|
77
|
+
closure: closure,
|
|
78
|
+
name: name || code_object.name.to_s,
|
|
79
|
+
comments: comments,
|
|
80
|
+
scope: scope || code_object.scope,
|
|
81
|
+
visibility: visibility || code_object.visibility,
|
|
82
|
+
parameters: InnerMethods.get_parameters(code_object, location, comments),
|
|
83
|
+
explicit: code_object.is_explicit?,
|
|
84
|
+
source: :yard_map
|
|
85
|
+
)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
data/lib/solargraph/yardoc.rb
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'open3'
|
|
4
|
-
|
|
5
|
-
module Solargraph
|
|
6
|
-
# Methods for caching and loading YARD documentation for gems.
|
|
7
|
-
#
|
|
8
|
-
module Yardoc
|
|
9
|
-
module_function
|
|
10
|
-
|
|
11
|
-
# Build and cache a gem's yardoc and return the path. If the cache already
|
|
12
|
-
# exists, do nothing and return the path.
|
|
13
|
-
#
|
|
14
|
-
# @param yard_plugins [Array<String>] The names of YARD plugins to use.
|
|
15
|
-
# @param gemspec [Gem::Specification]
|
|
16
|
-
# @return [String] The path to the cached yardoc.
|
|
17
|
-
def cache(yard_plugins, gemspec)
|
|
18
|
-
path = PinCache.yardoc_path gemspec
|
|
19
|
-
return path if cached?(gemspec)
|
|
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
|
-
|
|
30
|
-
Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
|
|
31
|
-
cmd = "yardoc --db #{path} --no-output --plugin solargraph"
|
|
32
|
-
yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" }
|
|
33
|
-
Solargraph.logger.debug { "Running: #{cmd}" }
|
|
34
|
-
# @todo set these up to run in parallel
|
|
35
|
-
stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir)
|
|
36
|
-
unless status.success?
|
|
37
|
-
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" }
|
|
38
|
-
Solargraph.logger.info stdout_and_stderr_str
|
|
39
|
-
end
|
|
40
|
-
path
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# True if the gem yardoc is cached.
|
|
44
|
-
#
|
|
45
|
-
# @param gemspec [Gem::Specification]
|
|
46
|
-
def cached?(gemspec)
|
|
47
|
-
yardoc = File.join(PinCache.yardoc_path(gemspec), 'complete')
|
|
48
|
-
File.exist?(yardoc)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# True if another process is currently building the yardoc cache.
|
|
52
|
-
#
|
|
53
|
-
# @param gemspec [Gem::Specification]
|
|
54
|
-
def processing?(gemspec)
|
|
55
|
-
yardoc = File.join(PinCache.yardoc_path(gemspec), 'processing')
|
|
56
|
-
File.exist?(yardoc)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Load a gem's yardoc and return its code objects.
|
|
60
|
-
#
|
|
61
|
-
# @note This method modifies the global YARD registry.
|
|
62
|
-
#
|
|
63
|
-
# @param gemspec [Gem::Specification]
|
|
64
|
-
# @return [Array<YARD::CodeObjects::Base>]
|
|
65
|
-
def load!(gemspec)
|
|
66
|
-
YARD::Registry.load! PinCache.yardoc_path gemspec
|
|
67
|
-
YARD::Registry.all
|
|
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
|
|
86
|
-
end
|
|
87
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
|
|
5
|
+
module Solargraph
|
|
6
|
+
# Methods for caching and loading YARD documentation for gems.
|
|
7
|
+
#
|
|
8
|
+
module Yardoc
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
# Build and cache a gem's yardoc and return the path. If the cache already
|
|
12
|
+
# exists, do nothing and return the path.
|
|
13
|
+
#
|
|
14
|
+
# @param yard_plugins [Array<String>] The names of YARD plugins to use.
|
|
15
|
+
# @param gemspec [Gem::Specification]
|
|
16
|
+
# @return [String] The path to the cached yardoc.
|
|
17
|
+
def cache(yard_plugins, gemspec)
|
|
18
|
+
path = PinCache.yardoc_path gemspec
|
|
19
|
+
return path if cached?(gemspec)
|
|
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
|
+
|
|
30
|
+
Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
|
|
31
|
+
cmd = "yardoc --db #{path} --no-output --plugin solargraph"
|
|
32
|
+
yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" }
|
|
33
|
+
Solargraph.logger.debug { "Running: #{cmd}" }
|
|
34
|
+
# @todo set these up to run in parallel
|
|
35
|
+
stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir)
|
|
36
|
+
unless status.success?
|
|
37
|
+
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" }
|
|
38
|
+
Solargraph.logger.info stdout_and_stderr_str
|
|
39
|
+
end
|
|
40
|
+
path
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# True if the gem yardoc is cached.
|
|
44
|
+
#
|
|
45
|
+
# @param gemspec [Gem::Specification]
|
|
46
|
+
def cached?(gemspec)
|
|
47
|
+
yardoc = File.join(PinCache.yardoc_path(gemspec), 'complete')
|
|
48
|
+
File.exist?(yardoc)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# True if another process is currently building the yardoc cache.
|
|
52
|
+
#
|
|
53
|
+
# @param gemspec [Gem::Specification]
|
|
54
|
+
def processing?(gemspec)
|
|
55
|
+
yardoc = File.join(PinCache.yardoc_path(gemspec), 'processing')
|
|
56
|
+
File.exist?(yardoc)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Load a gem's yardoc and return its code objects.
|
|
60
|
+
#
|
|
61
|
+
# @note This method modifies the global YARD registry.
|
|
62
|
+
#
|
|
63
|
+
# @param gemspec [Gem::Specification]
|
|
64
|
+
# @return [Array<YARD::CodeObjects::Base>]
|
|
65
|
+
def load!(gemspec)
|
|
66
|
+
YARD::Registry.load! PinCache.yardoc_path gemspec
|
|
67
|
+
YARD::Registry.all
|
|
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
|
|
86
|
+
end
|
|
87
|
+
end
|
data/lib/solargraph.rb
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Encoding.default_external = 'UTF-8'
|
|
4
|
-
|
|
5
|
-
require 'bundler'
|
|
6
|
-
require 'set'
|
|
7
|
-
require 'yard-solargraph'
|
|
8
|
-
require 'solargraph/yard_tags'
|
|
9
|
-
require 'solargraph/version'
|
|
10
|
-
|
|
11
|
-
# The top-level namespace for the Solargraph code mapping, documentation,
|
|
12
|
-
# static analysis, and language server libraries.
|
|
13
|
-
#
|
|
14
|
-
module Solargraph
|
|
15
|
-
class InvalidOffsetError < RangeError; end
|
|
16
|
-
class DiagnosticsError < RuntimeError; end
|
|
17
|
-
class FileNotFoundError < RuntimeError; end
|
|
18
|
-
class SourceNotAvailableError < StandardError; end
|
|
19
|
-
class ComplexTypeError < StandardError; end
|
|
20
|
-
class WorkspaceTooLargeError < RuntimeError; end
|
|
21
|
-
class BundleNotFoundError < StandardError; end
|
|
22
|
-
class InvalidRubocopVersionError < RuntimeError; end
|
|
23
|
-
|
|
24
|
-
autoload :Position, 'solargraph/position'
|
|
25
|
-
autoload :Range, 'solargraph/range'
|
|
26
|
-
autoload :Location, 'solargraph/location'
|
|
27
|
-
autoload :Shell, 'solargraph/shell'
|
|
28
|
-
autoload :Source, 'solargraph/source'
|
|
29
|
-
autoload :SourceMap, 'solargraph/source_map'
|
|
30
|
-
autoload :ApiMap, 'solargraph/api_map'
|
|
31
|
-
autoload :Yardoc, 'solargraph/yardoc'
|
|
32
|
-
autoload :YardMap, 'solargraph/yard_map'
|
|
33
|
-
autoload :Pin, 'solargraph/pin'
|
|
34
|
-
autoload :DocMap, 'solargraph/doc_map'
|
|
35
|
-
autoload :ServerMethods, 'solargraph/server_methods'
|
|
36
|
-
autoload :LanguageServer, 'solargraph/language_server'
|
|
37
|
-
autoload :Workspace, 'solargraph/workspace'
|
|
38
|
-
autoload :Page, 'solargraph/page'
|
|
39
|
-
autoload :Library, 'solargraph/library'
|
|
40
|
-
autoload :Diagnostics, 'solargraph/diagnostics'
|
|
41
|
-
autoload :ComplexType, 'solargraph/complex_type'
|
|
42
|
-
autoload :Bench, 'solargraph/bench'
|
|
43
|
-
autoload :Logging, 'solargraph/logging'
|
|
44
|
-
autoload :TypeChecker, 'solargraph/type_checker'
|
|
45
|
-
autoload :Environ, 'solargraph/environ'
|
|
46
|
-
autoload :Equality, 'solargraph/equality'
|
|
47
|
-
autoload :Convention, 'solargraph/convention'
|
|
48
|
-
autoload :Parser, 'solargraph/parser'
|
|
49
|
-
autoload :RbsMap, 'solargraph/rbs_map'
|
|
50
|
-
autoload :GemPins, 'solargraph/gem_pins'
|
|
51
|
-
autoload :PinCache, 'solargraph/pin_cache'
|
|
52
|
-
|
|
53
|
-
dir = File.dirname(__FILE__)
|
|
54
|
-
VIEWS_PATH = File.join(dir, 'solargraph', 'views')
|
|
55
|
-
|
|
56
|
-
CHDIR_MUTEX = Mutex.new
|
|
57
|
-
|
|
58
|
-
# @param type [Symbol] Type of assert.
|
|
59
|
-
def self.asserts_on?(type)
|
|
60
|
-
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
|
|
61
|
-
false
|
|
62
|
-
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
|
|
63
|
-
true
|
|
64
|
-
else
|
|
65
|
-
logger.warn "Unrecognized SOLARGRAPH_ASSERTS value: #{ENV['SOLARGRAPH_ASSERTS']}"
|
|
66
|
-
false
|
|
67
|
-
end
|
|
68
|
-
end
|
|
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]
|
|
74
|
-
def self.assert_or_log(type, msg = nil, &block)
|
|
75
|
-
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
|
|
76
|
-
logger.info msg, &block
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# A convenience method for Solargraph::Logging.logger.
|
|
80
|
-
#
|
|
81
|
-
# @return [Logger]
|
|
82
|
-
def self.logger
|
|
83
|
-
Solargraph::Logging.logger
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# A helper method that runs Bundler.with_unbundled_env or falls back to
|
|
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>]
|
|
93
|
-
def self.with_clean_env &block
|
|
94
|
-
meth = if Bundler.respond_to?(:with_original_env)
|
|
95
|
-
:with_original_env
|
|
96
|
-
else
|
|
97
|
-
:with_clean_env
|
|
98
|
-
end
|
|
99
|
-
Bundler.send meth, &block
|
|
100
|
-
end
|
|
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'
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Encoding.default_external = 'UTF-8'
|
|
4
|
+
|
|
5
|
+
require 'bundler'
|
|
6
|
+
require 'set'
|
|
7
|
+
require 'yard-solargraph'
|
|
8
|
+
require 'solargraph/yard_tags'
|
|
9
|
+
require 'solargraph/version'
|
|
10
|
+
|
|
11
|
+
# The top-level namespace for the Solargraph code mapping, documentation,
|
|
12
|
+
# static analysis, and language server libraries.
|
|
13
|
+
#
|
|
14
|
+
module Solargraph
|
|
15
|
+
class InvalidOffsetError < RangeError; end
|
|
16
|
+
class DiagnosticsError < RuntimeError; end
|
|
17
|
+
class FileNotFoundError < RuntimeError; end
|
|
18
|
+
class SourceNotAvailableError < StandardError; end
|
|
19
|
+
class ComplexTypeError < StandardError; end
|
|
20
|
+
class WorkspaceTooLargeError < RuntimeError; end
|
|
21
|
+
class BundleNotFoundError < StandardError; end
|
|
22
|
+
class InvalidRubocopVersionError < RuntimeError; end
|
|
23
|
+
|
|
24
|
+
autoload :Position, 'solargraph/position'
|
|
25
|
+
autoload :Range, 'solargraph/range'
|
|
26
|
+
autoload :Location, 'solargraph/location'
|
|
27
|
+
autoload :Shell, 'solargraph/shell'
|
|
28
|
+
autoload :Source, 'solargraph/source'
|
|
29
|
+
autoload :SourceMap, 'solargraph/source_map'
|
|
30
|
+
autoload :ApiMap, 'solargraph/api_map'
|
|
31
|
+
autoload :Yardoc, 'solargraph/yardoc'
|
|
32
|
+
autoload :YardMap, 'solargraph/yard_map'
|
|
33
|
+
autoload :Pin, 'solargraph/pin'
|
|
34
|
+
autoload :DocMap, 'solargraph/doc_map'
|
|
35
|
+
autoload :ServerMethods, 'solargraph/server_methods'
|
|
36
|
+
autoload :LanguageServer, 'solargraph/language_server'
|
|
37
|
+
autoload :Workspace, 'solargraph/workspace'
|
|
38
|
+
autoload :Page, 'solargraph/page'
|
|
39
|
+
autoload :Library, 'solargraph/library'
|
|
40
|
+
autoload :Diagnostics, 'solargraph/diagnostics'
|
|
41
|
+
autoload :ComplexType, 'solargraph/complex_type'
|
|
42
|
+
autoload :Bench, 'solargraph/bench'
|
|
43
|
+
autoload :Logging, 'solargraph/logging'
|
|
44
|
+
autoload :TypeChecker, 'solargraph/type_checker'
|
|
45
|
+
autoload :Environ, 'solargraph/environ'
|
|
46
|
+
autoload :Equality, 'solargraph/equality'
|
|
47
|
+
autoload :Convention, 'solargraph/convention'
|
|
48
|
+
autoload :Parser, 'solargraph/parser'
|
|
49
|
+
autoload :RbsMap, 'solargraph/rbs_map'
|
|
50
|
+
autoload :GemPins, 'solargraph/gem_pins'
|
|
51
|
+
autoload :PinCache, 'solargraph/pin_cache'
|
|
52
|
+
|
|
53
|
+
dir = File.dirname(__FILE__)
|
|
54
|
+
VIEWS_PATH = File.join(dir, 'solargraph', 'views')
|
|
55
|
+
|
|
56
|
+
CHDIR_MUTEX = Mutex.new
|
|
57
|
+
|
|
58
|
+
# @param type [Symbol] Type of assert.
|
|
59
|
+
def self.asserts_on?(type)
|
|
60
|
+
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
|
|
61
|
+
false
|
|
62
|
+
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
|
|
63
|
+
true
|
|
64
|
+
else
|
|
65
|
+
logger.warn "Unrecognized SOLARGRAPH_ASSERTS value: #{ENV['SOLARGRAPH_ASSERTS']}"
|
|
66
|
+
false
|
|
67
|
+
end
|
|
68
|
+
end
|
|
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]
|
|
74
|
+
def self.assert_or_log(type, msg = nil, &block)
|
|
75
|
+
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
|
|
76
|
+
logger.info msg, &block
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# A convenience method for Solargraph::Logging.logger.
|
|
80
|
+
#
|
|
81
|
+
# @return [Logger]
|
|
82
|
+
def self.logger
|
|
83
|
+
Solargraph::Logging.logger
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# A helper method that runs Bundler.with_unbundled_env or falls back to
|
|
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>]
|
|
93
|
+
def self.with_clean_env &block
|
|
94
|
+
meth = if Bundler.respond_to?(:with_original_env)
|
|
95
|
+
:with_original_env
|
|
96
|
+
else
|
|
97
|
+
:with_clean_env
|
|
98
|
+
end
|
|
99
|
+
Bundler.send meth, &block
|
|
100
|
+
end
|
|
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_collection.yaml
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solargraph
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.58.
|
|
4
|
+
version: 0.58.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-01-
|
|
10
|
+
date: 2026-01-19 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: ast
|
|
@@ -806,17 +806,17 @@ files:
|
|
|
806
806
|
- rbs/fills/rubygems/0/spec_fetcher.rbs
|
|
807
807
|
- rbs/fills/rubygems/0/specification.rbs
|
|
808
808
|
- rbs/fills/tuple/tuple.rbs
|
|
809
|
+
- rbs/shims/ast/0/node.rbs
|
|
810
|
+
- rbs/shims/ast/2.4/.rbs_meta.yaml
|
|
811
|
+
- rbs/shims/ast/2.4/ast.rbs
|
|
812
|
+
- rbs/shims/parser/3.2.0.1/builders/default.rbs
|
|
813
|
+
- rbs/shims/parser/3.2.0.1/manifest.yaml
|
|
814
|
+
- rbs/shims/parser/3.2.0.1/parser.rbs
|
|
815
|
+
- rbs/shims/parser/3.2.0.1/polyfill.rbs
|
|
816
|
+
- rbs/shims/thor/1.2.0.1/.rbs_meta.yaml
|
|
817
|
+
- rbs/shims/thor/1.2.0.1/manifest.yaml
|
|
818
|
+
- rbs/shims/thor/1.2.0.1/thor.rbs
|
|
809
819
|
- rbs_collection.yaml
|
|
810
|
-
- sig/shims/ast/0/node.rbs
|
|
811
|
-
- sig/shims/ast/2.4/.rbs_meta.yaml
|
|
812
|
-
- sig/shims/ast/2.4/ast.rbs
|
|
813
|
-
- sig/shims/parser/3.2.0.1/builders/default.rbs
|
|
814
|
-
- sig/shims/parser/3.2.0.1/manifest.yaml
|
|
815
|
-
- sig/shims/parser/3.2.0.1/parser.rbs
|
|
816
|
-
- sig/shims/parser/3.2.0.1/polyfill.rbs
|
|
817
|
-
- sig/shims/thor/1.2.0.1/.rbs_meta.yaml
|
|
818
|
-
- sig/shims/thor/1.2.0.1/manifest.yaml
|
|
819
|
-
- sig/shims/thor/1.2.0.1/thor.rbs
|
|
820
820
|
- solargraph.gemspec
|
|
821
821
|
homepage: https://solargraph.org
|
|
822
822
|
licenses:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|