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
|
@@ -14,16 +14,17 @@ module Solargraph
|
|
|
14
14
|
method_name = node.children[1]
|
|
15
15
|
# :nocov:
|
|
16
16
|
unless method_name.instance_of?(Symbol)
|
|
17
|
-
Solargraph.assert_or_log(:parser_method_name,
|
|
17
|
+
Solargraph.assert_or_log(:parser_method_name,
|
|
18
|
+
"Expected method name to be a Symbol, got #{method_name.class} for node #{node.inspect}")
|
|
18
19
|
return process_children
|
|
19
20
|
end
|
|
20
21
|
# :nocov:
|
|
21
22
|
if node.children[0].nil?
|
|
22
|
-
if [
|
|
23
|
+
if %i[private public protected].include?(method_name)
|
|
23
24
|
process_visibility
|
|
24
25
|
elsif method_name == :module_function
|
|
25
26
|
process_module_function
|
|
26
|
-
elsif [
|
|
27
|
+
elsif %i[attr_reader attr_writer attr_accessor].include?(method_name)
|
|
27
28
|
process_attribute
|
|
28
29
|
elsif method_name == :include
|
|
29
30
|
process_include
|
|
@@ -44,7 +45,10 @@ module Solargraph
|
|
|
44
45
|
return if process_private_class_method
|
|
45
46
|
end
|
|
46
47
|
elsif method_name == :require && node.children[0].to_s == '(const nil :Bundler)'
|
|
47
|
-
pins.push Pin::Reference::Require.new(
|
|
48
|
+
pins.push Pin::Reference::Require.new(
|
|
49
|
+
Solargraph::Location.new(region.filename,
|
|
50
|
+
Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require', source: :parser
|
|
51
|
+
)
|
|
48
52
|
end
|
|
49
53
|
process_children
|
|
50
54
|
end
|
|
@@ -53,21 +57,22 @@ module Solargraph
|
|
|
53
57
|
|
|
54
58
|
# @return [void]
|
|
55
59
|
def process_visibility
|
|
56
|
-
if
|
|
60
|
+
if node.children.length > 2
|
|
57
61
|
# @sg-ignore Need to add nil check here
|
|
58
|
-
node.children[2
|
|
62
|
+
node.children[2..].each do |child|
|
|
59
63
|
# @sg-ignore Variable type could not be inferred for method_name
|
|
60
64
|
# @type [Symbol]
|
|
61
65
|
visibility = node.children[1]
|
|
62
66
|
# :nocov:
|
|
63
67
|
unless visibility.instance_of?(Symbol)
|
|
64
|
-
Solargraph.assert_or_log(:parser_visibility,
|
|
68
|
+
Solargraph.assert_or_log(:parser_visibility,
|
|
69
|
+
"Expected visibility name to be a Symbol, got #{visibility.class} for node #{node.inspect}")
|
|
65
70
|
return process_children
|
|
66
71
|
end
|
|
67
72
|
# :nocov:
|
|
68
|
-
if child.is_a?(::Parser::AST::Node) &&
|
|
73
|
+
if child.is_a?(::Parser::AST::Node) && %i[sym str].include?(child.type)
|
|
69
74
|
name = child.children[0].to_s
|
|
70
|
-
matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
|
|
75
|
+
matches = pins.select { |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance) }
|
|
71
76
|
matches.each do |pin|
|
|
72
77
|
# @todo Smelly instance variable access
|
|
73
78
|
pin.instance_variable_set(:@visibility, visibility)
|
|
@@ -85,11 +90,11 @@ module Solargraph
|
|
|
85
90
|
# @return [void]
|
|
86
91
|
def process_attribute
|
|
87
92
|
# @sg-ignore Need to add nil check here
|
|
88
|
-
node.children[2
|
|
93
|
+
node.children[2..].each do |a|
|
|
89
94
|
loc = get_node_location(node)
|
|
90
95
|
clos = region.closure
|
|
91
96
|
cmnt = comments_for(node)
|
|
92
|
-
if
|
|
97
|
+
if %i[attr_reader attr_accessor].include?(node.children[1])
|
|
93
98
|
pins.push Solargraph::Pin::Method.new(
|
|
94
99
|
location: loc,
|
|
95
100
|
closure: clos,
|
|
@@ -101,63 +106,62 @@ module Solargraph
|
|
|
101
106
|
source: :parser
|
|
102
107
|
)
|
|
103
108
|
end
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
next unless %i[attr_writer attr_accessor].include?(node.children[1])
|
|
110
|
+
method_pin = Solargraph::Pin::Method.new(
|
|
111
|
+
location: loc,
|
|
112
|
+
closure: clos,
|
|
113
|
+
name: "#{a.children[0]}=",
|
|
114
|
+
comments: cmnt,
|
|
115
|
+
scope: region.scope || :instance,
|
|
116
|
+
visibility: region.visibility,
|
|
117
|
+
attribute: true,
|
|
118
|
+
source: :parser
|
|
119
|
+
)
|
|
120
|
+
pins.push method_pin
|
|
121
|
+
method_pin.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last,
|
|
122
|
+
source: :parser)
|
|
123
|
+
if method_pin.return_type.defined?
|
|
124
|
+
pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '',
|
|
125
|
+
pins.last.return_type.items.map(&:rooted_tags), 'value')
|
|
120
126
|
end
|
|
121
127
|
end
|
|
122
128
|
end
|
|
123
129
|
|
|
124
130
|
# @return [void]
|
|
125
131
|
def process_include
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
end
|
|
132
|
+
return unless node.children[2].is_a?(AST::Node) && node.children[2].type == :const
|
|
133
|
+
cp = region.closure
|
|
134
|
+
# @sg-ignore Need to add nil check here
|
|
135
|
+
node.children[2..].each do |i|
|
|
136
|
+
type = region.scope == :class ? Pin::Reference::Extend : Pin::Reference::Include
|
|
137
|
+
pins.push type.new(
|
|
138
|
+
location: get_node_location(i),
|
|
139
|
+
closure: cp,
|
|
140
|
+
name: unpack_name(i),
|
|
141
|
+
source: :parser
|
|
142
|
+
)
|
|
138
143
|
end
|
|
139
144
|
end
|
|
140
145
|
|
|
141
146
|
# @return [void]
|
|
142
147
|
def process_prepend
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
end
|
|
148
|
+
return unless node.children[2].is_a?(AST::Node) && node.children[2].type == :const
|
|
149
|
+
cp = region.closure
|
|
150
|
+
# @sg-ignore Need to add nil check here
|
|
151
|
+
node.children[2..].each do |i|
|
|
152
|
+
pins.push Pin::Reference::Prepend.new(
|
|
153
|
+
location: get_node_location(i),
|
|
154
|
+
closure: cp,
|
|
155
|
+
name: unpack_name(i),
|
|
156
|
+
source: :parser
|
|
157
|
+
)
|
|
154
158
|
end
|
|
155
159
|
end
|
|
156
160
|
|
|
157
161
|
# @return [void]
|
|
158
162
|
def process_extend
|
|
159
163
|
# @sg-ignore Need to add nil check here
|
|
160
|
-
node.children[2
|
|
164
|
+
node.children[2..].each do |i|
|
|
161
165
|
loc = get_node_location(node)
|
|
162
166
|
if i.type == :self
|
|
163
167
|
pins.push Pin::Reference::Extend.new(
|
|
@@ -179,18 +183,16 @@ module Solargraph
|
|
|
179
183
|
|
|
180
184
|
# @return [void]
|
|
181
185
|
def process_require
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
end
|
|
186
|
+
return unless node.children[2].is_a?(AST::Node) && node.children[2].type == :str
|
|
187
|
+
path = node.children[2].children[0].to_s
|
|
188
|
+
pins.push Pin::Reference::Require.new(get_node_location(node), path, source: :parser)
|
|
186
189
|
end
|
|
187
190
|
|
|
188
191
|
# @return [void]
|
|
189
192
|
def process_autoload
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
end
|
|
193
|
+
return unless node.children[3].is_a?(AST::Node) && node.children[3].type == :str
|
|
194
|
+
path = node.children[3].children[0].to_s
|
|
195
|
+
pins.push Pin::Reference::Require.new(get_node_location(node), path, source: :parser)
|
|
194
196
|
end
|
|
195
197
|
|
|
196
198
|
# @return [void]
|
|
@@ -198,55 +200,55 @@ module Solargraph
|
|
|
198
200
|
if node.children[2].nil?
|
|
199
201
|
# @todo Smelly instance variable access
|
|
200
202
|
region.instance_variable_set(:@visibility, :module_function)
|
|
201
|
-
elsif
|
|
203
|
+
elsif %i[sym str].include?(node.children[2].type)
|
|
202
204
|
# @sg-ignore Need to add nil check here
|
|
203
|
-
node.children[2
|
|
205
|
+
node.children[2..].each do |x|
|
|
204
206
|
cn = x.children[0].to_s
|
|
205
207
|
# @type [Pin::Method, nil]
|
|
206
208
|
ref = pins.find { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
209
|
+
next if ref.nil?
|
|
210
|
+
pins.delete ref
|
|
211
|
+
mm = Solargraph::Pin::Method.new(
|
|
212
|
+
location: ref.location,
|
|
213
|
+
closure: ref.closure,
|
|
214
|
+
name: ref.name,
|
|
215
|
+
parameters: ref.parameters,
|
|
216
|
+
comments: ref.comments,
|
|
217
|
+
scope: :class,
|
|
218
|
+
visibility: :public,
|
|
219
|
+
node: ref.node,
|
|
220
|
+
source: :parser
|
|
221
|
+
)
|
|
222
|
+
cm = Solargraph::Pin::Method.new(
|
|
223
|
+
location: ref.location,
|
|
224
|
+
closure: ref.closure,
|
|
225
|
+
name: ref.name,
|
|
226
|
+
parameters: ref.parameters,
|
|
227
|
+
comments: ref.comments,
|
|
228
|
+
scope: :instance,
|
|
229
|
+
visibility: :private,
|
|
230
|
+
node: ref.node,
|
|
231
|
+
source: :parser
|
|
232
|
+
)
|
|
233
|
+
pins.push mm, cm
|
|
234
|
+
ivars.select { |pin| pin.is_a?(Pin::InstanceVariable) && pin.closure.path == ref.path }.each do |ivar|
|
|
235
|
+
ivars.delete ivar
|
|
236
|
+
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
237
|
+
location: ivar.location,
|
|
238
|
+
closure: cm,
|
|
239
|
+
name: ivar.name,
|
|
240
|
+
comments: ivar.comments,
|
|
241
|
+
assignment: ivar.assignment,
|
|
242
|
+
source: :parser
|
|
243
|
+
)
|
|
244
|
+
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
245
|
+
location: ivar.location,
|
|
246
|
+
closure: mm,
|
|
247
|
+
name: ivar.name,
|
|
248
|
+
comments: ivar.comments,
|
|
249
|
+
assignment: ivar.assignment,
|
|
218
250
|
source: :parser
|
|
219
251
|
)
|
|
220
|
-
cm = Solargraph::Pin::Method.new(
|
|
221
|
-
location: ref.location,
|
|
222
|
-
closure: ref.closure,
|
|
223
|
-
name: ref.name,
|
|
224
|
-
parameters: ref.parameters,
|
|
225
|
-
comments: ref.comments,
|
|
226
|
-
scope: :instance,
|
|
227
|
-
visibility: :private,
|
|
228
|
-
node: ref.node,
|
|
229
|
-
source: :parser)
|
|
230
|
-
pins.push mm, cm
|
|
231
|
-
ivars.select{|pin| pin.is_a?(Pin::InstanceVariable) && pin.closure.path == ref.path}.each do |ivar|
|
|
232
|
-
ivars.delete ivar
|
|
233
|
-
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
234
|
-
location: ivar.location,
|
|
235
|
-
closure: cm,
|
|
236
|
-
name: ivar.name,
|
|
237
|
-
comments: ivar.comments,
|
|
238
|
-
assignment: ivar.assignment,
|
|
239
|
-
source: :parser
|
|
240
|
-
)
|
|
241
|
-
ivars.push Solargraph::Pin::InstanceVariable.new(
|
|
242
|
-
location: ivar.location,
|
|
243
|
-
closure: mm,
|
|
244
|
-
name: ivar.name,
|
|
245
|
-
comments: ivar.comments,
|
|
246
|
-
assignment: ivar.assignment,
|
|
247
|
-
source: :parser
|
|
248
|
-
)
|
|
249
|
-
end
|
|
250
252
|
end
|
|
251
253
|
end
|
|
252
254
|
elsif node.children[2].type == :def
|
|
@@ -256,17 +258,19 @@ module Solargraph
|
|
|
256
258
|
|
|
257
259
|
# @return [void]
|
|
258
260
|
def process_private_constant
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
end
|
|
261
|
+
return unless node.children[2] && %i[sym str].include?(node.children[2].type)
|
|
262
|
+
cn = node.children[2].children[0].to_s
|
|
263
|
+
ref = pins.select do |p|
|
|
264
|
+
[Solargraph::Pin::Namespace,
|
|
265
|
+
Solargraph::Pin::Constant].include?(p.class) && p.namespace == region.closure.full_context.namespace && p.name == cn
|
|
266
|
+
end.first
|
|
267
|
+
# HACK: Smelly instance variable access
|
|
268
|
+
ref&.instance_variable_set(:@visibility, :private)
|
|
265
269
|
end
|
|
266
270
|
|
|
267
271
|
# @return [void]
|
|
268
272
|
def process_alias_method
|
|
269
|
-
|
|
273
|
+
get_node_location(node)
|
|
270
274
|
pins.push Solargraph::Pin::MethodAlias.new(
|
|
271
275
|
location: get_node_location(node),
|
|
272
276
|
closure: region.closure,
|
|
@@ -279,10 +283,12 @@ module Solargraph
|
|
|
279
283
|
|
|
280
284
|
# @return [Boolean]
|
|
281
285
|
def process_private_class_method
|
|
282
|
-
if
|
|
283
|
-
ref = pins.select
|
|
286
|
+
if %i[sym str].include?(node.children[2].type)
|
|
287
|
+
ref = pins.select do |p|
|
|
288
|
+
p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == node.children[2].children[0].to_s
|
|
289
|
+
end.first
|
|
284
290
|
# HACK: Smelly instance variable access
|
|
285
|
-
ref
|
|
291
|
+
ref&.instance_variable_set(:@visibility, :private)
|
|
286
292
|
false
|
|
287
293
|
else
|
|
288
294
|
process_children region.update(scope: :class, visibility: :private)
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
module Parser
|
|
5
|
-
module ParserGem
|
|
6
|
-
module NodeProcessors
|
|
7
|
-
class UntilNode < Parser::NodeProcessor::Base
|
|
8
|
-
include ParserGem::NodeMethods
|
|
9
|
-
|
|
10
|
-
def process
|
|
11
|
-
location = get_node_location(node)
|
|
12
|
-
# Note - this should not be considered a block, as the
|
|
13
|
-
# until statement doesn't create a closure - e.g.,
|
|
14
|
-
# variables created inside can be seen from outside as
|
|
15
|
-
# well
|
|
16
|
-
pins.push Solargraph::Pin::Until.new(
|
|
17
|
-
location: location,
|
|
18
|
-
closure: region.closure,
|
|
19
|
-
node: node,
|
|
20
|
-
comments: comments_for(node),
|
|
21
|
-
source: :parser
|
|
22
|
-
)
|
|
23
|
-
process_children region
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
module NodeProcessors
|
|
7
|
+
class UntilNode < Parser::NodeProcessor::Base
|
|
8
|
+
include ParserGem::NodeMethods
|
|
9
|
+
|
|
10
|
+
def process
|
|
11
|
+
location = get_node_location(node)
|
|
12
|
+
# Note - this should not be considered a block, as the
|
|
13
|
+
# until statement doesn't create a closure - e.g.,
|
|
14
|
+
# variables created inside can be seen from outside as
|
|
15
|
+
# well
|
|
16
|
+
pins.push Solargraph::Pin::Until.new(
|
|
17
|
+
location: location,
|
|
18
|
+
closure: region.closure,
|
|
19
|
+
node: node,
|
|
20
|
+
comments: comments_for(node),
|
|
21
|
+
source: :parser
|
|
22
|
+
)
|
|
23
|
+
process_children region
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
autoload :
|
|
7
|
-
autoload :
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
module ParserGem
|
|
6
|
+
autoload :FlawedBuilder, 'solargraph/parser/parser_gem/flawed_builder'
|
|
7
|
+
autoload :ClassMethods, 'solargraph/parser/parser_gem/class_methods'
|
|
8
|
+
autoload :NodeMethods, 'solargraph/parser/parser_gem/node_methods'
|
|
9
|
+
autoload :NodeChainer, 'solargraph/parser/parser_gem/node_chainer'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
require 'solargraph/parser/parser_gem/node_processors'
|
data/lib/solargraph/parser.rb
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
autoload :
|
|
6
|
-
autoload :
|
|
7
|
-
autoload :
|
|
8
|
-
autoload :
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
extend
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module Parser
|
|
5
|
+
autoload :CommentRipper, 'solargraph/parser/comment_ripper'
|
|
6
|
+
autoload :ParserGem, 'solargraph/parser/parser_gem'
|
|
7
|
+
autoload :Region, 'solargraph/parser/region'
|
|
8
|
+
autoload :NodeProcessor, 'solargraph/parser/node_processor'
|
|
9
|
+
autoload :FlowSensitiveTyping, 'solargraph/parser/flow_sensitive_typing'
|
|
10
|
+
autoload :Snippet, 'solargraph/parser/snippet'
|
|
11
|
+
|
|
12
|
+
class SyntaxError < StandardError
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @deprecated
|
|
16
|
+
Legacy = ParserGem
|
|
17
|
+
|
|
18
|
+
ClassMethods = ParserGem::ClassMethods
|
|
19
|
+
# @todo should be able to just 'extend ClassMethods' here and
|
|
20
|
+
# typecheck things off it in strict mode
|
|
21
|
+
extend ParserGem::ClassMethods
|
|
22
|
+
|
|
23
|
+
NodeMethods = ParserGem::NodeMethods
|
|
24
|
+
end
|
|
25
|
+
end
|