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,111 +1,111 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Convention
|
|
5
|
-
# ActiveSupport::Concern is syntactic sugar for a common
|
|
6
|
-
# pattern to include class methods while mixing-in a Module
|
|
7
|
-
# See https://api.rubyonrails.org/classes/ActiveSupport/Concern.html
|
|
8
|
-
class ActiveSupportConcern < Base
|
|
9
|
-
include Logging
|
|
10
|
-
|
|
11
|
-
# @return [Array<Pin::Base>]
|
|
12
|
-
attr_reader :pins
|
|
13
|
-
|
|
14
|
-
# @param api_map [ApiMap]
|
|
15
|
-
# @param rooted_tag [String]
|
|
16
|
-
# @param scope [Symbol] :class or :instance
|
|
17
|
-
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
18
|
-
# @param deep [Boolean] whether to include methods from included modules
|
|
19
|
-
# @param skip [Set<String>]
|
|
20
|
-
# @param _no_core [Boolean]n whether to skip core methods
|
|
21
|
-
def object api_map, rooted_tag, scope, visibility, deep, skip, _no_core
|
|
22
|
-
moo = ObjectProcessor.new(api_map, rooted_tag, scope, visibility, deep, skip)
|
|
23
|
-
moo.environ
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# yard-activesupport-concern pulls methods inside
|
|
27
|
-
# 'class_methods' blocks into main class visible from YARD
|
|
28
|
-
#
|
|
29
|
-
# @param _doc_map [DocMap]
|
|
30
|
-
def global _doc_map
|
|
31
|
-
Environ.new(yard_plugins: ['activesupport-concern'])
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Process an object to add any class methods brought in via
|
|
35
|
-
# ActiveSupport::Concern
|
|
36
|
-
class ObjectProcessor
|
|
37
|
-
include Logging
|
|
38
|
-
|
|
39
|
-
attr_reader :environ
|
|
40
|
-
|
|
41
|
-
# @param api_map [ApiMap]
|
|
42
|
-
# @param rooted_tag [String] the tag of the class or module being processed
|
|
43
|
-
# @param scope [Symbol] :class or :instance
|
|
44
|
-
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
45
|
-
# @param deep [Boolean] whether to include methods from included modules
|
|
46
|
-
# @param skip [Set<String>] a set of tags to skip
|
|
47
|
-
def initialize api_map, rooted_tag, scope, visibility, deep, skip
|
|
48
|
-
@api_map = api_map
|
|
49
|
-
@rooted_tag = rooted_tag
|
|
50
|
-
@scope = scope
|
|
51
|
-
@visibility = visibility
|
|
52
|
-
@deep = deep
|
|
53
|
-
@skip = skip
|
|
54
|
-
|
|
55
|
-
@environ = Environ.new
|
|
56
|
-
return unless scope == :class
|
|
57
|
-
|
|
58
|
-
@rooted_type = ComplexType.parse(rooted_tag).force_rooted
|
|
59
|
-
@fqns = rooted_type.namespace
|
|
60
|
-
@namespace_pin = api_map.get_path_pins(fqns).select { |p| p.is_a?(Pin::Namespace) }.first
|
|
61
|
-
|
|
62
|
-
api_map.get_includes(fqns).reverse.each do |include_tag|
|
|
63
|
-
process_include include_tag
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
private
|
|
68
|
-
|
|
69
|
-
attr_reader :api_map, :rooted_tag, :rooted_type, :scope,
|
|
70
|
-
:visibility, :deep, :skip, :namespace_pin,
|
|
71
|
-
:fqns
|
|
72
|
-
|
|
73
|
-
# @param include_tag [Pin::Reference::Include] the include reference pin
|
|
74
|
-
#
|
|
75
|
-
# @return [void]
|
|
76
|
-
def process_include include_tag
|
|
77
|
-
rooted_include_tag = api_map.dereference(include_tag)
|
|
78
|
-
return if rooted_include_tag.nil?
|
|
79
|
-
logger.debug do
|
|
80
|
-
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
81
|
-
"Handling class include include_tag=#{include_tag}"
|
|
82
|
-
end
|
|
83
|
-
module_extends = api_map.get_extends(rooted_include_tag).map(&:type).map(&:to_s)
|
|
84
|
-
logger.debug do
|
|
85
|
-
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
86
|
-
"found module extends of #{rooted_include_tag}: #{module_extends}"
|
|
87
|
-
end
|
|
88
|
-
return unless module_extends.include? 'ActiveSupport::Concern'
|
|
89
|
-
included_class_pins = api_map.inner_get_methods_from_reference(rooted_include_tag, namespace_pin, rooted_type,
|
|
90
|
-
:class, visibility, deep, skip, true)
|
|
91
|
-
logger.debug do
|
|
92
|
-
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
93
|
-
"Found #{included_class_pins.length} inluded class methods for #{rooted_include_tag}"
|
|
94
|
-
end
|
|
95
|
-
environ.pins.concat included_class_pins
|
|
96
|
-
# another pattern is to put class methods inside a submodule
|
|
97
|
-
classmethods_include_tag = "#{rooted_include_tag}::ClassMethods"
|
|
98
|
-
included_classmethods_pins =
|
|
99
|
-
api_map.inner_get_methods_from_reference(classmethods_include_tag, namespace_pin, rooted_type,
|
|
100
|
-
:instance, visibility, deep, skip, true)
|
|
101
|
-
logger.debug do
|
|
102
|
-
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
103
|
-
"Found #{included_classmethods_pins.length} included classmethod " \
|
|
104
|
-
"class methods for #{classmethods_include_tag}"
|
|
105
|
-
end
|
|
106
|
-
environ.pins.concat included_classmethods_pins
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Convention
|
|
5
|
+
# ActiveSupport::Concern is syntactic sugar for a common
|
|
6
|
+
# pattern to include class methods while mixing-in a Module
|
|
7
|
+
# See https://api.rubyonrails.org/classes/ActiveSupport/Concern.html
|
|
8
|
+
class ActiveSupportConcern < Base
|
|
9
|
+
include Logging
|
|
10
|
+
|
|
11
|
+
# @return [Array<Pin::Base>]
|
|
12
|
+
attr_reader :pins
|
|
13
|
+
|
|
14
|
+
# @param api_map [ApiMap]
|
|
15
|
+
# @param rooted_tag [String]
|
|
16
|
+
# @param scope [Symbol] :class or :instance
|
|
17
|
+
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
18
|
+
# @param deep [Boolean] whether to include methods from included modules
|
|
19
|
+
# @param skip [Set<String>]
|
|
20
|
+
# @param _no_core [Boolean]n whether to skip core methods
|
|
21
|
+
def object api_map, rooted_tag, scope, visibility, deep, skip, _no_core
|
|
22
|
+
moo = ObjectProcessor.new(api_map, rooted_tag, scope, visibility, deep, skip)
|
|
23
|
+
moo.environ
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# yard-activesupport-concern pulls methods inside
|
|
27
|
+
# 'class_methods' blocks into main class visible from YARD
|
|
28
|
+
#
|
|
29
|
+
# @param _doc_map [DocMap]
|
|
30
|
+
def global _doc_map
|
|
31
|
+
Environ.new(yard_plugins: ['activesupport-concern'])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Process an object to add any class methods brought in via
|
|
35
|
+
# ActiveSupport::Concern
|
|
36
|
+
class ObjectProcessor
|
|
37
|
+
include Logging
|
|
38
|
+
|
|
39
|
+
attr_reader :environ
|
|
40
|
+
|
|
41
|
+
# @param api_map [ApiMap]
|
|
42
|
+
# @param rooted_tag [String] the tag of the class or module being processed
|
|
43
|
+
# @param scope [Symbol] :class or :instance
|
|
44
|
+
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
45
|
+
# @param deep [Boolean] whether to include methods from included modules
|
|
46
|
+
# @param skip [Set<String>] a set of tags to skip
|
|
47
|
+
def initialize api_map, rooted_tag, scope, visibility, deep, skip
|
|
48
|
+
@api_map = api_map
|
|
49
|
+
@rooted_tag = rooted_tag
|
|
50
|
+
@scope = scope
|
|
51
|
+
@visibility = visibility
|
|
52
|
+
@deep = deep
|
|
53
|
+
@skip = skip
|
|
54
|
+
|
|
55
|
+
@environ = Environ.new
|
|
56
|
+
return unless scope == :class
|
|
57
|
+
|
|
58
|
+
@rooted_type = ComplexType.parse(rooted_tag).force_rooted
|
|
59
|
+
@fqns = rooted_type.namespace
|
|
60
|
+
@namespace_pin = api_map.get_path_pins(fqns).select { |p| p.is_a?(Pin::Namespace) }.first
|
|
61
|
+
|
|
62
|
+
api_map.get_includes(fqns).reverse.each do |include_tag|
|
|
63
|
+
process_include include_tag
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
attr_reader :api_map, :rooted_tag, :rooted_type, :scope,
|
|
70
|
+
:visibility, :deep, :skip, :namespace_pin,
|
|
71
|
+
:fqns
|
|
72
|
+
|
|
73
|
+
# @param include_tag [Pin::Reference::Include] the include reference pin
|
|
74
|
+
#
|
|
75
|
+
# @return [void]
|
|
76
|
+
def process_include include_tag
|
|
77
|
+
rooted_include_tag = api_map.dereference(include_tag)
|
|
78
|
+
return if rooted_include_tag.nil?
|
|
79
|
+
logger.debug do
|
|
80
|
+
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
81
|
+
"Handling class include include_tag=#{include_tag}"
|
|
82
|
+
end
|
|
83
|
+
module_extends = api_map.get_extends(rooted_include_tag).map(&:type).map(&:to_s)
|
|
84
|
+
logger.debug do
|
|
85
|
+
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
86
|
+
"found module extends of #{rooted_include_tag}: #{module_extends}"
|
|
87
|
+
end
|
|
88
|
+
return unless module_extends.include? 'ActiveSupport::Concern'
|
|
89
|
+
included_class_pins = api_map.inner_get_methods_from_reference(rooted_include_tag, namespace_pin, rooted_type,
|
|
90
|
+
:class, visibility, deep, skip, true)
|
|
91
|
+
logger.debug do
|
|
92
|
+
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
93
|
+
"Found #{included_class_pins.length} inluded class methods for #{rooted_include_tag}"
|
|
94
|
+
end
|
|
95
|
+
environ.pins.concat included_class_pins
|
|
96
|
+
# another pattern is to put class methods inside a submodule
|
|
97
|
+
classmethods_include_tag = "#{rooted_include_tag}::ClassMethods"
|
|
98
|
+
included_classmethods_pins =
|
|
99
|
+
api_map.inner_get_methods_from_reference(classmethods_include_tag, namespace_pin, rooted_type,
|
|
100
|
+
:instance, visibility, deep, skip, true)
|
|
101
|
+
logger.debug do
|
|
102
|
+
"ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \
|
|
103
|
+
"Found #{included_classmethods_pins.length} included classmethod " \
|
|
104
|
+
"class methods for #{classmethods_include_tag}"
|
|
105
|
+
end
|
|
106
|
+
environ.pins.concat included_classmethods_pins
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Convention
|
|
5
|
-
# The base class for Conventions.
|
|
6
|
-
#
|
|
7
|
-
# A Convention provides Environs that customize ApiMaps with additional
|
|
8
|
-
# pins and other information. Subclasses should implement the `local` and
|
|
9
|
-
# `global` methods as necessary.
|
|
10
|
-
#
|
|
11
|
-
class Base
|
|
12
|
-
EMPTY_ENVIRON = Environ.new
|
|
13
|
-
|
|
14
|
-
# The Environ for a source map.
|
|
15
|
-
# Subclasses can override this method.
|
|
16
|
-
#
|
|
17
|
-
# @param source_map [SourceMap]
|
|
18
|
-
# @return [Environ]
|
|
19
|
-
def local source_map
|
|
20
|
-
EMPTY_ENVIRON
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# The Environ for a DocMap.
|
|
24
|
-
# Subclasses can override this method.
|
|
25
|
-
#
|
|
26
|
-
# @param doc_map [DocMap]
|
|
27
|
-
# @return [Environ]
|
|
28
|
-
def global doc_map
|
|
29
|
-
EMPTY_ENVIRON
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Provides any additional method pins based on e the described object.
|
|
33
|
-
#
|
|
34
|
-
# @param api_map [ApiMap]
|
|
35
|
-
# @param rooted_tag [String] A fully qualified namespace, with
|
|
36
|
-
# generic parameter values if applicable
|
|
37
|
-
# @param scope [Symbol] :class or :instance
|
|
38
|
-
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
39
|
-
# @param deep [Boolean]
|
|
40
|
-
# @param skip [Set<String>]
|
|
41
|
-
# @param no_core [Boolean] Skip core classes if true
|
|
42
|
-
#
|
|
43
|
-
# @return [Environ]
|
|
44
|
-
def object api_map, rooted_tag, scope, visibility,
|
|
45
|
-
deep, skip, no_core
|
|
46
|
-
EMPTY_ENVIRON
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Convention
|
|
5
|
+
# The base class for Conventions.
|
|
6
|
+
#
|
|
7
|
+
# A Convention provides Environs that customize ApiMaps with additional
|
|
8
|
+
# pins and other information. Subclasses should implement the `local` and
|
|
9
|
+
# `global` methods as necessary.
|
|
10
|
+
#
|
|
11
|
+
class Base
|
|
12
|
+
EMPTY_ENVIRON = Environ.new
|
|
13
|
+
|
|
14
|
+
# The Environ for a source map.
|
|
15
|
+
# Subclasses can override this method.
|
|
16
|
+
#
|
|
17
|
+
# @param source_map [SourceMap]
|
|
18
|
+
# @return [Environ]
|
|
19
|
+
def local source_map
|
|
20
|
+
EMPTY_ENVIRON
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The Environ for a DocMap.
|
|
24
|
+
# Subclasses can override this method.
|
|
25
|
+
#
|
|
26
|
+
# @param doc_map [DocMap]
|
|
27
|
+
# @return [Environ]
|
|
28
|
+
def global doc_map
|
|
29
|
+
EMPTY_ENVIRON
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Provides any additional method pins based on e the described object.
|
|
33
|
+
#
|
|
34
|
+
# @param api_map [ApiMap]
|
|
35
|
+
# @param rooted_tag [String] A fully qualified namespace, with
|
|
36
|
+
# generic parameter values if applicable
|
|
37
|
+
# @param scope [Symbol] :class or :instance
|
|
38
|
+
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
39
|
+
# @param deep [Boolean]
|
|
40
|
+
# @param skip [Set<String>]
|
|
41
|
+
# @param no_core [Boolean] Skip core classes if true
|
|
42
|
+
#
|
|
43
|
+
# @return [Environ]
|
|
44
|
+
def object api_map, rooted_tag, scope, visibility,
|
|
45
|
+
deep, skip, no_core
|
|
46
|
+
EMPTY_ENVIRON
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -27,7 +27,7 @@ module Solargraph
|
|
|
27
27
|
# s(:send, nil, :bar)))
|
|
28
28
|
#
|
|
29
29
|
# @param node [Parser::AST::Node]
|
|
30
|
-
def match?
|
|
30
|
+
def match? node
|
|
31
31
|
return false unless node&.type == :class
|
|
32
32
|
|
|
33
33
|
data_definition_node?(node.children[1])
|
|
@@ -37,7 +37,7 @@ module Solargraph
|
|
|
37
37
|
|
|
38
38
|
# @param data_node [Parser::AST::Node]
|
|
39
39
|
# @return [Boolean]
|
|
40
|
-
def data_definition_node?
|
|
40
|
+
def data_definition_node? data_node
|
|
41
41
|
return false unless data_node.is_a?(::Parser::AST::Node)
|
|
42
42
|
return false unless data_node&.type == :send
|
|
43
43
|
return false unless data_node.children[0]&.type == :const
|
|
@@ -49,7 +49,7 @@ module Solargraph
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
# @param node [Parser::AST::Node]
|
|
52
|
-
def initialize
|
|
52
|
+
def initialize node
|
|
53
53
|
@node = node
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -66,7 +66,7 @@ module Solargraph
|
|
|
66
66
|
end.compact
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
# @return [Parser::AST::Node]
|
|
69
|
+
# @return [Parser::AST::Node, nil]
|
|
70
70
|
def body_node
|
|
71
71
|
node.children[2]
|
|
72
72
|
end
|
|
@@ -81,9 +81,11 @@ module Solargraph
|
|
|
81
81
|
node.children[1]
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
# @sg-ignore Need to add nil check here
|
|
84
85
|
# @return [Array<Parser::AST::Node>]
|
|
85
86
|
def data_attribute_nodes
|
|
86
|
-
|
|
87
|
+
# @sg-ignore Need to add nil check here
|
|
88
|
+
data_node.children[2..]
|
|
87
89
|
end
|
|
88
90
|
end
|
|
89
91
|
end
|
|
@@ -17,6 +17,7 @@ module Solargraph
|
|
|
17
17
|
type: :class,
|
|
18
18
|
location: loc,
|
|
19
19
|
closure: region.closure,
|
|
20
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
20
21
|
name: data_definition_node.class_name,
|
|
21
22
|
comments: comments_for(node),
|
|
22
23
|
visibility: :public,
|
|
@@ -39,6 +40,7 @@ module Solargraph
|
|
|
39
40
|
# Solargraph::SourceMap::Clip#complete_keyword_parameters does not seem to currently take into account [Pin::Method#signatures] hence we only one for :kwarg
|
|
40
41
|
pins.push initialize_method_pin
|
|
41
42
|
|
|
43
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
42
44
|
data_definition_node.attributes.map do |attribute_node, attribute_name|
|
|
43
45
|
initialize_method_pin.parameters.push(
|
|
44
46
|
Pin::Parameter.new(
|
|
@@ -51,6 +53,7 @@ module Solargraph
|
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
# define attribute readers and instance variables
|
|
56
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
54
57
|
data_definition_node.attributes.each do |attribute_node, attribute_name|
|
|
55
58
|
name = attribute_name.to_s
|
|
56
59
|
method_pin = Pin::Method.new(
|
|
@@ -78,7 +81,7 @@ module Solargraph
|
|
|
78
81
|
|
|
79
82
|
private
|
|
80
83
|
|
|
81
|
-
# @return [DataDefintionNode, nil]
|
|
84
|
+
# @return [DataDefinition::DataDefintionNode, DataDefinition::DataAssignmentNode, nil]
|
|
82
85
|
def data_definition_node
|
|
83
86
|
@data_definition_node ||= if DataDefintionNode.match?(node)
|
|
84
87
|
DataDefintionNode.new(node)
|
|
@@ -90,7 +93,7 @@ module Solargraph
|
|
|
90
93
|
# @param attribute_node [Parser::AST::Node]
|
|
91
94
|
# @param attribute_name [String]
|
|
92
95
|
# @return [String, nil]
|
|
93
|
-
def attribute_comments
|
|
96
|
+
def attribute_comments attribute_node, attribute_name
|
|
94
97
|
data_comments = comments_for(attribute_node)
|
|
95
98
|
return if data_comments.nil? || data_comments.empty?
|
|
96
99
|
|
|
@@ -5,7 +5,7 @@ module Solargraph
|
|
|
5
5
|
class Gemspec < Base
|
|
6
6
|
def local source_map
|
|
7
7
|
return Convention::Base::EMPTY_ENVIRON unless File.basename(source_map.filename).end_with?('.gemspec')
|
|
8
|
-
@
|
|
8
|
+
@local ||= Environ.new(
|
|
9
9
|
requires: ['rubygems'],
|
|
10
10
|
pins: [
|
|
11
11
|
Solargraph::Pin::Reference::Override.from_comment(
|
|
@@ -27,7 +27,7 @@ module Solargraph
|
|
|
27
27
|
# s(:send, nil, :bar)))
|
|
28
28
|
#
|
|
29
29
|
# @param node [Parser::AST::Node]
|
|
30
|
-
def match?
|
|
30
|
+
def match? node
|
|
31
31
|
return false unless node&.type == :class
|
|
32
32
|
|
|
33
33
|
struct_definition_node?(node.children[1])
|
|
@@ -37,7 +37,7 @@ module Solargraph
|
|
|
37
37
|
|
|
38
38
|
# @param struct_node [Parser::AST::Node]
|
|
39
39
|
# @return [Boolean]
|
|
40
|
-
def struct_definition_node?
|
|
40
|
+
def struct_definition_node? struct_node
|
|
41
41
|
return false unless struct_node.is_a?(::Parser::AST::Node)
|
|
42
42
|
return false unless struct_node&.type == :send
|
|
43
43
|
return false unless struct_node.children[0]&.type == :const
|
|
@@ -49,7 +49,7 @@ module Solargraph
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
# @param node [Parser::AST::Node]
|
|
52
|
-
def initialize
|
|
52
|
+
def initialize node
|
|
53
53
|
@node = node
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -92,6 +92,7 @@ module Solargraph
|
|
|
92
92
|
node.children[1]
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
+
# @sg-ignore Need to add nil check here
|
|
95
96
|
# @return [Array<Parser::AST::Node>]
|
|
96
97
|
def struct_attribute_nodes
|
|
97
98
|
struct_node.children[2..-1]
|
|
@@ -17,6 +17,7 @@ module Solargraph
|
|
|
17
17
|
type: :class,
|
|
18
18
|
location: loc,
|
|
19
19
|
closure: region.closure,
|
|
20
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
20
21
|
name: struct_definition_node.class_name,
|
|
21
22
|
docstring: docstring,
|
|
22
23
|
visibility: :public,
|
|
@@ -39,6 +40,7 @@ module Solargraph
|
|
|
39
40
|
|
|
40
41
|
pins.push initialize_method_pin
|
|
41
42
|
|
|
43
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
42
44
|
struct_definition_node.attributes.map do |attribute_node, attribute_name|
|
|
43
45
|
initialize_method_pin.parameters.push(
|
|
44
46
|
Pin::Parameter.new(
|
|
@@ -52,6 +54,7 @@ module Solargraph
|
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
# define attribute accessors and instance variables
|
|
57
|
+
# @sg-ignore flow sensitive typing needs to handle attrs
|
|
55
58
|
struct_definition_node.attributes.each do |attribute_node, attribute_name|
|
|
56
59
|
[attribute_name, "#{attribute_name}="].each do |name|
|
|
57
60
|
docs = docstring.tags.find { |t| t.tag_name == 'param' && t.name == attribute_name }
|
|
@@ -102,7 +105,7 @@ module Solargraph
|
|
|
102
105
|
|
|
103
106
|
private
|
|
104
107
|
|
|
105
|
-
# @return [StructDefintionNode, StructAssignmentNode, nil]
|
|
108
|
+
# @return [StructDefinition::StructDefintionNode, StructDefinition::StructAssignmentNode, nil]
|
|
106
109
|
def struct_definition_node
|
|
107
110
|
@struct_definition_node ||= if StructDefintionNode.match?(node)
|
|
108
111
|
StructDefintionNode.new(node)
|
|
@@ -121,6 +124,7 @@ module Solargraph
|
|
|
121
124
|
# @return [YARD::Docstring]
|
|
122
125
|
def parse_comments
|
|
123
126
|
struct_comments = comments_for(node) || ''
|
|
127
|
+
# @sg-ignore Need to add nil check here
|
|
124
128
|
struct_definition_node.attributes.each do |attr_node, attr_name|
|
|
125
129
|
comment = comments_for(attr_node)
|
|
126
130
|
next if comment.nil?
|
|
@@ -138,7 +142,7 @@ module Solargraph
|
|
|
138
142
|
# @param tag [YARD::Tags::Tag, nil] The param tag for this attribute.xtract_
|
|
139
143
|
#
|
|
140
144
|
# @return [String]
|
|
141
|
-
def tag_string
|
|
145
|
+
def tag_string tag
|
|
142
146
|
tag&.types&.join(',') || 'undefined'
|
|
143
147
|
end
|
|
144
148
|
|
|
@@ -146,8 +150,8 @@ module Solargraph
|
|
|
146
150
|
# @param for_setter [Boolean] If true, will return a @param tag instead of a @return tag
|
|
147
151
|
#
|
|
148
152
|
# @return [String] The formatted comment for the attribute
|
|
149
|
-
def attribute_comment
|
|
150
|
-
return
|
|
153
|
+
def attribute_comment tag, for_setter
|
|
154
|
+
return '' if tag.nil?
|
|
151
155
|
|
|
152
156
|
suffix = "[#{tag_string(tag)}] #{tag.text}"
|
|
153
157
|
|
|
@@ -30,7 +30,7 @@ module Solargraph
|
|
|
30
30
|
|
|
31
31
|
# @param source_map [SourceMap]
|
|
32
32
|
# @return [Environ]
|
|
33
|
-
def self.for_local
|
|
33
|
+
def self.for_local source_map
|
|
34
34
|
result = Environ.new
|
|
35
35
|
@@conventions.each do |conv|
|
|
36
36
|
result.merge conv.local(source_map)
|
|
@@ -40,7 +40,7 @@ module Solargraph
|
|
|
40
40
|
|
|
41
41
|
# @param doc_map [DocMap]
|
|
42
42
|
# @return [Environ]
|
|
43
|
-
def self.for_global
|
|
43
|
+
def self.for_global doc_map
|
|
44
44
|
result = Environ.new
|
|
45
45
|
@@conventions.each do |conv|
|
|
46
46
|
result.merge conv.global(doc_map)
|
|
@@ -10,6 +10,7 @@ module Solargraph
|
|
|
10
10
|
return [] unless source.parsed? && source.synchronized?
|
|
11
11
|
result = []
|
|
12
12
|
refs = {}
|
|
13
|
+
# @sg-ignore Need to add nil check here
|
|
13
14
|
map = api_map.source_map(source.filename)
|
|
14
15
|
map.requires.each { |ref| refs[ref.name] = ref }
|
|
15
16
|
api_map.missing_docs.each do |r|
|