solargraph 0.58.2 → 0.59.0.dev.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 +4 -5
- data/.github/workflows/plugins.yml +41 -34
- data/.github/workflows/rspec.yml +44 -23
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop.yml +32 -5
- data/.rubocop_todo.yml +50 -966
- 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 +13 -3
- data/lib/solargraph/api_map/index.rb +23 -18
- data/lib/solargraph/api_map/source_to_yard.rb +22 -9
- data/lib/solargraph/api_map/store.rb +33 -28
- data/lib/solargraph/api_map.rb +150 -82
- data/lib/solargraph/bench.rb +44 -45
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +28 -17
- data/lib/solargraph/complex_type/unique_type.rb +218 -57
- data/lib/solargraph/complex_type.rb +170 -57
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -61
- 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 +15 -15
- data/lib/solargraph/convention/gemspec.rb +23 -23
- data/lib/solargraph/convention/rakefile.rb +17 -17
- 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 +78 -78
- data/lib/solargraph/converters/dd.rb +19 -17
- data/lib/solargraph/converters/dl.rb +17 -15
- data/lib/solargraph/converters/dt.rb +17 -15
- data/lib/solargraph/converters/misc.rb +3 -1
- 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 +37 -41
- data/lib/solargraph/doc_map.rb +133 -373
- data/lib/solargraph/equality.rb +4 -4
- data/lib/solargraph/gem_pins.rb +21 -20
- data/lib/solargraph/language_server/error_codes.rb +20 -20
- 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 +30 -22
- data/lib/solargraph/language_server/message/base.rb +97 -97
- data/lib/solargraph/language_server/message/client/register_capability.rb +13 -15
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +58 -60
- 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 +32 -32
- data/lib/solargraph/language_server/message/extended/download_core.rb +20 -19
- data/lib/solargraph/language_server/message/extended/search.rb +20 -20
- data/lib/solargraph/language_server/message/initialize.rb +197 -191
- 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 +23 -16
- 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 +18 -11
- data/lib/solargraph/language_server/message/text_document/references.rb +23 -16
- data/lib/solargraph/language_server/message/text_document/rename.rb +26 -19
- 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/workspace/did_change_configuration.rb +41 -35
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +48 -40
- data/lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb +32 -26
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +27 -17
- data/lib/solargraph/language_server/message.rb +94 -94
- data/lib/solargraph/language_server/request.rb +29 -27
- data/lib/solargraph/language_server/transport/data_reader.rb +72 -74
- data/lib/solargraph/language_server/uri_helpers.rb +49 -49
- data/lib/solargraph/library.rb +85 -44
- data/lib/solargraph/location.rb +17 -14
- data/lib/solargraph/logging.rb +24 -4
- data/lib/solargraph/page.rb +92 -92
- data/lib/solargraph/parser/comment_ripper.rb +19 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +326 -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 +32 -14
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +19 -19
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +50 -25
- data/lib/solargraph/parser/parser_gem/node_methods.rb +91 -70
- 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 +12 -12
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +10 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +38 -37
- 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/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/until_node.rb +29 -29
- 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 +14 -12
- data/lib/solargraph/parser/region.rb +9 -3
- data/lib/solargraph/parser/snippet.rb +3 -1
- data/lib/solargraph/parser.rb +25 -23
- data/lib/solargraph/pin/base.rb +126 -80
- 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 +43 -45
- 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 +153 -104
- data/lib/solargraph/pin/method_alias.rb +8 -0
- data/lib/solargraph/pin/namespace.rb +19 -12
- data/lib/solargraph/pin/parameter.rb +100 -36
- data/lib/solargraph/pin/proxy_type.rb +4 -1
- data/lib/solargraph/pin/reference/override.rb +1 -1
- data/lib/solargraph/pin/reference/superclass.rb +2 -0
- data/lib/solargraph/pin/reference.rb +19 -0
- data/lib/solargraph/pin/search.rb +3 -2
- data/lib/solargraph/pin/signature.rb +15 -12
- 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 +490 -73
- data/lib/solargraph/position.rb +14 -10
- data/lib/solargraph/range.rb +16 -15
- data/lib/solargraph/rbs_map/conversions.rb +343 -214
- data/lib/solargraph/rbs_map/core_fills.rb +91 -84
- 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 +77 -32
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +128 -73
- data/lib/solargraph/source/chain/array.rb +39 -37
- data/lib/solargraph/source/chain/call.rb +96 -56
- data/lib/solargraph/source/chain/class_variable.rb +13 -13
- data/lib/solargraph/source/chain/constant.rb +5 -1
- data/lib/solargraph/source/chain/global_variable.rb +13 -13
- data/lib/solargraph/source/chain/hash.rb +8 -5
- 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 +99 -109
- data/lib/solargraph/source/chain/literal.rb +9 -6
- data/lib/solargraph/source/chain/or.rb +10 -4
- data/lib/solargraph/source/chain/q_call.rb +13 -11
- data/lib/solargraph/source/chain/variable.rb +15 -13
- data/lib/solargraph/source/chain/z_super.rb +28 -30
- data/lib/solargraph/source/chain.rb +49 -38
- data/lib/solargraph/source/change.rb +12 -5
- data/lib/solargraph/source/cursor.rb +23 -17
- 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 +48 -29
- data/lib/solargraph/source_map/data.rb +4 -1
- data/lib/solargraph/source_map/mapper.rb +71 -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 +195 -120
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +13 -10
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +1 -0
- data/lib/solargraph/workspace.rb +149 -30
- data/lib/solargraph/yard_map/helpers.rb +8 -3
- 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_tags.rb +20 -20
- data/lib/solargraph/yardoc.rb +33 -23
- data/lib/solargraph.rb +29 -8
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/fills/tuple/tuple.rbs +28 -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 +36 -34
- metadata +38 -33
- 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
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Convention
|
|
5
|
-
class Gemfile < Base
|
|
6
|
-
def local source_map
|
|
7
|
-
return EMPTY_ENVIRON unless File.basename(source_map.filename) == 'Gemfile'
|
|
8
|
-
@
|
|
9
|
-
requires: ['bundler'],
|
|
10
|
-
domains: ['Bundler::Dsl']
|
|
11
|
-
)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Convention
|
|
5
|
+
class Gemfile < Base
|
|
6
|
+
def local source_map
|
|
7
|
+
return EMPTY_ENVIRON unless File.basename(source_map.filename) == 'Gemfile'
|
|
8
|
+
@local ||= Environ.new(
|
|
9
|
+
requires: ['bundler'],
|
|
10
|
+
domains: ['Bundler::Dsl']
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Convention
|
|
5
|
-
class Gemspec < Base
|
|
6
|
-
def local source_map
|
|
7
|
-
return Convention::Base::EMPTY_ENVIRON unless File.basename(source_map.filename).end_with?('.gemspec')
|
|
8
|
-
@
|
|
9
|
-
requires: ['rubygems'],
|
|
10
|
-
pins: [
|
|
11
|
-
Solargraph::Pin::Reference::Override.from_comment(
|
|
12
|
-
'Gem::Specification.new',
|
|
13
|
-
%(
|
|
14
|
-
@yieldparam [self]
|
|
15
|
-
),
|
|
16
|
-
source: :gemspec
|
|
17
|
-
)
|
|
18
|
-
]
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Convention
|
|
5
|
+
class Gemspec < Base
|
|
6
|
+
def local source_map
|
|
7
|
+
return Convention::Base::EMPTY_ENVIRON unless File.basename(source_map.filename).end_with?('.gemspec')
|
|
8
|
+
@local ||= Environ.new(
|
|
9
|
+
requires: ['rubygems'],
|
|
10
|
+
pins: [
|
|
11
|
+
Solargraph::Pin::Reference::Override.from_comment(
|
|
12
|
+
'Gem::Specification.new',
|
|
13
|
+
%(
|
|
14
|
+
@yieldparam [self]
|
|
15
|
+
),
|
|
16
|
+
source: :gemspec
|
|
17
|
+
)
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Convention
|
|
5
|
-
class Rakefile < Base
|
|
6
|
-
def local source_map
|
|
7
|
-
basename = File.basename(source_map.filename)
|
|
8
|
-
return EMPTY_ENVIRON unless basename.end_with?('.rake') || basename == 'Rakefile'
|
|
9
|
-
|
|
10
|
-
@
|
|
11
|
-
requires: ['rake'],
|
|
12
|
-
domains: ['Rake::DSL']
|
|
13
|
-
)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Convention
|
|
5
|
+
class Rakefile < Base
|
|
6
|
+
def local source_map
|
|
7
|
+
basename = File.basename(source_map.filename)
|
|
8
|
+
return EMPTY_ENVIRON unless basename.end_with?('.rake') || basename == 'Rakefile'
|
|
9
|
+
|
|
10
|
+
@local ||= Environ.new(
|
|
11
|
+
requires: ['rake'],
|
|
12
|
+
domains: ['Rake::DSL']
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
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
|
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
|
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
# Conventions provide a way to modify an ApiMap based on expectations about
|
|
5
|
-
# one of its sources.
|
|
6
|
-
#
|
|
7
|
-
module Convention
|
|
8
|
-
autoload :Base, 'solargraph/convention/base'
|
|
9
|
-
autoload :Gemfile, 'solargraph/convention/gemfile'
|
|
10
|
-
autoload :Gemspec, 'solargraph/convention/gemspec'
|
|
11
|
-
autoload :Rakefile, 'solargraph/convention/rakefile'
|
|
12
|
-
autoload :StructDefinition, 'solargraph/convention/struct_definition'
|
|
13
|
-
autoload :DataDefinition, 'solargraph/convention/data_definition'
|
|
14
|
-
autoload :ActiveSupportConcern, 'solargraph/convention/active_support_concern'
|
|
15
|
-
|
|
16
|
-
# @type [Set<Convention::Base>]
|
|
17
|
-
@@conventions = Set.new
|
|
18
|
-
|
|
19
|
-
# @param convention [Class<Convention::Base>]
|
|
20
|
-
# @return [void]
|
|
21
|
-
def self.register convention
|
|
22
|
-
@@conventions.add convention.new
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# @param convention [Class<Convention::Base>]
|
|
26
|
-
# @return [void]
|
|
27
|
-
def self.unregister convention
|
|
28
|
-
@@conventions.delete_if { |c| c.is_a?(convention) }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# @param source_map [SourceMap]
|
|
32
|
-
# @return [Environ]
|
|
33
|
-
def self.for_local
|
|
34
|
-
result = Environ.new
|
|
35
|
-
@@conventions.each do |conv|
|
|
36
|
-
result.merge conv.local(source_map)
|
|
37
|
-
end
|
|
38
|
-
result
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# @param doc_map [DocMap]
|
|
42
|
-
# @return [Environ]
|
|
43
|
-
def self.for_global
|
|
44
|
-
result = Environ.new
|
|
45
|
-
@@conventions.each do |conv|
|
|
46
|
-
result.merge conv.global(doc_map)
|
|
47
|
-
end
|
|
48
|
-
result
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Provides any additional method pins based on the described object.
|
|
52
|
-
#
|
|
53
|
-
# @param api_map [ApiMap]
|
|
54
|
-
# @param rooted_tag [String] A fully qualified namespace, with
|
|
55
|
-
# generic parameter values if applicable
|
|
56
|
-
# @param scope [Symbol] :class or :instance
|
|
57
|
-
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
58
|
-
# @param deep [Boolean]
|
|
59
|
-
# @param skip [Set<String>]
|
|
60
|
-
# @param no_core [Boolean] Skip core classes if true
|
|
61
|
-
#
|
|
62
|
-
# @return [Environ]
|
|
63
|
-
def self.for_object api_map, rooted_tag, scope, visibility,
|
|
64
|
-
deep, skip, no_core
|
|
65
|
-
result = Environ.new
|
|
66
|
-
@@conventions.each do |conv|
|
|
67
|
-
result.merge conv.object(api_map, rooted_tag, scope, visibility,
|
|
68
|
-
deep, skip, no_core)
|
|
69
|
-
end
|
|
70
|
-
result
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
register Gemfile
|
|
74
|
-
register Gemspec
|
|
75
|
-
register Rakefile
|
|
76
|
-
register ActiveSupportConcern
|
|
77
|
-
end
|
|
78
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
# Conventions provide a way to modify an ApiMap based on expectations about
|
|
5
|
+
# one of its sources.
|
|
6
|
+
#
|
|
7
|
+
module Convention
|
|
8
|
+
autoload :Base, 'solargraph/convention/base'
|
|
9
|
+
autoload :Gemfile, 'solargraph/convention/gemfile'
|
|
10
|
+
autoload :Gemspec, 'solargraph/convention/gemspec'
|
|
11
|
+
autoload :Rakefile, 'solargraph/convention/rakefile'
|
|
12
|
+
autoload :StructDefinition, 'solargraph/convention/struct_definition'
|
|
13
|
+
autoload :DataDefinition, 'solargraph/convention/data_definition'
|
|
14
|
+
autoload :ActiveSupportConcern, 'solargraph/convention/active_support_concern'
|
|
15
|
+
|
|
16
|
+
# @type [Set<Convention::Base>]
|
|
17
|
+
@@conventions = Set.new
|
|
18
|
+
|
|
19
|
+
# @param convention [Class<Convention::Base>]
|
|
20
|
+
# @return [void]
|
|
21
|
+
def self.register convention
|
|
22
|
+
@@conventions.add convention.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @param convention [Class<Convention::Base>]
|
|
26
|
+
# @return [void]
|
|
27
|
+
def self.unregister convention
|
|
28
|
+
@@conventions.delete_if { |c| c.is_a?(convention) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @param source_map [SourceMap]
|
|
32
|
+
# @return [Environ]
|
|
33
|
+
def self.for_local source_map
|
|
34
|
+
result = Environ.new
|
|
35
|
+
@@conventions.each do |conv|
|
|
36
|
+
result.merge conv.local(source_map)
|
|
37
|
+
end
|
|
38
|
+
result
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @param doc_map [DocMap]
|
|
42
|
+
# @return [Environ]
|
|
43
|
+
def self.for_global doc_map
|
|
44
|
+
result = Environ.new
|
|
45
|
+
@@conventions.each do |conv|
|
|
46
|
+
result.merge conv.global(doc_map)
|
|
47
|
+
end
|
|
48
|
+
result
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Provides any additional method pins based on the described object.
|
|
52
|
+
#
|
|
53
|
+
# @param api_map [ApiMap]
|
|
54
|
+
# @param rooted_tag [String] A fully qualified namespace, with
|
|
55
|
+
# generic parameter values if applicable
|
|
56
|
+
# @param scope [Symbol] :class or :instance
|
|
57
|
+
# @param visibility [Array<Symbol>] :public, :protected, and/or :private
|
|
58
|
+
# @param deep [Boolean]
|
|
59
|
+
# @param skip [Set<String>]
|
|
60
|
+
# @param no_core [Boolean] Skip core classes if true
|
|
61
|
+
#
|
|
62
|
+
# @return [Environ]
|
|
63
|
+
def self.for_object api_map, rooted_tag, scope, visibility,
|
|
64
|
+
deep, skip, no_core
|
|
65
|
+
result = Environ.new
|
|
66
|
+
@@conventions.each do |conv|
|
|
67
|
+
result.merge conv.object(api_map, rooted_tag, scope, visibility,
|
|
68
|
+
deep, skip, no_core)
|
|
69
|
+
end
|
|
70
|
+
result
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
register Gemfile
|
|
74
|
+
register Gemspec
|
|
75
|
+
register Rakefile
|
|
76
|
+
register ActiveSupportConcern
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
|
|
5
|
+
module ReverseMarkdown
|
|
6
|
+
module Converters
|
|
7
|
+
class Dd < Base
|
|
8
|
+
# @return [String]
|
|
9
|
+
# @param node [Nokogiri::XML::Element]
|
|
10
|
+
# @param state [Hash]
|
|
11
|
+
def convert node, state = {}
|
|
12
|
+
content = treat_children(node, state)
|
|
13
|
+
": #{content.strip}\n"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
ReverseMarkdown::Converters.register :dd, ReverseMarkdown::Converters::Dd.new
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# @
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ReverseMarkdown
|
|
4
|
+
module Converters
|
|
5
|
+
class Dl < Base
|
|
6
|
+
# @return [String]
|
|
7
|
+
# @param node [Nokogiri::XML::Element]
|
|
8
|
+
# @param state [Hash]
|
|
9
|
+
def convert node, state = {}
|
|
10
|
+
content = treat_children(node, state).strip
|
|
11
|
+
"\n\n#{content}\n"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
ReverseMarkdown::Converters.register :dl, ReverseMarkdown::Converters::Dl.new
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# @
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ReverseMarkdown
|
|
4
|
+
module Converters
|
|
5
|
+
class Dt < Base
|
|
6
|
+
# @return [String]
|
|
7
|
+
# @param node [Nokogiri::XML::Element]
|
|
8
|
+
# @param state [Hash]
|
|
9
|
+
def convert node, state = {}
|
|
10
|
+
content = treat_children(node, state)
|
|
11
|
+
"\n#{content.strip}\n"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
ReverseMarkdown::Converters.register :dt, ReverseMarkdown::Converters::Dt.new
|
|
@@ -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|
|
|
@@ -17,7 +17,7 @@ module Solargraph
|
|
|
17
17
|
'warning' => Severities::WARNING,
|
|
18
18
|
'error' => Severities::ERROR,
|
|
19
19
|
'fatal' => Severities::ERROR
|
|
20
|
-
}
|
|
20
|
+
}.freeze
|
|
21
21
|
|
|
22
22
|
# @param source [Solargraph::Source]
|
|
23
23
|
# @param _api_map [Solargraph::ApiMap]
|
|
@@ -25,6 +25,7 @@ module Solargraph
|
|
|
25
25
|
def diagnose source, _api_map
|
|
26
26
|
@source = source
|
|
27
27
|
require_rubocop(rubocop_version)
|
|
28
|
+
# @sg-ignore Need to add nil check here
|
|
28
29
|
options, paths = generate_options(source.filename, source.code)
|
|
29
30
|
store = RuboCop::ConfigStore.new
|
|
30
31
|
runner = RuboCop::Runner.new(options, store)
|
|
@@ -32,7 +33,7 @@ module Solargraph
|
|
|
32
33
|
# a time - it uses 'chdir' to read config files with ERB,
|
|
33
34
|
# which can conflict with other chdirs.
|
|
34
35
|
result = Solargraph::CHDIR_MUTEX.synchronize do
|
|
35
|
-
redirect_stdout{ runner.run(paths) }
|
|
36
|
+
redirect_stdout { runner.run(paths) }
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
return [] if result.empty?
|
|
@@ -76,7 +77,7 @@ module Solargraph
|
|
|
76
77
|
severity: SEVERITIES[off['severity']],
|
|
77
78
|
source: 'rubocop',
|
|
78
79
|
code: off['cop_name'],
|
|
79
|
-
message: off['message'].gsub(/^#{off['cop_name']}
|
|
80
|
+
message: off['message'].gsub(/^#{off['cop_name']}:/, '')
|
|
80
81
|
}
|
|
81
82
|
end
|
|
82
83
|
|
|
@@ -95,22 +96,22 @@ module Solargraph
|
|
|
95
96
|
# @param off [Hash{String => Hash{String => Integer}}]
|
|
96
97
|
# @return [Position]
|
|
97
98
|
def offense_ending_position off
|
|
98
|
-
if off['location']['start_line']
|
|
99
|
-
Position.new(off['location']['start_line'], 0)
|
|
100
|
-
else
|
|
99
|
+
if off['location']['start_line'] == off['location']['last_line']
|
|
101
100
|
start_line = off['location']['start_line'] - 1
|
|
102
101
|
# @type [Integer]
|
|
103
102
|
last_column = off['location']['last_column']
|
|
104
103
|
line = @source.code.lines[start_line]
|
|
105
104
|
col_off = if line.nil? || line.empty?
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
1
|
|
106
|
+
else
|
|
107
|
+
0
|
|
108
|
+
end
|
|
110
109
|
|
|
111
110
|
Position.new(
|
|
112
111
|
start_line, last_column - col_off
|
|
113
112
|
)
|
|
113
|
+
else
|
|
114
|
+
Position.new(off['location']['start_line'], 0)
|
|
114
115
|
end
|
|
115
116
|
end
|
|
116
117
|
end
|
|
@@ -13,17 +13,18 @@ module Solargraph
|
|
|
13
13
|
# @param version [String, nil]
|
|
14
14
|
# @raise [InvalidRubocopVersionError] if _version_ is not installed
|
|
15
15
|
# @return [void]
|
|
16
|
-
def require_rubocop
|
|
16
|
+
def require_rubocop version = nil
|
|
17
17
|
begin
|
|
18
18
|
# @type [String]
|
|
19
19
|
gem_path = Gem::Specification.find_by_name('rubocop', version).full_gem_path
|
|
20
20
|
gem_lib_path = File.join(gem_path, 'lib')
|
|
21
|
+
# @sg-ignore Should better support meaning of '&' in RBS
|
|
21
22
|
$LOAD_PATH.unshift(gem_lib_path) unless $LOAD_PATH.include?(gem_lib_path)
|
|
22
23
|
rescue Gem::MissingSpecVersionError => e
|
|
23
24
|
# @type [Array<Gem::Specification>]
|
|
24
25
|
specs = e.specs
|
|
25
26
|
raise InvalidRubocopVersionError,
|
|
26
|
-
"could not find '#{e.name}' (#{e.requirement}) - "\
|
|
27
|
+
"could not find '#{e.name}' (#{e.requirement}) - " \
|
|
27
28
|
"did find: [#{specs.map { |s| s.version.version }.join(', ')}]"
|
|
28
29
|
end
|
|
29
30
|
require 'rubocop'
|
|
@@ -50,7 +51,8 @@ module Solargraph
|
|
|
50
51
|
# @return [String]
|
|
51
52
|
def fix_drive_letter path
|
|
52
53
|
return path unless path.match(/^[a-z]:/)
|
|
53
|
-
|
|
54
|
+
# @sg-ignore Need to add nil check here
|
|
55
|
+
path[0].upcase + path[1..]
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
# @todo This is a smelly way to redirect output, but the RuboCop specs do
|
|
@@ -10,18 +10,19 @@ module Solargraph
|
|
|
10
10
|
def diagnose source, api_map
|
|
11
11
|
# return [] unless args.include?('always') || api_map.workspaced?(source.filename)
|
|
12
12
|
severity = Diagnostics::Severities::ERROR
|
|
13
|
-
level =
|
|
13
|
+
level = args.reverse.find { |a| %w[normal typed strict strong].include?(a) } || :normal
|
|
14
|
+
# @sg-ignore sensitive typing needs to handle || on nil types
|
|
14
15
|
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym)
|
|
15
16
|
checker.problems
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
.sort { |a, b| a.location.range.start.line <=> b.location.range.start.line }
|
|
18
|
+
.map do |problem|
|
|
19
|
+
{
|
|
20
|
+
range: extract_first_line(problem.location, source),
|
|
21
|
+
severity: severity,
|
|
22
|
+
source: 'Typecheck',
|
|
23
|
+
message: problem.message
|
|
24
|
+
}
|
|
25
|
+
end
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
private
|