solargraph 0.59.1 → 0.60.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 +6 -0
- data/.github/workflows/plugins.yml +8 -0
- data/.github/workflows/rspec.yml +4 -1
- data/.github/workflows/typecheck.yml +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +18 -0
- data/Gemfile +3 -0
- data/lib/solargraph/api_map/index.rb +13 -2
- data/lib/solargraph/api_map/store.rb +22 -8
- data/lib/solargraph/api_map.rb +38 -8
- data/lib/solargraph/complex_type/type_methods.rb +1 -0
- data/lib/solargraph/complex_type/unique_type.rb +16 -13
- data/lib/solargraph/complex_type.rb +5 -0
- data/lib/solargraph/convention/active_support_concern.rb +111 -111
- data/lib/solargraph/convention/base.rb +50 -50
- data/lib/solargraph/diagnostics.rb +55 -55
- data/lib/solargraph/doc_map.rb +1 -0
- data/lib/solargraph/environ.rb +52 -52
- data/lib/solargraph/gem_pins.rb +0 -11
- data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
- data/lib/solargraph/language_server/message/initialized.rb +28 -28
- data/lib/solargraph/language_server/message/text_document.rb +28 -28
- data/lib/solargraph/language_server/progress.rb +143 -143
- data/lib/solargraph/language_server/transport/adapter.rb +68 -68
- data/lib/solargraph/language_server.rb +20 -20
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_methods.rb +42 -0
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
- 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/gvasgn_node.rb +24 -24
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +29 -5
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +20 -20
- data/lib/solargraph/pin/base.rb +31 -3
- data/lib/solargraph/pin/callable.rb +2 -2
- data/lib/solargraph/pin/common.rb +12 -0
- data/lib/solargraph/pin/method.rb +56 -16
- data/lib/solargraph/pin/reference/require.rb +14 -14
- data/lib/solargraph/pin/singleton.rb +11 -11
- data/lib/solargraph/rbs_map/conversions.rb +103 -145
- data/lib/solargraph/rbs_translator.rb +206 -0
- data/lib/solargraph/shell.rb +131 -64
- data/lib/solargraph/source/chain/array.rb +1 -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 +8 -76
- data/lib/solargraph/source/chain/head.rb +19 -19
- data/lib/solargraph/source/chain/literal.rb +18 -14
- data/lib/solargraph/source/source_chainer.rb +4 -4
- data/lib/solargraph/source_map/mapper.rb +5 -135
- data/lib/solargraph/source_map.rb +14 -0
- data/lib/solargraph/version.rb +19 -1
- data/lib/solargraph/yard_map/cache.rb +25 -25
- data/lib/solargraph/yard_map/directives/attribute_directive.rb +65 -0
- data/lib/solargraph/yard_map/directives/domain_directive.rb +30 -0
- data/lib/solargraph/yard_map/directives/method_directive.rb +51 -0
- data/lib/solargraph/yard_map/directives/override_directive.rb +30 -0
- data/lib/solargraph/yard_map/directives/parse_directive.rb +53 -0
- data/lib/solargraph/yard_map/directives/visibility_directive.rb +70 -0
- data/lib/solargraph/yard_map/directives.rb +35 -0
- data/lib/solargraph/yard_map/macro.rb +113 -0
- data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
- data/lib/solargraph/yard_map/mapper.rb +19 -1
- data/lib/solargraph/yard_map.rb +2 -0
- data/lib/solargraph.rb +1 -0
- data/solargraph.gemspec +1 -0
- metadata +24 -2
- data/rbs/fills/tuple/tuple.rbs +0 -177
|
@@ -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
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
# The Diagnostics library provides reporters for analyzing problems in code
|
|
5
|
-
# and providing the results to language server clients.
|
|
6
|
-
#
|
|
7
|
-
module Diagnostics
|
|
8
|
-
autoload :Base, 'solargraph/diagnostics/base'
|
|
9
|
-
autoload :Severities, 'solargraph/diagnostics/severities'
|
|
10
|
-
autoload :Rubocop, 'solargraph/diagnostics/rubocop'
|
|
11
|
-
autoload :RubocopHelpers, 'solargraph/diagnostics/rubocop_helpers'
|
|
12
|
-
autoload :RequireNotFound, 'solargraph/diagnostics/require_not_found'
|
|
13
|
-
autoload :UpdateErrors, 'solargraph/diagnostics/update_errors'
|
|
14
|
-
autoload :TypeCheck, 'solargraph/diagnostics/type_check'
|
|
15
|
-
|
|
16
|
-
class << self
|
|
17
|
-
# Add a reporter with a name to identify it in .solargraph.yml files.
|
|
18
|
-
#
|
|
19
|
-
# @param name [String] The name
|
|
20
|
-
# @param klass [Class<Solargraph::Diagnostics::Base>] The class implementation
|
|
21
|
-
# @return [void]
|
|
22
|
-
def register name, klass
|
|
23
|
-
reporter_hash[name] = klass
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Get an array of reporter names.
|
|
27
|
-
#
|
|
28
|
-
# @return [Array<String>]
|
|
29
|
-
def reporters
|
|
30
|
-
reporter_hash.keys - ['type_not_defined'] # @todo Hide type_not_defined for now
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Find a reporter by name.
|
|
34
|
-
#
|
|
35
|
-
# @param name [String] The name with which the reporter was registered
|
|
36
|
-
# @return [Class<Solargraph::Diagnostics::Base>, nil]
|
|
37
|
-
def reporter name
|
|
38
|
-
reporter_hash[name]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
# @return [Hash{String => Class<Solargraph::Diagnostics::Base>}]
|
|
44
|
-
def reporter_hash
|
|
45
|
-
@reporter_hash ||= {}
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
register 'rubocop', Rubocop
|
|
50
|
-
register 'require_not_found', RequireNotFound
|
|
51
|
-
register 'typecheck', TypeCheck
|
|
52
|
-
register 'update_errors', UpdateErrors
|
|
53
|
-
register 'type_not_defined', TypeCheck # @todo Retained for backwards compatibility
|
|
54
|
-
end
|
|
55
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
# The Diagnostics library provides reporters for analyzing problems in code
|
|
5
|
+
# and providing the results to language server clients.
|
|
6
|
+
#
|
|
7
|
+
module Diagnostics
|
|
8
|
+
autoload :Base, 'solargraph/diagnostics/base'
|
|
9
|
+
autoload :Severities, 'solargraph/diagnostics/severities'
|
|
10
|
+
autoload :Rubocop, 'solargraph/diagnostics/rubocop'
|
|
11
|
+
autoload :RubocopHelpers, 'solargraph/diagnostics/rubocop_helpers'
|
|
12
|
+
autoload :RequireNotFound, 'solargraph/diagnostics/require_not_found'
|
|
13
|
+
autoload :UpdateErrors, 'solargraph/diagnostics/update_errors'
|
|
14
|
+
autoload :TypeCheck, 'solargraph/diagnostics/type_check'
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
# Add a reporter with a name to identify it in .solargraph.yml files.
|
|
18
|
+
#
|
|
19
|
+
# @param name [String] The name
|
|
20
|
+
# @param klass [Class<Solargraph::Diagnostics::Base>] The class implementation
|
|
21
|
+
# @return [void]
|
|
22
|
+
def register name, klass
|
|
23
|
+
reporter_hash[name] = klass
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Get an array of reporter names.
|
|
27
|
+
#
|
|
28
|
+
# @return [Array<String>]
|
|
29
|
+
def reporters
|
|
30
|
+
reporter_hash.keys - ['type_not_defined'] # @todo Hide type_not_defined for now
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Find a reporter by name.
|
|
34
|
+
#
|
|
35
|
+
# @param name [String] The name with which the reporter was registered
|
|
36
|
+
# @return [Class<Solargraph::Diagnostics::Base>, nil]
|
|
37
|
+
def reporter name
|
|
38
|
+
reporter_hash[name]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# @return [Hash{String => Class<Solargraph::Diagnostics::Base>}]
|
|
44
|
+
def reporter_hash
|
|
45
|
+
@reporter_hash ||= {}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
register 'rubocop', Rubocop
|
|
50
|
+
register 'require_not_found', RequireNotFound
|
|
51
|
+
register 'typecheck', TypeCheck
|
|
52
|
+
register 'update_errors', UpdateErrors
|
|
53
|
+
register 'type_not_defined', TypeCheck # @todo Retained for backwards compatibility
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/solargraph/doc_map.rb
CHANGED
|
@@ -317,6 +317,7 @@ module Solargraph
|
|
|
317
317
|
gemspec = Gem::Specification.find_by_path(path)
|
|
318
318
|
if gemspec.nil?
|
|
319
319
|
gem_name_guess = path.split('/').first
|
|
320
|
+
return nil if gem_name_guess.to_s.empty?
|
|
320
321
|
begin
|
|
321
322
|
# this can happen when the gem is included via a local path in
|
|
322
323
|
# a Gemfile; Gem doesn't try to index the paths in that case.
|
data/lib/solargraph/environ.rb
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
# A collection of additional data, such as map pins and required paths, that
|
|
5
|
-
# can be added to an ApiMap.
|
|
6
|
-
#
|
|
7
|
-
# Conventions are used to add Environs.
|
|
8
|
-
#
|
|
9
|
-
class Environ
|
|
10
|
-
# @return [Array<String>]
|
|
11
|
-
attr_reader :requires
|
|
12
|
-
|
|
13
|
-
# @return [Array<String>]
|
|
14
|
-
attr_reader :domains
|
|
15
|
-
|
|
16
|
-
# @return [Array<Pin::Base>]
|
|
17
|
-
attr_reader :pins
|
|
18
|
-
|
|
19
|
-
# @return [Array<String>]
|
|
20
|
-
attr_reader :yard_plugins
|
|
21
|
-
|
|
22
|
-
# @param requires [Array<String>]
|
|
23
|
-
# @param domains [Array<String>]
|
|
24
|
-
# @param pins [Array<Pin::Base>]
|
|
25
|
-
# @param yard_plugins [Array<String>]
|
|
26
|
-
def initialize requires: [], domains: [], pins: [], yard_plugins: []
|
|
27
|
-
@requires = requires
|
|
28
|
-
@domains = domains
|
|
29
|
-
@pins = pins
|
|
30
|
-
@yard_plugins = yard_plugins
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# @return [self]
|
|
34
|
-
def clear
|
|
35
|
-
domains.clear
|
|
36
|
-
requires.clear
|
|
37
|
-
pins.clear
|
|
38
|
-
yard_plugins.clear
|
|
39
|
-
self
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# @param other [Environ]
|
|
43
|
-
# @return [self]
|
|
44
|
-
def merge other
|
|
45
|
-
domains.concat other.domains
|
|
46
|
-
requires.concat other.requires
|
|
47
|
-
pins.concat other.pins
|
|
48
|
-
yard_plugins.concat other.yard_plugins
|
|
49
|
-
self
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
# A collection of additional data, such as map pins and required paths, that
|
|
5
|
+
# can be added to an ApiMap.
|
|
6
|
+
#
|
|
7
|
+
# Conventions are used to add Environs.
|
|
8
|
+
#
|
|
9
|
+
class Environ
|
|
10
|
+
# @return [Array<String>]
|
|
11
|
+
attr_reader :requires
|
|
12
|
+
|
|
13
|
+
# @return [Array<String>]
|
|
14
|
+
attr_reader :domains
|
|
15
|
+
|
|
16
|
+
# @return [Array<Pin::Base>]
|
|
17
|
+
attr_reader :pins
|
|
18
|
+
|
|
19
|
+
# @return [Array<String>]
|
|
20
|
+
attr_reader :yard_plugins
|
|
21
|
+
|
|
22
|
+
# @param requires [Array<String>]
|
|
23
|
+
# @param domains [Array<String>]
|
|
24
|
+
# @param pins [Array<Pin::Base>]
|
|
25
|
+
# @param yard_plugins [Array<String>]
|
|
26
|
+
def initialize requires: [], domains: [], pins: [], yard_plugins: []
|
|
27
|
+
@requires = requires
|
|
28
|
+
@domains = domains
|
|
29
|
+
@pins = pins
|
|
30
|
+
@yard_plugins = yard_plugins
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [self]
|
|
34
|
+
def clear
|
|
35
|
+
domains.clear
|
|
36
|
+
requires.clear
|
|
37
|
+
pins.clear
|
|
38
|
+
yard_plugins.clear
|
|
39
|
+
self
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param other [Environ]
|
|
43
|
+
# @return [self]
|
|
44
|
+
def merge other
|
|
45
|
+
domains.concat other.domains
|
|
46
|
+
requires.concat other.requires
|
|
47
|
+
pins.concat other.pins
|
|
48
|
+
yard_plugins.concat other.yard_plugins
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/solargraph/gem_pins.rb
CHANGED
|
@@ -11,17 +11,6 @@ module Solargraph
|
|
|
11
11
|
include Logging
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# @param pins [Array<Pin::Base>]
|
|
15
|
-
# @return [Array<Pin::Base>]
|
|
16
|
-
def self.combine_method_pins_by_path pins
|
|
17
|
-
method_pins, alias_pins = pins.partition { |pin| pin.instance_of?(Pin::Method) }
|
|
18
|
-
by_path = method_pins.group_by(&:path)
|
|
19
|
-
by_path.transform_values! do |pins|
|
|
20
|
-
GemPins.combine_method_pins(*pins)
|
|
21
|
-
end
|
|
22
|
-
by_path.values + alias_pins
|
|
23
|
-
end
|
|
24
|
-
|
|
25
14
|
# @param pins [Array<Pin::Method>]
|
|
26
15
|
# @return [Pin::Method, nil]
|
|
27
16
|
def self.combine_method_pins(*pins)
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module LanguageServer
|
|
5
|
-
module Message
|
|
6
|
-
module Extended
|
|
7
|
-
# Update YARD documentation for installed gems. If the `rebuild`
|
|
8
|
-
# parameter is true, rebuild existing yardocs.
|
|
9
|
-
#
|
|
10
|
-
class Environment < Base
|
|
11
|
-
def process
|
|
12
|
-
# Make sure the environment page can report RuboCop's version
|
|
13
|
-
require 'rubocop'
|
|
14
|
-
|
|
15
|
-
page = Solargraph::Page.new(host.options['viewsPath'])
|
|
16
|
-
content = page.render('environment', layout: true, locals: { config: host.options, folders: host.folders })
|
|
17
|
-
set_result(
|
|
18
|
-
content: content
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
module Message
|
|
6
|
+
module Extended
|
|
7
|
+
# Update YARD documentation for installed gems. If the `rebuild`
|
|
8
|
+
# parameter is true, rebuild existing yardocs.
|
|
9
|
+
#
|
|
10
|
+
class Environment < Base
|
|
11
|
+
def process
|
|
12
|
+
# Make sure the environment page can report RuboCop's version
|
|
13
|
+
require 'rubocop'
|
|
14
|
+
|
|
15
|
+
page = Solargraph::Page.new(host.options['viewsPath'])
|
|
16
|
+
content = page.render('environment', layout: true, locals: { config: host.options, folders: host.folders })
|
|
17
|
+
set_result(
|
|
18
|
+
content: content
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|