solargraph 0.58.3 → 0.59.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/.envrc +3 -0
- data/.github/workflows/linting.yml +12 -5
- data/.github/workflows/plugins.yml +54 -34
- data/.github/workflows/rspec.yml +15 -28
- data/.github/workflows/typecheck.yml +6 -3
- data/.rubocop.yml +38 -6
- data/.rubocop_todo.yml +53 -966
- data/CHANGELOG.md +24 -0
- data/Gemfile +3 -1
- data/README.md +3 -3
- data/Rakefile +26 -23
- data/bin/solargraph +2 -1
- data/lib/solargraph/api_map/cache.rb +3 -3
- data/lib/solargraph/api_map/constants.rb +12 -3
- data/lib/solargraph/api_map/index.rb +29 -18
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +40 -30
- data/lib/solargraph/api_map.rb +160 -78
- data/lib/solargraph/bench.rb +2 -3
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +31 -18
- data/lib/solargraph/complex_type/unique_type.rb +221 -63
- data/lib/solargraph/complex_type.rb +173 -59
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +1 -1
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +7 -5
- data/lib/solargraph/convention/data_definition.rb +5 -2
- data/lib/solargraph/convention/gemfile.rb +1 -1
- data/lib/solargraph/convention/gemspec.rb +1 -1
- data/lib/solargraph/convention/rakefile.rb +1 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +4 -3
- data/lib/solargraph/convention/struct_definition.rb +8 -4
- data/lib/solargraph/convention.rb +2 -2
- data/lib/solargraph/converters/dd.rb +2 -0
- data/lib/solargraph/converters/dl.rb +2 -0
- data/lib/solargraph/converters/dt.rb +2 -0
- data/lib/solargraph/converters/misc.rb +2 -0
- data/lib/solargraph/diagnostics/require_not_found.rb +1 -0
- data/lib/solargraph/diagnostics/rubocop.rb +11 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +5 -3
- data/lib/solargraph/diagnostics/type_check.rb +11 -10
- data/lib/solargraph/diagnostics/update_errors.rb +4 -8
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/doc_map.rb +38 -39
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +4 -15
- data/lib/solargraph/language_server/error_codes.rb +10 -10
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -1
- data/lib/solargraph/language_server/host/dispatch.rb +3 -3
- data/lib/solargraph/language_server/host/message_worker.rb +4 -3
- data/lib/solargraph/language_server/host/sources.rb +2 -1
- data/lib/solargraph/language_server/host.rb +35 -28
- data/lib/solargraph/language_server/message/base.rb +1 -1
- data/lib/solargraph/language_server/message/client/register_capability.rb +1 -3
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +6 -8
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +12 -18
- data/lib/solargraph/language_server/message/extended/document.rb +1 -0
- data/lib/solargraph/language_server/message/extended/document_gems.rb +7 -7
- data/lib/solargraph/language_server/message/extended/download_core.rb +2 -1
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/extended/search.rb +1 -1
- data/lib/solargraph/language_server/message/initialize.rb +20 -14
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- data/lib/solargraph/language_server/message/text_document/completion.rb +10 -8
- data/lib/solargraph/language_server/message/text_document/definition.rb +41 -32
- data/lib/solargraph/language_server/message/text_document/document_highlight.rb +17 -10
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +29 -19
- data/lib/solargraph/language_server/message/text_document/formatting.rb +8 -6
- data/lib/solargraph/language_server/message/text_document/hover.rb +5 -5
- data/lib/solargraph/language_server/message/text_document/prepare_rename.rb +13 -6
- data/lib/solargraph/language_server/message/text_document/references.rb +17 -10
- data/lib/solargraph/language_server/message/text_document/rename.rb +20 -13
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +3 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -17
- data/lib/solargraph/language_server/message/text_document.rb +28 -28
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +34 -28
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +38 -30
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +23 -17
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +1 -1
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/request.rb +4 -2
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server/transport/data_reader.rb +11 -13
- data/lib/solargraph/language_server/uri_helpers.rb +2 -2
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/library.rb +57 -38
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +22 -4
- data/lib/solargraph/page.rb +1 -1
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +324 -108
- data/lib/solargraph/parser/node_processor/base.rb +34 -4
- data/lib/solargraph/parser/node_processor.rb +8 -7
- data/lib/solargraph/parser/parser_gem/class_methods.rb +30 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +51 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +181 -73
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +4 -4
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +13 -11
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +9 -0
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +11 -12
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +36 -36
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +9 -8
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +36 -6
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +5 -3
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +40 -40
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/or_node.rb +22 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +4 -5
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +124 -113
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +6 -2
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/parser/parser_gem.rb +2 -0
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +2 -0
- data/lib/solargraph/pin/base.rb +126 -82
- data/lib/solargraph/pin/base_variable.rb +273 -24
- data/lib/solargraph/pin/block.rb +29 -6
- data/lib/solargraph/pin/breakable.rb +7 -1
- data/lib/solargraph/pin/callable.rb +65 -21
- data/lib/solargraph/pin/closure.rb +7 -10
- data/lib/solargraph/pin/common.rb +24 -6
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/constant.rb +3 -5
- data/lib/solargraph/pin/conversions.rb +10 -4
- data/lib/solargraph/pin/delegated_method.rb +19 -8
- data/lib/solargraph/pin/documenting.rb +4 -2
- data/lib/solargraph/pin/instance_variable.rb +5 -1
- data/lib/solargraph/pin/keyword.rb +0 -4
- data/lib/solargraph/pin/local_variable.rb +15 -59
- data/lib/solargraph/pin/method.rb +158 -104
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +102 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference/type_alias.rb +16 -0
- data/lib/solargraph/pin/reference.rb +20 -0
- data/lib/solargraph/pin/search.rb +8 -7
- data/lib/solargraph/pin/signature.rb +15 -12
- data/lib/solargraph/pin/singleton.rb +11 -11
- data/lib/solargraph/pin/symbol.rb +2 -1
- data/lib/solargraph/pin/until.rb +2 -4
- data/lib/solargraph/pin/while.rb +2 -4
- data/lib/solargraph/pin.rb +2 -0
- data/lib/solargraph/pin_cache.rb +22 -19
- data/lib/solargraph/position.rb +17 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +367 -231
- data/lib/solargraph/rbs_map/core_fills.rb +18 -11
- data/lib/solargraph/rbs_map/core_map.rb +24 -17
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -5
- data/lib/solargraph/rbs_map.rb +76 -32
- data/lib/solargraph/server_methods.rb +1 -1
- data/lib/solargraph/shell.rb +258 -66
- data/lib/solargraph/source/chain/array.rb +3 -12
- data/lib/solargraph/source/chain/block_symbol.rb +13 -13
- data/lib/solargraph/source/chain/block_variable.rb +13 -13
- data/lib/solargraph/source/chain/call.rb +96 -56
- data/lib/solargraph/source/chain/class_variable.rb +1 -1
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +1 -1
- data/lib/solargraph/source/chain/hash.rb +8 -5
- data/lib/solargraph/source/chain/head.rb +19 -19
- data/lib/solargraph/source/chain/if.rb +12 -10
- data/lib/solargraph/source/chain/instance_variable.rb +24 -1
- data/lib/solargraph/source/chain/link.rb +12 -22
- data/lib/solargraph/source/chain/literal.rb +22 -15
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +2 -0
- data/lib/solargraph/source/chain/variable.rb +3 -1
- data/lib/solargraph/source/chain/z_super.rb +1 -3
- data/lib/solargraph/source/chain.rb +51 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +33 -18
- data/lib/solargraph/source/encoding_fixes.rb +6 -7
- data/lib/solargraph/source/source_chainer.rb +56 -32
- data/lib/solargraph/source/updater.rb +5 -1
- data/lib/solargraph/source.rb +59 -35
- data/lib/solargraph/source_map/clip.rb +54 -30
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +69 -42
- data/lib/solargraph/source_map.rb +21 -9
- data/lib/solargraph/type_checker/problem.rb +3 -1
- data/lib/solargraph/type_checker/rules.rb +81 -8
- data/lib/solargraph/type_checker.rb +196 -122
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +50 -28
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- data/lib/solargraph/yard_map/mapper/to_method.rb +13 -7
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +2 -1
- data/lib/solargraph/yard_map/mapper.rb +13 -8
- data/lib/solargraph/yard_map.rb +17 -18
- data/lib/solargraph/yard_tags.rb +2 -2
- data/lib/solargraph/yardoc.rb +7 -4
- data/lib/solargraph.rb +33 -10
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/shims/ast/0/node.rbs +1 -1
- data/rbs/shims/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/solargraph.gemspec +37 -35
- metadata +41 -42
- data/lib/solargraph/type_checker/checks.rb +0 -124
- data/lib/solargraph/type_checker/param_def.rb +0 -37
- data/lib/solargraph/yard_map/to_method.rb +0 -89
- data/rbs/fills/tuple/tuple.rbs +0 -149
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Solargraph
|
|
2
4
|
class YardMap
|
|
3
5
|
module Helpers
|
|
@@ -5,7 +7,7 @@ module Solargraph
|
|
|
5
7
|
|
|
6
8
|
# @param code_object [YARD::CodeObjects::Base]
|
|
7
9
|
# @param spec [Gem::Specification, nil]
|
|
8
|
-
# @return [Solargraph::Location
|
|
10
|
+
# @return [Solargraph::Location]
|
|
9
11
|
def object_location code_object, spec
|
|
10
12
|
if spec.nil? || code_object.nil? || code_object.file.nil? || code_object.line.nil?
|
|
11
13
|
if code_object.namespace.is_a?(YARD::CodeObjects::NamespaceObject)
|
|
@@ -14,6 +16,7 @@ module Solargraph
|
|
|
14
16
|
end
|
|
15
17
|
return Solargraph::Location.new(__FILE__, Solargraph::Range.from_to(__LINE__ - 1, 0, __LINE__ - 1, 0))
|
|
16
18
|
end
|
|
19
|
+
# @sg-ignore flow sensitive typing should be able to identify more blocks that always return
|
|
17
20
|
file = File.join(spec.full_gem_path, code_object.file)
|
|
18
21
|
Solargraph::Location.new(file, Solargraph::Range.from_to(code_object.line - 1, 0, code_object.line - 1, 0))
|
|
19
22
|
end
|
|
@@ -21,10 +24,12 @@ module Solargraph
|
|
|
21
24
|
# @param code_object [YARD::CodeObjects::Base]
|
|
22
25
|
# @param spec [Gem::Specification, nil]
|
|
23
26
|
# @return [Solargraph::Pin::Namespace]
|
|
24
|
-
def create_closure_namespace_for
|
|
27
|
+
def create_closure_namespace_for code_object, spec
|
|
25
28
|
code_object_for_location = code_object
|
|
26
29
|
# code_object.namespace is sometimes a YARD proxy object pointing to a method path ("Object#new")
|
|
27
|
-
|
|
30
|
+
if code_object.namespace.is_a?(YARD::CodeObjects::NamespaceObject)
|
|
31
|
+
code_object_for_location = code_object.namespace
|
|
32
|
+
end
|
|
28
33
|
namespace_location = object_location(code_object_for_location, spec)
|
|
29
34
|
ns_name = code_object.namespace.to_s
|
|
30
35
|
if ns_name.empty?
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
class YardMap
|
|
5
|
-
class Mapper
|
|
6
|
-
module ToConstant
|
|
7
|
-
extend YardMap::Helpers
|
|
8
|
-
|
|
9
|
-
# @param code_object [YARD::CodeObjects::Base]
|
|
10
|
-
# @param closure [Pin::Closure, nil]
|
|
11
|
-
# @param spec [Gem::Specification, nil]
|
|
12
|
-
# @return [Pin::Constant]
|
|
13
|
-
def self.make code_object, closure = nil, spec = nil
|
|
14
|
-
closure ||= create_closure_namespace_for(code_object, spec)
|
|
15
|
-
|
|
16
|
-
Pin::Constant.new(
|
|
17
|
-
location: object_location(code_object, spec),
|
|
18
|
-
closure: closure,
|
|
19
|
-
name: code_object.name.to_s,
|
|
20
|
-
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
|
21
|
-
visibility: code_object.visibility,
|
|
22
|
-
source: :yardoc
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class YardMap
|
|
5
|
+
class Mapper
|
|
6
|
+
module ToConstant
|
|
7
|
+
extend YardMap::Helpers
|
|
8
|
+
|
|
9
|
+
# @param code_object [YARD::CodeObjects::Base]
|
|
10
|
+
# @param closure [Pin::Closure, nil]
|
|
11
|
+
# @param spec [Gem::Specification, nil]
|
|
12
|
+
# @return [Pin::Constant]
|
|
13
|
+
def self.make code_object, closure = nil, spec = nil
|
|
14
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
|
15
|
+
|
|
16
|
+
Pin::Constant.new(
|
|
17
|
+
location: object_location(code_object, spec),
|
|
18
|
+
closure: closure,
|
|
19
|
+
name: code_object.name.to_s,
|
|
20
|
+
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
|
21
|
+
visibility: code_object.visibility,
|
|
22
|
+
source: :yardoc
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -6,10 +6,11 @@ module Solargraph
|
|
|
6
6
|
module ToMethod
|
|
7
7
|
extend YardMap::Helpers
|
|
8
8
|
|
|
9
|
+
# @type [Hash{Array<String, Symbol, String> => Symbol}]
|
|
9
10
|
VISIBILITY_OVERRIDE = {
|
|
10
11
|
# YARD pays attention to 'private' statements prior to class methods but shouldn't
|
|
11
|
-
[
|
|
12
|
-
}
|
|
12
|
+
['Rails::Engine', :class, 'find_root_with_flag'] => :public
|
|
13
|
+
}.freeze
|
|
13
14
|
|
|
14
15
|
# @param code_object [YARD::CodeObjects::MethodObject]
|
|
15
16
|
# @param name [String, nil]
|
|
@@ -25,10 +26,15 @@ module Solargraph
|
|
|
25
26
|
return_type = ComplexType::SELF if name == 'new'
|
|
26
27
|
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
|
27
28
|
final_scope = scope || code_object.scope
|
|
29
|
+
# @sg-ignore Need to add nil check here
|
|
28
30
|
override_key = [closure.path, final_scope, name]
|
|
29
31
|
final_visibility = VISIBILITY_OVERRIDE[override_key]
|
|
32
|
+
# @sg-ignore Need to add nil check here
|
|
30
33
|
final_visibility ||= VISIBILITY_OVERRIDE[[closure.path, final_scope]]
|
|
31
|
-
|
|
34
|
+
# @sg-ignore Need to add nil check here
|
|
35
|
+
if closure.path == 'Kernel' && Kernel.private_method_defined?(name.to_sym, false)
|
|
36
|
+
final_visibility ||= :private
|
|
37
|
+
end
|
|
32
38
|
final_visibility ||= visibility
|
|
33
39
|
final_visibility ||= :private if code_object.module_function? && final_scope == :instance
|
|
34
40
|
final_visibility ||= :public if code_object.module_function? && final_scope == :class
|
|
@@ -46,9 +52,10 @@ module Solargraph
|
|
|
46
52
|
explicit: code_object.is_explicit?,
|
|
47
53
|
return_type: return_type,
|
|
48
54
|
parameters: [],
|
|
49
|
-
source: :yardoc
|
|
55
|
+
source: :yardoc
|
|
50
56
|
)
|
|
51
57
|
else
|
|
58
|
+
# @sg-ignore Need to add nil check here
|
|
52
59
|
pin = Pin::Method.new(
|
|
53
60
|
location: location,
|
|
54
61
|
closure: closure,
|
|
@@ -61,7 +68,7 @@ module Solargraph
|
|
|
61
68
|
return_type: return_type,
|
|
62
69
|
attribute: code_object.is_attribute?,
|
|
63
70
|
parameters: [],
|
|
64
|
-
source: :yardoc
|
|
71
|
+
source: :yardoc
|
|
65
72
|
)
|
|
66
73
|
pin.parameters.concat get_parameters(code_object, location, comments, pin)
|
|
67
74
|
pin.parameters.freeze
|
|
@@ -85,7 +92,6 @@ module Solargraph
|
|
|
85
92
|
# HACK: Skip `nil` and `self` parameters that are sometimes emitted
|
|
86
93
|
# for methods defined in C
|
|
87
94
|
# See https://github.com/castwide/solargraph/issues/345
|
|
88
|
-
# @sg-ignore https://github.com/castwide/solargraph/pull/1114
|
|
89
95
|
code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
|
|
90
96
|
Solargraph::Pin::Parameter.new(
|
|
91
97
|
location: location,
|
|
@@ -95,7 +101,7 @@ module Solargraph
|
|
|
95
101
|
presence: nil,
|
|
96
102
|
decl: arg_type(a),
|
|
97
103
|
asgn_code: a[1],
|
|
98
|
-
source: :yardoc
|
|
104
|
+
source: :yardoc
|
|
99
105
|
)
|
|
100
106
|
end
|
|
101
107
|
end
|
|
@@ -21,8 +21,9 @@ module Solargraph
|
|
|
21
21
|
type: code_object.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
|
22
22
|
visibility: code_object.visibility,
|
|
23
23
|
closure: closure,
|
|
24
|
+
# @sg-ignore need to add a nil check here
|
|
24
25
|
gates: closure.gates,
|
|
25
|
-
source: :yardoc
|
|
26
|
+
source: :yardoc
|
|
26
27
|
)
|
|
27
28
|
end
|
|
28
29
|
end
|
|
@@ -24,6 +24,7 @@ module Solargraph
|
|
|
24
24
|
end
|
|
25
25
|
# Some yardocs contain documentation for dependencies that can be
|
|
26
26
|
# ignored here. The YardMap will load dependencies separately.
|
|
27
|
+
# @sg-ignore Need to add nil check here
|
|
27
28
|
@pins.keep_if { |pin| pin.location.nil? || File.file?(pin.location.filename) } if @spec
|
|
28
29
|
@pins
|
|
29
30
|
end
|
|
@@ -34,24 +35,27 @@ module Solargraph
|
|
|
34
35
|
# @return [Array<Pin::Base>]
|
|
35
36
|
def generate_pins code_object
|
|
36
37
|
result = []
|
|
37
|
-
|
|
38
|
+
case code_object
|
|
39
|
+
when YARD::CodeObjects::NamespaceObject
|
|
38
40
|
nspin = ToNamespace.make(code_object, @spec, @namespace_pins[code_object.namespace.to_s])
|
|
39
41
|
@namespace_pins[code_object.path] = nspin
|
|
40
42
|
result.push nspin
|
|
41
|
-
if code_object.is_a?(YARD::CodeObjects::ClassObject)
|
|
43
|
+
if code_object.is_a?(YARD::CodeObjects::ClassObject) && !code_object.superclass.nil?
|
|
42
44
|
# This method of superclass detection is a bit of a hack. If
|
|
43
45
|
# the superclass is a Proxy, it is assumed to be undefined in its
|
|
44
46
|
# yardoc and converted to a fully qualified namespace.
|
|
45
47
|
superclass = if code_object.superclass.is_a?(YARD::CodeObjects::Proxy)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
"::#{code_object.superclass}"
|
|
49
|
+
else
|
|
50
|
+
code_object.superclass.to_s
|
|
51
|
+
end
|
|
50
52
|
result.push Solargraph::Pin::Reference::Superclass.new(name: superclass, closure: nspin, source: :yard_map)
|
|
51
53
|
end
|
|
54
|
+
# @sg-ignore flow sensitive typing ought to be able to handle 'when ClassName'
|
|
52
55
|
code_object.class_mixins.each do |m|
|
|
53
56
|
result.push Solargraph::Pin::Reference::Extend.new(closure: nspin, name: m.path, source: :yard_map)
|
|
54
57
|
end
|
|
58
|
+
# @sg-ignore flow sensitive typing ought to be able to handle 'when ClassName'
|
|
55
59
|
code_object.instance_mixins.each do |m|
|
|
56
60
|
result.push Solargraph::Pin::Reference::Include.new(
|
|
57
61
|
closure: nspin, # @todo Fix this
|
|
@@ -59,8 +63,9 @@ module Solargraph
|
|
|
59
63
|
source: :yard_map
|
|
60
64
|
)
|
|
61
65
|
end
|
|
62
|
-
|
|
66
|
+
when YARD::CodeObjects::MethodObject
|
|
63
67
|
closure = @namespace_pins[code_object.namespace.to_s]
|
|
68
|
+
# @sg-ignore flow sensitive typing ought to be able to handle 'when ClassName'
|
|
64
69
|
if code_object.name == :initialize && code_object.scope == :instance
|
|
65
70
|
# @todo Check the visibility of <Class>.new
|
|
66
71
|
result.push ToMethod.make(code_object, 'new', :class, :public, closure, @spec)
|
|
@@ -68,7 +73,7 @@ module Solargraph
|
|
|
68
73
|
else
|
|
69
74
|
result.push ToMethod.make(code_object, nil, nil, nil, closure, @spec)
|
|
70
75
|
end
|
|
71
|
-
|
|
76
|
+
when YARD::CodeObjects::ConstantObject
|
|
72
77
|
closure = @namespace_pins[code_object.namespace]
|
|
73
78
|
result.push ToConstant.make(code_object, closure, @spec)
|
|
74
79
|
end
|
data/lib/solargraph/yard_map.rb
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'yard'
|
|
4
|
-
require 'solargraph/yard_tags'
|
|
5
|
-
|
|
6
|
-
module Solargraph
|
|
7
|
-
# The YardMap provides access to YARD documentation for the Ruby core, the
|
|
8
|
-
# stdlib, and gems.
|
|
9
|
-
#
|
|
10
|
-
class YardMap
|
|
11
|
-
class NoYardocError < StandardError; end
|
|
12
|
-
|
|
13
|
-
autoload :Cache, 'solargraph/yard_map/cache'
|
|
14
|
-
autoload :Mapper, 'solargraph/yard_map/mapper'
|
|
15
|
-
autoload :Helpers, 'solargraph/yard_map/helpers'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yard'
|
|
4
|
+
require 'solargraph/yard_tags'
|
|
5
|
+
|
|
6
|
+
module Solargraph
|
|
7
|
+
# The YardMap provides access to YARD documentation for the Ruby core, the
|
|
8
|
+
# stdlib, and gems.
|
|
9
|
+
#
|
|
10
|
+
class YardMap
|
|
11
|
+
class NoYardocError < StandardError; end
|
|
12
|
+
|
|
13
|
+
autoload :Cache, 'solargraph/yard_map/cache'
|
|
14
|
+
autoload :Mapper, 'solargraph/yard_map/mapper'
|
|
15
|
+
autoload :Helpers, 'solargraph/yard_map/helpers'
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/solargraph/yard_tags.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Define a @type tag for documenting variables
|
|
17
|
-
YARD::Tags::Library.define_tag(
|
|
17
|
+
YARD::Tags::Library.define_tag('Type', :type, :with_types_and_name)
|
|
18
18
|
|
|
19
19
|
# Define an @!override directive for overriding method tags
|
|
20
|
-
YARD::Tags::Library.define_directive(
|
|
20
|
+
YARD::Tags::Library.define_directive('override', :with_name, Solargraph::DomainDirective)
|
data/lib/solargraph/yardoc.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
|
14
14
|
# @param yard_plugins [Array<String>] The names of YARD plugins to use.
|
|
15
15
|
# @param gemspec [Gem::Specification]
|
|
16
16
|
# @return [String] The path to the cached yardoc.
|
|
17
|
-
def cache
|
|
17
|
+
def cache yard_plugins, gemspec
|
|
18
18
|
path = PinCache.yardoc_path gemspec
|
|
19
19
|
return path if cached?(gemspec)
|
|
20
20
|
|
|
@@ -32,6 +32,8 @@ module Solargraph
|
|
|
32
32
|
yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" }
|
|
33
33
|
Solargraph.logger.debug { "Running: #{cmd}" }
|
|
34
34
|
# @todo set these up to run in parallel
|
|
35
|
+
# @todo Is the chdir argument being used here?
|
|
36
|
+
# @sg-ignore Unrecognized keyword argument chdir to Open3.capture2e
|
|
35
37
|
stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir)
|
|
36
38
|
unless status.success?
|
|
37
39
|
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" }
|
|
@@ -43,7 +45,7 @@ module Solargraph
|
|
|
43
45
|
# True if the gem yardoc is cached.
|
|
44
46
|
#
|
|
45
47
|
# @param gemspec [Gem::Specification]
|
|
46
|
-
def cached?
|
|
48
|
+
def cached? gemspec
|
|
47
49
|
yardoc = File.join(PinCache.yardoc_path(gemspec), 'complete')
|
|
48
50
|
File.exist?(yardoc)
|
|
49
51
|
end
|
|
@@ -51,7 +53,7 @@ module Solargraph
|
|
|
51
53
|
# True if another process is currently building the yardoc cache.
|
|
52
54
|
#
|
|
53
55
|
# @param gemspec [Gem::Specification]
|
|
54
|
-
def processing?
|
|
56
|
+
def processing? gemspec
|
|
55
57
|
yardoc = File.join(PinCache.yardoc_path(gemspec), 'processing')
|
|
56
58
|
File.exist?(yardoc)
|
|
57
59
|
end
|
|
@@ -62,7 +64,7 @@ module Solargraph
|
|
|
62
64
|
#
|
|
63
65
|
# @param gemspec [Gem::Specification]
|
|
64
66
|
# @return [Array<YARD::CodeObjects::Base>]
|
|
65
|
-
def load!
|
|
67
|
+
def load! gemspec
|
|
66
68
|
YARD::Registry.load! PinCache.yardoc_path gemspec
|
|
67
69
|
YARD::Registry.all
|
|
68
70
|
end
|
|
@@ -78,6 +80,7 @@ module Solargraph
|
|
|
78
80
|
# @return [Hash{String => String}] a hash of environment variables to override
|
|
79
81
|
def current_bundle_env_tweaks
|
|
80
82
|
tweaks = {}
|
|
83
|
+
# @sg-ignore Unresolved call to empty? on String, nil
|
|
81
84
|
if ENV['BUNDLE_GEMFILE'] && !ENV['BUNDLE_GEMFILE'].empty?
|
|
82
85
|
tweaks['BUNDLE_GEMFILE'] = File.expand_path(ENV['BUNDLE_GEMFILE'])
|
|
83
86
|
end
|
data/lib/solargraph.rb
CHANGED
|
@@ -55,8 +55,8 @@ module Solargraph
|
|
|
55
55
|
|
|
56
56
|
CHDIR_MUTEX = Mutex.new
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
def self.asserts_on?
|
|
59
|
+
# @sg-ignore Translate to something flow sensitive typing understands
|
|
60
60
|
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
|
|
61
61
|
false
|
|
62
62
|
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
|
|
@@ -71,8 +71,31 @@ module Solargraph
|
|
|
71
71
|
# @param msg [String, nil] An optional message to log
|
|
72
72
|
# @param block [Proc] A block that returns a message to log
|
|
73
73
|
# @return [void]
|
|
74
|
-
def self.assert_or_log
|
|
75
|
-
|
|
74
|
+
def self.assert_or_log type, msg = nil, &block
|
|
75
|
+
if asserts_on?
|
|
76
|
+
# @type [String, nil]
|
|
77
|
+
msg ||= block.call
|
|
78
|
+
|
|
79
|
+
raise "No message given for #{type.inspect}" if msg.nil?
|
|
80
|
+
|
|
81
|
+
# conditional aliases to handle compatibility corner cases
|
|
82
|
+
# @sg-ignore flow sensitive typing needs to handle 'raise if'
|
|
83
|
+
return if type == :alias_target_missing && msg.include?('highline/compatibility.rb')
|
|
84
|
+
# @sg-ignore flow sensitive typing needs to handle 'raise if'
|
|
85
|
+
return if type == :alias_target_missing && msg.include?('lib/json/add/date.rb')
|
|
86
|
+
# @sg-ignore flow sensitive typing needs to handle 'raise if'
|
|
87
|
+
return if type == :alias_target_missing && msg.include?('rubocop-ast.rbs')
|
|
88
|
+
# @todo :combine_with_visibility is not ready for prime time -
|
|
89
|
+
# lots of disagreements found in practice that heuristics need
|
|
90
|
+
# to be created for and/or debugging needs to resolve in pin
|
|
91
|
+
# generation.
|
|
92
|
+
# @todo :api_map_namespace_pin_stack triggers in a badly handled
|
|
93
|
+
# self type case - 'keeps track of self type in method
|
|
94
|
+
# parameters in subclass' in call_spec.rb
|
|
95
|
+
return if %i[api_map_namespace_pin_stack combine_with_visibility].include?(type)
|
|
96
|
+
|
|
97
|
+
raise msg
|
|
98
|
+
end
|
|
76
99
|
logger.info msg, &block
|
|
77
100
|
end
|
|
78
101
|
|
|
@@ -90,13 +113,13 @@ module Solargraph
|
|
|
90
113
|
# @yieldreturn [generic<T>]
|
|
91
114
|
# @sg-ignore dynamic call, but both functions behave the same
|
|
92
115
|
# @return [generic<T>]
|
|
93
|
-
def self.with_clean_env
|
|
116
|
+
def self.with_clean_env(&)
|
|
94
117
|
meth = if Bundler.respond_to?(:with_original_env)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Bundler.send
|
|
118
|
+
:with_original_env
|
|
119
|
+
else
|
|
120
|
+
:with_clean_env
|
|
121
|
+
end
|
|
122
|
+
Bundler.send(meth, &)
|
|
100
123
|
end
|
|
101
124
|
end
|
|
102
125
|
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# <!-- rdoc-file=lib/rubygems/dependency.rb -->
|
|
2
|
+
# The Dependency class holds a Gem name and a Gem::Requirement.
|
|
3
|
+
#
|
|
4
|
+
class Gem::Dependency
|
|
5
|
+
@name: untyped
|
|
6
|
+
|
|
7
|
+
@requirement: untyped
|
|
8
|
+
|
|
9
|
+
@type: untyped
|
|
10
|
+
|
|
11
|
+
@prerelease: untyped
|
|
12
|
+
|
|
13
|
+
@version_requirements: untyped
|
|
14
|
+
|
|
15
|
+
@version_requirement: untyped
|
|
16
|
+
|
|
17
|
+
# <!-- rdoc-file=lib/rubygems/dependency.rb -->
|
|
18
|
+
# Valid dependency types.
|
|
19
|
+
#
|
|
20
|
+
TYPES: ::Array[:development | :runtime]
|
|
21
|
+
|
|
22
|
+
# <!-- rdoc-file=lib/rubygems/dependency.rb -->
|
|
23
|
+
# Dependency name or regular expression.
|
|
24
|
+
#
|
|
25
|
+
attr_accessor name: untyped
|
|
26
|
+
|
|
27
|
+
# <!-- rdoc-file=lib/rubygems/dependency.rb -->
|
|
28
|
+
# Allows you to force this dependency to be a prerelease.
|
|
29
|
+
#
|
|
30
|
+
attr_writer prerelease: untyped
|
|
31
|
+
|
|
32
|
+
# <!--
|
|
33
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
34
|
+
# - new(name, *requirements)
|
|
35
|
+
# -->
|
|
36
|
+
# Constructs a dependency with `name` and `requirements`. The last argument can
|
|
37
|
+
# optionally be the dependency type, which defaults to `:runtime`.
|
|
38
|
+
#
|
|
39
|
+
def initialize: (untyped name, *untyped requirements) -> void
|
|
40
|
+
|
|
41
|
+
def hash: () -> untyped
|
|
42
|
+
|
|
43
|
+
def inspect: () -> untyped
|
|
44
|
+
|
|
45
|
+
# <!--
|
|
46
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
47
|
+
# - prerelease?()
|
|
48
|
+
# -->
|
|
49
|
+
# Does this dependency require a prerelease?
|
|
50
|
+
#
|
|
51
|
+
def prerelease?: () -> untyped
|
|
52
|
+
|
|
53
|
+
# <!--
|
|
54
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
55
|
+
# - latest_version?()
|
|
56
|
+
# -->
|
|
57
|
+
# Is this dependency simply asking for the latest version of a gem?
|
|
58
|
+
#
|
|
59
|
+
def latest_version?: () -> untyped
|
|
60
|
+
|
|
61
|
+
def pretty_print: (untyped q) -> untyped
|
|
62
|
+
|
|
63
|
+
# <!--
|
|
64
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
65
|
+
# - requirement()
|
|
66
|
+
# -->
|
|
67
|
+
# What does this dependency require?
|
|
68
|
+
#
|
|
69
|
+
def requirement: () -> untyped
|
|
70
|
+
|
|
71
|
+
# <!--
|
|
72
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
73
|
+
# - requirements_list()
|
|
74
|
+
# -->
|
|
75
|
+
#
|
|
76
|
+
def requirements_list: () -> untyped
|
|
77
|
+
|
|
78
|
+
def to_s: () -> ::String
|
|
79
|
+
|
|
80
|
+
# <!--
|
|
81
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
82
|
+
# - type()
|
|
83
|
+
# -->
|
|
84
|
+
# Dependency type.
|
|
85
|
+
#
|
|
86
|
+
def type: () -> untyped
|
|
87
|
+
|
|
88
|
+
# <!--
|
|
89
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
90
|
+
# - runtime?()
|
|
91
|
+
# -->
|
|
92
|
+
#
|
|
93
|
+
def runtime?: () -> untyped
|
|
94
|
+
|
|
95
|
+
def ==: (untyped other) -> untyped
|
|
96
|
+
|
|
97
|
+
# <!--
|
|
98
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
99
|
+
# - <=>(other)
|
|
100
|
+
# -->
|
|
101
|
+
# Dependencies are ordered by name.
|
|
102
|
+
#
|
|
103
|
+
def <=>: (untyped other) -> untyped
|
|
104
|
+
|
|
105
|
+
# <!--
|
|
106
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
107
|
+
# - =~(other)
|
|
108
|
+
# -->
|
|
109
|
+
# Uses this dependency as a pattern to compare to `other`. This dependency will
|
|
110
|
+
# match if the name matches the other's name, and other has only an equal
|
|
111
|
+
# version requirement that satisfies this dependency.
|
|
112
|
+
#
|
|
113
|
+
def =~: (untyped other) -> (nil | false | untyped)
|
|
114
|
+
|
|
115
|
+
# <!--
|
|
116
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
117
|
+
# - ===(other)
|
|
118
|
+
# -->
|
|
119
|
+
#
|
|
120
|
+
alias === =~
|
|
121
|
+
|
|
122
|
+
# <!--
|
|
123
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
124
|
+
# - dep.match? name => true or false
|
|
125
|
+
# - dep.match? name, version => true or false
|
|
126
|
+
# - dep.match? spec => true or false
|
|
127
|
+
# -->
|
|
128
|
+
# Does this dependency match the specification described by `name` and `version`
|
|
129
|
+
# or match `spec`?
|
|
130
|
+
#
|
|
131
|
+
# NOTE: Unlike #matches_spec? this method does not return true when the version
|
|
132
|
+
# is a prerelease version unless this is a prerelease dependency.
|
|
133
|
+
#
|
|
134
|
+
def match?: (untyped obj, ?untyped? version, ?bool allow_prerelease) -> (false | true | untyped)
|
|
135
|
+
|
|
136
|
+
# <!--
|
|
137
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
138
|
+
# - matches_spec?(spec)
|
|
139
|
+
# -->
|
|
140
|
+
# Does this dependency match `spec`?
|
|
141
|
+
#
|
|
142
|
+
# NOTE: This is not a convenience method. Unlike #match? this method returns
|
|
143
|
+
# true when `spec` is a prerelease version even if this dependency is not a
|
|
144
|
+
# prerelease dependency.
|
|
145
|
+
#
|
|
146
|
+
def matches_spec?: (untyped spec) -> (false | true | untyped)
|
|
147
|
+
|
|
148
|
+
# <!--
|
|
149
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
150
|
+
# - merge(other)
|
|
151
|
+
# -->
|
|
152
|
+
# Merges the requirements of `other` into this dependency
|
|
153
|
+
#
|
|
154
|
+
def merge: (untyped other) -> untyped
|
|
155
|
+
|
|
156
|
+
# <!--
|
|
157
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
158
|
+
# - matching_specs(platform_only = false)
|
|
159
|
+
# -->
|
|
160
|
+
#
|
|
161
|
+
def matching_specs: (?bool platform_only) -> untyped
|
|
162
|
+
|
|
163
|
+
# <!--
|
|
164
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
165
|
+
# - specific?()
|
|
166
|
+
# -->
|
|
167
|
+
# True if the dependency will not always match the latest version.
|
|
168
|
+
#
|
|
169
|
+
def specific?: () -> untyped
|
|
170
|
+
|
|
171
|
+
# <!--
|
|
172
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
173
|
+
# - to_specs()
|
|
174
|
+
# -->
|
|
175
|
+
#
|
|
176
|
+
def to_specs: () -> untyped
|
|
177
|
+
|
|
178
|
+
# <!--
|
|
179
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
180
|
+
# - to_spec()
|
|
181
|
+
# -->
|
|
182
|
+
#
|
|
183
|
+
def to_spec: () -> untyped
|
|
184
|
+
|
|
185
|
+
# <!--
|
|
186
|
+
# rdoc-file=lib/rubygems/dependency.rb
|
|
187
|
+
# - identity()
|
|
188
|
+
# -->
|
|
189
|
+
#
|
|
190
|
+
def identity: () -> (:complete | :abs_latest | :latest | :released)
|
|
191
|
+
|
|
192
|
+
def encode_with: (untyped coder) -> untyped
|
|
193
|
+
end
|
data/rbs/shims/ast/0/node.rbs
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Diff
|
|
2
|
+
end
|
|
3
|
+
|
|
4
|
+
module Diff::LCS
|
|
5
|
+
def self.LCS: (Array[String], Array[String]) -> Array[String]
|
|
6
|
+
| (String, String) -> Array[String]
|
|
7
|
+
def self.diff: (Array[String], Array[String]) -> Array[Array[String]]
|
|
8
|
+
| (String, String) -> Array[Array[Diff::LCS::Change]]
|
|
9
|
+
|
|
10
|
+
def self.patch!: (Array[String], Array[String]) -> String
|
|
11
|
+
end
|