solargraph 0.59.0.dev.1 → 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/.github/workflows/plugins.yml +4 -1
- data/.github/workflows/rspec.yml +3 -14
- data/.gitignore +1 -0
- data/.rubocop.yml +32 -5
- data/.rubocop_todo.yml +37 -931
- data/CHANGELOG.md +7 -1
- data/Gemfile +3 -1
- data/Rakefile +25 -23
- data/bin/solargraph +2 -1
- data/lib/solargraph/api_map/index.rb +5 -11
- data/lib/solargraph/api_map/source_to_yard.rb +9 -8
- data/lib/solargraph/api_map/store.rb +22 -20
- data/lib/solargraph/api_map.rb +50 -37
- data/lib/solargraph/bench.rb +44 -45
- data/lib/solargraph/complex_type/type_methods.rb +12 -15
- data/lib/solargraph/complex_type/unique_type.rb +54 -43
- data/lib/solargraph/complex_type.rb +69 -61
- 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 +9 -10
- data/lib/solargraph/equality.rb +3 -3
- data/lib/solargraph/gem_pins.rb +7 -5
- 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 +28 -33
- data/lib/solargraph/location.rb +10 -12
- data/lib/solargraph/logging.rb +4 -4
- 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 -42
- 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 -4
- 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 -1
- 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 +78 -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 +71 -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.rb +17 -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 +16 -19
- data/lib/solargraph/position.rb +35 -17
- data/lib/solargraph/range.rb +10 -9
- data/lib/solargraph/rbs_map/conversions.rb +312 -206
- 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 +3 -12
- data/lib/solargraph/server_methods.rb +16 -16
- data/lib/solargraph/shell.rb +63 -53
- 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 +24 -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 +52 -46
- data/lib/solargraph/source_map.rb +8 -4
- data/lib/solargraph/type_checker/rules.rb +8 -8
- data/lib/solargraph/type_checker.rb +95 -101
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +10 -9
- data/lib/solargraph/workspace/gemspecs.rb +1 -1
- data/lib/solargraph/workspace.rb +21 -44
- 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_tags.rb +20 -20
- data/lib/solargraph.rb +5 -5
- data/solargraph.gemspec +35 -34
- metadata +28 -28
|
@@ -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
|
|
@@ -13,7 +13,7 @@ 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
|
|
@@ -24,7 +24,7 @@ module Solargraph
|
|
|
24
24
|
# @type [Array<Gem::Specification>]
|
|
25
25
|
specs = e.specs
|
|
26
26
|
raise InvalidRubocopVersionError,
|
|
27
|
-
"could not find '#{e.name}' (#{e.requirement}) - "\
|
|
27
|
+
"could not find '#{e.name}' (#{e.requirement}) - " \
|
|
28
28
|
"did find: [#{specs.map { |s| s.version.version }.join(', ')}]"
|
|
29
29
|
end
|
|
30
30
|
require 'rubocop'
|
|
@@ -52,7 +52,7 @@ module Solargraph
|
|
|
52
52
|
def fix_drive_letter path
|
|
53
53
|
return path unless path.match(/^[a-z]:/)
|
|
54
54
|
# @sg-ignore Need to add nil check here
|
|
55
|
-
path[0].upcase + path[1
|
|
55
|
+
path[0].upcase + path[1..]
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
# @todo This is a smelly way to redirect output, but the RuboCop specs do
|
|
@@ -10,19 +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
14
|
# @sg-ignore sensitive typing needs to handle || on nil types
|
|
15
15
|
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym)
|
|
16
16
|
checker.problems
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
private
|
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Diagnostics
|
|
5
|
-
class UpdateErrors < Base
|
|
6
|
-
def diagnose source, api_map
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Diagnostics
|
|
5
|
+
class UpdateErrors < Base
|
|
6
|
+
def diagnose source, api_map
|
|
7
|
+
combine_ranges(source.code, source.error_ranges).map do |range|
|
|
8
|
+
{ range: range.to_hash,
|
|
9
|
+
severity: Diagnostics::Severities::ERROR,
|
|
10
|
+
source: 'Solargraph',
|
|
11
|
+
message: 'Syntax error' }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
# Combine an array of ranges by their starting lines.
|
|
18
|
+
#
|
|
19
|
+
# @param code [String]
|
|
20
|
+
# @param ranges [Array<Range>]
|
|
21
|
+
# @return [Array<Range>]
|
|
22
|
+
def combine_ranges code, ranges
|
|
23
|
+
result = []
|
|
24
|
+
lines = []
|
|
25
|
+
ranges.sort { |a, b| a.start.line <=> b.start.line }.each do |rng|
|
|
26
|
+
next if rng.nil? || lines.include?(rng.start.line)
|
|
27
|
+
lines.push rng.start.line
|
|
28
|
+
next if rng.start.line >= code.lines.length
|
|
29
|
+
scol = code.lines[rng.start.line].index(/[^\s]/) || 0
|
|
30
|
+
ecol = code.lines[rng.start.line].length
|
|
31
|
+
result.push Range.from_to(rng.start.line, scol, rng.start.line, ecol)
|
|
32
|
+
end
|
|
33
|
+
result
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/solargraph/doc_map.rb
CHANGED
|
@@ -98,12 +98,12 @@ module Solargraph
|
|
|
98
98
|
@dependencies ||=
|
|
99
99
|
begin
|
|
100
100
|
gem_deps = gemspecs
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
.flat_map { |spec| workspace.fetch_dependencies(spec, out: out) }
|
|
102
|
+
.uniq(&:name)
|
|
103
103
|
stdlib_deps = gemspecs
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
.flat_map { |spec| workspace.stdlib_dependencies(spec.name) }
|
|
105
|
+
.flat_map { |dep_name| workspace.resolve_require(dep_name) }
|
|
106
|
+
.compact
|
|
107
107
|
existing_gems = gemspecs.map(&:name)
|
|
108
108
|
(gem_deps + stdlib_deps).reject { |gemspec| existing_gems.include? gemspec.name }
|
|
109
109
|
end
|
|
@@ -134,11 +134,10 @@ module Solargraph
|
|
|
134
134
|
def load_serialized_gem_pins out: @out
|
|
135
135
|
serialized_pins = []
|
|
136
136
|
with_gemspecs, without_gemspecs = required_gems_map.partition { |_, v| v }
|
|
137
|
-
# @sg-ignore Need better typing for Hash[]
|
|
138
137
|
# @type [Array<String>]
|
|
139
|
-
missing_paths =
|
|
138
|
+
missing_paths = without_gemspecs.to_h.keys
|
|
140
139
|
# @type [Array<Gem::Specification>]
|
|
141
|
-
gemspecs =
|
|
140
|
+
gemspecs = with_gemspecs.to_h.values.flatten.compact + dependencies(out: out).to_a
|
|
142
141
|
|
|
143
142
|
# if we are type checking a gem project, we should not include
|
|
144
143
|
# pins from rbs or yard from that gem here - we use our own
|
|
@@ -167,7 +166,7 @@ module Solargraph
|
|
|
167
166
|
end
|
|
168
167
|
end
|
|
169
168
|
|
|
170
|
-
|
|
169
|
+
serialized_pins.length
|
|
171
170
|
time = Benchmark.measure do
|
|
172
171
|
gemspecs.each do |gemspec|
|
|
173
172
|
# only deserializes already-cached gems
|
|
@@ -179,7 +178,7 @@ module Solargraph
|
|
|
179
178
|
end
|
|
180
179
|
end
|
|
181
180
|
end
|
|
182
|
-
|
|
181
|
+
serialized_pins.length
|
|
183
182
|
milliseconds = (time.real * 1000).round
|
|
184
183
|
if (milliseconds > 500) && out && gemspecs.any?
|
|
185
184
|
out.puts "Deserialized #{serialized_pins.length} gem pins from #{PinCache.base_dir} in #{milliseconds} ms"
|
data/lib/solargraph/equality.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Solargraph
|
|
|
10
10
|
|
|
11
11
|
# @param other [Object]
|
|
12
12
|
# @return [Boolean]
|
|
13
|
-
def eql?
|
|
13
|
+
def eql? other
|
|
14
14
|
self.class.eql?(other.class) &&
|
|
15
15
|
# @sg-ignore flow sensitive typing should support .class == .class
|
|
16
16
|
equality_fields.eql?(other.equality_fields)
|
|
@@ -18,8 +18,8 @@ module Solargraph
|
|
|
18
18
|
|
|
19
19
|
# @param other [Object]
|
|
20
20
|
# @return [Boolean]
|
|
21
|
-
def ==
|
|
22
|
-
|
|
21
|
+
def == other
|
|
22
|
+
eql?(other)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def hash
|
data/lib/solargraph/gem_pins.rb
CHANGED
|
@@ -13,8 +13,8 @@ module Solargraph
|
|
|
13
13
|
|
|
14
14
|
# @param pins [Array<Pin::Base>]
|
|
15
15
|
# @return [Array<Pin::Base>]
|
|
16
|
-
def self.combine_method_pins_by_path
|
|
17
|
-
method_pins, alias_pins = pins.partition { |pin| pin.
|
|
16
|
+
def self.combine_method_pins_by_path pins
|
|
17
|
+
method_pins, alias_pins = pins.partition { |pin| pin.instance_of?(Pin::Method) }
|
|
18
18
|
by_path = method_pins.group_by(&:path)
|
|
19
19
|
by_path.transform_values! do |pins|
|
|
20
20
|
GemPins.combine_method_pins(*pins)
|
|
@@ -47,7 +47,7 @@ module Solargraph
|
|
|
47
47
|
# @param rbs_pins [Array<Pin::Base>]
|
|
48
48
|
#
|
|
49
49
|
# @return [Array<Pin::Base>]
|
|
50
|
-
def self.combine
|
|
50
|
+
def self.combine yard_pins, rbs_pins
|
|
51
51
|
in_yard = Set.new
|
|
52
52
|
rbs_store = Solargraph::ApiMap::Store.new(rbs_pins)
|
|
53
53
|
combined = yard_pins.map do |yard_pin|
|
|
@@ -57,7 +57,9 @@ module Solargraph
|
|
|
57
57
|
next yard_pin unless rbs_pin && yard_pin.is_a?(Pin::Method)
|
|
58
58
|
|
|
59
59
|
unless rbs_pin
|
|
60
|
-
logger.debug
|
|
60
|
+
logger.debug do
|
|
61
|
+
"GemPins.combine: No rbs pin for #{yard_pin.path} - using YARD's '#{yard_pin.inspect} (return_type=#{yard_pin.return_type}; signatures=#{yard_pin.signatures})"
|
|
62
|
+
end
|
|
61
63
|
next yard_pin
|
|
62
64
|
end
|
|
63
65
|
|
|
@@ -90,7 +92,7 @@ module Solargraph
|
|
|
90
92
|
# @param choices [Array<ComplexType>]
|
|
91
93
|
# @return [ComplexType]
|
|
92
94
|
def best_return_type *choices
|
|
93
|
-
choices.find
|
|
95
|
+
choices.find(&:defined?) || choices.first || ComplexType::UNDEFINED
|
|
94
96
|
end
|
|
95
97
|
end
|
|
96
98
|
end
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module LanguageServer
|
|
5
|
-
# The ErrorCode constants for the language server protocol.
|
|
6
|
-
#
|
|
7
|
-
module ErrorCodes
|
|
8
|
-
PARSE_ERROR = -
|
|
9
|
-
INVALID_REQUEST = -
|
|
10
|
-
METHOD_NOT_FOUND = -
|
|
11
|
-
INVALID_PARAMS = -
|
|
12
|
-
INTERNAL_ERROR = -
|
|
13
|
-
SERVER_ERROR_START = -
|
|
14
|
-
SERVER_ERROR_END = -
|
|
15
|
-
SERVER_NOT_INITIALIZED = -
|
|
16
|
-
UNKNOWN_ERROR_CODE = -
|
|
17
|
-
REQUEST_CANCELLED = -
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module LanguageServer
|
|
5
|
+
# The ErrorCode constants for the language server protocol.
|
|
6
|
+
#
|
|
7
|
+
module ErrorCodes
|
|
8
|
+
PARSE_ERROR = -32_700
|
|
9
|
+
INVALID_REQUEST = -32_600
|
|
10
|
+
METHOD_NOT_FOUND = -32_601
|
|
11
|
+
INVALID_PARAMS = -32_602
|
|
12
|
+
INTERNAL_ERROR = -32_603
|
|
13
|
+
SERVER_ERROR_START = -32_099
|
|
14
|
+
SERVER_ERROR_END = -32_000
|
|
15
|
+
SERVER_NOT_INITIALIZED = -32_002
|
|
16
|
+
UNKNOWN_ERROR_CODE = -32_001
|
|
17
|
+
REQUEST_CANCELLED = -32_800
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|