solargraph 0.59.0.dev.1 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/linting.yml +3 -1
- data/.github/workflows/plugins.yml +12 -3
- data/.github/workflows/rspec.yml +9 -54
- data/.github/workflows/typecheck.yml +2 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +38 -6
- data/.rubocop_todo.yml +40 -931
- data/CHANGELOG.md +22 -1
- data/Gemfile +3 -1
- data/Rakefile +25 -23
- data/bin/solargraph +2 -1
- data/lib/solargraph/api_map/constants.rb +0 -1
- data/lib/solargraph/api_map/index.rb +11 -11
- data/lib/solargraph/api_map/source_to_yard.rb +9 -8
- data/lib/solargraph/api_map/store.rb +28 -20
- data/lib/solargraph/api_map.rb +70 -41
- data/lib/solargraph/bench.rb +44 -45
- data/lib/solargraph/complex_type/type_methods.rb +14 -16
- data/lib/solargraph/complex_type/unique_type.rb +56 -47
- data/lib/solargraph/complex_type.rb +70 -62
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +61 -61
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +4 -4
- data/lib/solargraph/convention/data_definition.rb +1 -1
- 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 +1 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +3 -3
- data/lib/solargraph/convention/struct_definition.rb +3 -3
- 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/rubocop.rb +10 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +3 -3
- data/lib/solargraph/diagnostics/type_check.rb +10 -10
- data/lib/solargraph/diagnostics/update_errors.rb +37 -41
- data/lib/solargraph/doc_map.rb +370 -132
- data/lib/solargraph/equality.rb +3 -3
- data/lib/solargraph/gem_pins.rb +19 -18
- data/lib/solargraph/language_server/error_codes.rb +20 -20
- data/lib/solargraph/language_server/host/diagnoser.rb +89 -89
- data/lib/solargraph/language_server/host/dispatch.rb +2 -3
- data/lib/solargraph/language_server/host/message_worker.rb +2 -2
- data/lib/solargraph/language_server/host/sources.rb +1 -1
- data/lib/solargraph/language_server/host.rb +24 -21
- 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 +10 -11
- 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 +8 -8
- data/lib/solargraph/language_server/message/text_document/definition.rb +41 -34
- 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 -21
- data/lib/solargraph/language_server/message/text_document/formatting.rb +6 -6
- data/lib/solargraph/language_server/message/text_document/hover.rb +3 -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 +2 -2
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +25 -19
- 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 -19
- 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 +68 -95
- data/lib/solargraph/location.rb +10 -12
- data/lib/solargraph/logging.rb +4 -6
- data/lib/solargraph/page.rb +92 -92
- data/lib/solargraph/parser/comment_ripper.rb +12 -4
- data/lib/solargraph/parser/flow_sensitive_typing.rb +32 -44
- data/lib/solargraph/parser/node_processor/base.rb +4 -4
- data/lib/solargraph/parser/node_processor.rb +1 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +4 -6
- data/lib/solargraph/parser/parser_gem/flawed_builder.rb +19 -19
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_methods.rb +66 -65
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +12 -12
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +1 -2
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +3 -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 +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +3 -5
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +118 -112
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +29 -29
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem.rb +14 -12
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +25 -23
- data/lib/solargraph/pin/base.rb +76 -64
- data/lib/solargraph/pin/base_variable.rb +28 -71
- data/lib/solargraph/pin/block.rb +3 -2
- data/lib/solargraph/pin/breakable.rb +2 -0
- data/lib/solargraph/pin/callable.rb +23 -26
- data/lib/solargraph/pin/closure.rb +5 -4
- data/lib/solargraph/pin/common.rb +5 -2
- data/lib/solargraph/pin/compound_statement.rb +3 -3
- data/lib/solargraph/pin/constant.rb +43 -45
- data/lib/solargraph/pin/conversions.rb +9 -4
- data/lib/solargraph/pin/delegated_method.rb +4 -4
- data/lib/solargraph/pin/documenting.rb +3 -2
- data/lib/solargraph/pin/local_variable.rb +4 -4
- data/lib/solargraph/pin/method.rb +74 -70
- data/lib/solargraph/pin/namespace.rb +13 -12
- data/lib/solargraph/pin/parameter.rb +28 -27
- data/lib/solargraph/pin/proxy_type.rb +2 -0
- data/lib/solargraph/pin/reference/type_alias.rb +16 -0
- data/lib/solargraph/pin/reference.rb +18 -0
- data/lib/solargraph/pin/search.rb +2 -2
- data/lib/solargraph/pin/signature.rb +9 -14
- data/lib/solargraph/pin/symbol.rb +1 -0
- data/lib/solargraph/pin/until.rb +1 -3
- data/lib/solargraph/pin/while.rb +1 -3
- data/lib/solargraph/pin_cache.rb +71 -488
- data/lib/solargraph/position.rb +38 -17
- data/lib/solargraph/range.rb +10 -9
- data/lib/solargraph/rbs_map/conversions.rb +327 -221
- data/lib/solargraph/rbs_map/core_fills.rb +91 -84
- data/lib/solargraph/rbs_map/stdlib_map.rb +0 -1
- data/lib/solargraph/rbs_map.rb +5 -15
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +224 -66
- data/lib/solargraph/source/chain/array.rb +39 -37
- data/lib/solargraph/source/chain/call.rb +49 -44
- data/lib/solargraph/source/chain/class_variable.rb +13 -13
- data/lib/solargraph/source/chain/constant.rb +3 -1
- data/lib/solargraph/source/chain/global_variable.rb +13 -13
- data/lib/solargraph/source/chain/hash.rb +8 -6
- data/lib/solargraph/source/chain/if.rb +11 -10
- data/lib/solargraph/source/chain/instance_variable.rb +3 -1
- data/lib/solargraph/source/chain/link.rb +99 -109
- data/lib/solargraph/source/chain/literal.rb +4 -6
- data/lib/solargraph/source/chain/or.rb +2 -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 +26 -16
- data/lib/solargraph/source/change.rb +3 -3
- data/lib/solargraph/source/cursor.rb +18 -18
- data/lib/solargraph/source/encoding_fixes.rb +6 -7
- data/lib/solargraph/source/source_chainer.rb +46 -32
- data/lib/solargraph/source/updater.rb +1 -1
- data/lib/solargraph/source.rb +27 -29
- data/lib/solargraph/source_map/clip.rb +38 -30
- data/lib/solargraph/source_map/mapper.rb +51 -47
- data/lib/solargraph/source_map.rb +8 -4
- data/lib/solargraph/type_checker/rules.rb +8 -8
- data/lib/solargraph/type_checker.rb +95 -102
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +11 -10
- data/lib/solargraph/workspace/gemspecs.rb +3 -3
- data/lib/solargraph/workspace.rb +45 -165
- data/lib/solargraph/yard_map/helpers.rb +6 -2
- data/lib/solargraph/yard_map/mapper/to_method.rb +8 -6
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -1
- data/lib/solargraph/yard_map/mapper.rb +12 -12
- data/lib/solargraph/yard_map.rb +17 -18
- data/lib/solargraph/yard_tags.rb +20 -20
- data/lib/solargraph/yardoc.rb +26 -33
- data/lib/solargraph.rb +7 -5
- data/solargraph.gemspec +36 -35
- metadata +33 -38
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Convention
|
|
5
|
-
module DataDefinition
|
|
6
|
-
# A node wrapper for a Data definition via const assignment.
|
|
7
|
-
# @example
|
|
8
|
-
# MyData = Data.new(:bar, :baz) do
|
|
9
|
-
# def foo
|
|
10
|
-
# end
|
|
11
|
-
# end
|
|
12
|
-
class DataAssignmentNode < DataDefintionNode
|
|
13
|
-
class << self
|
|
14
|
-
# @example
|
|
15
|
-
# s(:casgn, nil, :Foo,
|
|
16
|
-
# s(:block,
|
|
17
|
-
# s(:send,
|
|
18
|
-
# s(:const, nil, :Data), :define,
|
|
19
|
-
# s(:sym, :bar),
|
|
20
|
-
# s(:sym, :baz)),
|
|
21
|
-
# s(:args),
|
|
22
|
-
# s(:def, :foo,
|
|
23
|
-
# s(:args),
|
|
24
|
-
# s(:send, nil, :bar))))
|
|
25
|
-
# @param node [::Parser::AST::Node]
|
|
26
|
-
def match?
|
|
27
|
-
return false unless node&.type == :casgn
|
|
28
|
-
return false if node.children[2].nil?
|
|
29
|
-
|
|
30
|
-
data_node = if node.children[2].type == :block
|
|
31
|
-
node.children[2].children[0]
|
|
32
|
-
else
|
|
33
|
-
node.children[2]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
data_definition_node?(data_node)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def class_name
|
|
41
|
-
if node.children[0]
|
|
42
|
-
Parser::NodeMethods.unpack_name(node.children[0]) + "::#{node.children[1]}"
|
|
43
|
-
else
|
|
44
|
-
node.children[1].to_s
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
private
|
|
49
|
-
|
|
50
|
-
# @return [Parser::AST::Node]
|
|
51
|
-
def data_node
|
|
52
|
-
if node.children[2].type == :block
|
|
53
|
-
node.children[2].children[0]
|
|
54
|
-
else
|
|
55
|
-
node.children[2]
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Convention
|
|
5
|
+
module DataDefinition
|
|
6
|
+
# A node wrapper for a Data definition via const assignment.
|
|
7
|
+
# @example
|
|
8
|
+
# MyData = Data.new(:bar, :baz) do
|
|
9
|
+
# def foo
|
|
10
|
+
# end
|
|
11
|
+
# end
|
|
12
|
+
class DataAssignmentNode < DataDefintionNode
|
|
13
|
+
class << self
|
|
14
|
+
# @example
|
|
15
|
+
# s(:casgn, nil, :Foo,
|
|
16
|
+
# s(:block,
|
|
17
|
+
# s(:send,
|
|
18
|
+
# s(:const, nil, :Data), :define,
|
|
19
|
+
# s(:sym, :bar),
|
|
20
|
+
# s(:sym, :baz)),
|
|
21
|
+
# s(:args),
|
|
22
|
+
# s(:def, :foo,
|
|
23
|
+
# s(:args),
|
|
24
|
+
# s(:send, nil, :bar))))
|
|
25
|
+
# @param node [::Parser::AST::Node]
|
|
26
|
+
def match? node
|
|
27
|
+
return false unless node&.type == :casgn
|
|
28
|
+
return false if node.children[2].nil?
|
|
29
|
+
|
|
30
|
+
data_node = if node.children[2].type == :block
|
|
31
|
+
node.children[2].children[0]
|
|
32
|
+
else
|
|
33
|
+
node.children[2]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
data_definition_node?(data_node)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def class_name
|
|
41
|
+
if node.children[0]
|
|
42
|
+
Parser::NodeMethods.unpack_name(node.children[0]) + "::#{node.children[1]}"
|
|
43
|
+
else
|
|
44
|
+
node.children[1].to_s
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
# @return [Parser::AST::Node]
|
|
51
|
+
def data_node
|
|
52
|
+
if node.children[2].type == :block
|
|
53
|
+
node.children[2].children[0]
|
|
54
|
+
else
|
|
55
|
+
node.children[2]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
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
|
|
|
@@ -85,7 +85,7 @@ module Solargraph
|
|
|
85
85
|
# @return [Array<Parser::AST::Node>]
|
|
86
86
|
def data_attribute_nodes
|
|
87
87
|
# @sg-ignore Need to add nil check here
|
|
88
|
-
data_node.children[2
|
|
88
|
+
data_node.children[2..]
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
@@ -93,7 +93,7 @@ module Solargraph
|
|
|
93
93
|
# @param attribute_node [Parser::AST::Node]
|
|
94
94
|
# @param attribute_name [String]
|
|
95
95
|
# @return [String, nil]
|
|
96
|
-
def attribute_comments
|
|
96
|
+
def attribute_comments attribute_node, attribute_name
|
|
97
97
|
data_comments = comments_for(attribute_node)
|
|
98
98
|
return if data_comments.nil? || data_comments.empty?
|
|
99
99
|
|
|
@@ -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
|
|
|
@@ -142,7 +142,7 @@ module Solargraph
|
|
|
142
142
|
# @param tag [YARD::Tags::Tag, nil] The param tag for this attribute.xtract_
|
|
143
143
|
#
|
|
144
144
|
# @return [String]
|
|
145
|
-
def tag_string
|
|
145
|
+
def tag_string tag
|
|
146
146
|
tag&.types&.join(',') || 'undefined'
|
|
147
147
|
end
|
|
148
148
|
|
|
@@ -150,8 +150,8 @@ module Solargraph
|
|
|
150
150
|
# @param for_setter [Boolean] If true, will return a @param tag instead of a @return tag
|
|
151
151
|
#
|
|
152
152
|
# @return [String] The formatted comment for the attribute
|
|
153
|
-
def attribute_comment
|
|
154
|
-
return
|
|
153
|
+
def attribute_comment tag, for_setter
|
|
154
|
+
return '' if tag.nil?
|
|
155
155
|
|
|
156
156
|
suffix = "[#{tag_string(tag)}] #{tag.text}"
|
|
157
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
|
|
@@ -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]
|
|
@@ -33,7 +33,7 @@ module Solargraph
|
|
|
33
33
|
# a time - it uses 'chdir' to read config files with ERB,
|
|
34
34
|
# which can conflict with other chdirs.
|
|
35
35
|
result = Solargraph::CHDIR_MUTEX.synchronize do
|
|
36
|
-
redirect_stdout{ runner.run(paths) }
|
|
36
|
+
redirect_stdout { runner.run(paths) }
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
return [] if result.empty?
|
|
@@ -77,7 +77,7 @@ module Solargraph
|
|
|
77
77
|
severity: SEVERITIES[off['severity']],
|
|
78
78
|
source: 'rubocop',
|
|
79
79
|
code: off['cop_name'],
|
|
80
|
-
message: off['message'].gsub(/^#{off['cop_name']}
|
|
80
|
+
message: off['message'].gsub(/^#{off['cop_name']}:/, '')
|
|
81
81
|
}
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -96,22 +96,22 @@ module Solargraph
|
|
|
96
96
|
# @param off [Hash{String => Hash{String => Integer}}]
|
|
97
97
|
# @return [Position]
|
|
98
98
|
def offense_ending_position off
|
|
99
|
-
if off['location']['start_line']
|
|
100
|
-
Position.new(off['location']['start_line'], 0)
|
|
101
|
-
else
|
|
99
|
+
if off['location']['start_line'] == off['location']['last_line']
|
|
102
100
|
start_line = off['location']['start_line'] - 1
|
|
103
101
|
# @type [Integer]
|
|
104
102
|
last_column = off['location']['last_column']
|
|
105
103
|
line = @source.code.lines[start_line]
|
|
106
104
|
col_off = if line.nil? || line.empty?
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
1
|
|
106
|
+
else
|
|
107
|
+
0
|
|
108
|
+
end
|
|
111
109
|
|
|
112
110
|
Position.new(
|
|
113
111
|
start_line, last_column - col_off
|
|
114
112
|
)
|
|
113
|
+
else
|
|
114
|
+
Position.new(off['location']['start_line'], 0)
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
end
|