solargraph 0.56.0 → 0.56.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/CHANGELOG.md +14 -1
- data/lib/solargraph/convention/data_definition/data_assignment_node.rb +60 -0
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +89 -0
- data/lib/solargraph/convention/data_definition.rb +104 -0
- data/lib/solargraph/convention/gemspec.rb +2 -1
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +1 -1
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +1 -1
- data/lib/solargraph/convention/struct_definition.rb +60 -20
- data/lib/solargraph/convention.rb +1 -0
- data/lib/solargraph/doc_map.rb +8 -5
- data/lib/solargraph/library.rb +39 -15
- data/lib/solargraph/parser/node_processor/base.rb +9 -4
- data/lib/solargraph/parser/node_processor.rb +19 -7
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +1 -21
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +4 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +0 -22
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors.rb +4 -0
- data/lib/solargraph/pin/base.rb +15 -0
- data/lib/solargraph/pin/method.rb +4 -2
- data/lib/solargraph/rbs_map/conversions.rb +41 -14
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +1 -1
- data/lib/solargraph/workspace.rb +8 -0
- data/lib/solargraph/yard_map/helpers.rb +29 -1
- data/lib/solargraph/yard_map/mapper/to_constant.rb +5 -5
- data/lib/solargraph/yard_map/mapper/to_method.rb +1 -6
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +7 -7
- data/lib/solargraph/yardoc.rb +2 -0
- data/lib/solargraph.rb +13 -0
- data/solargraph.gemspec +1 -1
- metadata +7 -4
@@ -8,17 +8,6 @@ module Solargraph
|
|
8
8
|
include ParserGem::NodeMethods
|
9
9
|
|
10
10
|
def process
|
11
|
-
if Convention::StructDefinition::StructAssignmentNode.valid?(node)
|
12
|
-
process_struct_assignment
|
13
|
-
else
|
14
|
-
process_constant_assignment
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
# @return [void]
|
21
|
-
def process_constant_assignment
|
22
11
|
pins.push Solargraph::Pin::Constant.new(
|
23
12
|
location: get_node_location(node),
|
24
13
|
closure: region.closure,
|
@@ -30,16 +19,7 @@ module Solargraph
|
|
30
19
|
process_children
|
31
20
|
end
|
32
21
|
|
33
|
-
|
34
|
-
# multiple processors.
|
35
|
-
def process_struct_assignment
|
36
|
-
processor_klass = Convention::StructDefinition::NodeProcessors::StructNode
|
37
|
-
processor = processor_klass.new(node, region, pins, locals)
|
38
|
-
processor.process
|
39
|
-
|
40
|
-
@pins = processor.pins
|
41
|
-
@locals = processor.locals
|
42
|
-
end
|
22
|
+
private
|
43
23
|
|
44
24
|
# @return [String]
|
45
25
|
def const_name
|
@@ -7,6 +7,7 @@ module Solargraph
|
|
7
7
|
class MasgnNode < Parser::NodeProcessor::Base
|
8
8
|
include ParserGem::NodeMethods
|
9
9
|
|
10
|
+
# @return [void]
|
10
11
|
def process
|
11
12
|
# Example:
|
12
13
|
#
|
@@ -40,7 +41,9 @@ module Solargraph
|
|
40
41
|
# @todo in line below, nothing in typechecking alerts
|
41
42
|
# when a non-existant method is called on 'l'
|
42
43
|
if pin.nil?
|
43
|
-
Solargraph.logger.debug
|
44
|
+
Solargraph.logger.debug do
|
45
|
+
"Could not find local for masgn= value in location #{location.inspect} in #{lhs_arr} - masgn = #{masgn}, lhs.type = #{lhs.type}"
|
46
|
+
end
|
44
47
|
next
|
45
48
|
end
|
46
49
|
pin.mass_assignment = [mass_rhs, i]
|
@@ -11,17 +11,6 @@ module Solargraph
|
|
11
11
|
superclass_name = nil
|
12
12
|
superclass_name = unpack_name(node.children[1]) if node.type == :class && node.children[1]&.type == :const
|
13
13
|
|
14
|
-
if Convention::StructDefinition::StructDefintionNode.valid?(node)
|
15
|
-
process_struct_definition
|
16
|
-
else
|
17
|
-
process_namespace(superclass_name)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
# @param superclass_name [String, nil]
|
24
|
-
def process_namespace(superclass_name)
|
25
14
|
loc = get_node_location(node)
|
26
15
|
nspin = Solargraph::Pin::Namespace.new(
|
27
16
|
type: node.type,
|
@@ -44,17 +33,6 @@ module Solargraph
|
|
44
33
|
end
|
45
34
|
process_children region.update(closure: nspin, visibility: :public)
|
46
35
|
end
|
47
|
-
|
48
|
-
# @todo Move this out of [NamespaceNode] once [Solargraph::Parser::NodeProcessor] supports
|
49
|
-
# multiple processors.
|
50
|
-
def process_struct_definition
|
51
|
-
processor_klass = Convention::StructDefinition::NodeProcessors::StructNode
|
52
|
-
processor = processor_klass.new(node, region, pins, locals)
|
53
|
-
processor.process
|
54
|
-
|
55
|
-
@pins = processor.pins
|
56
|
-
@locals = processor.locals
|
57
|
-
end
|
58
36
|
end
|
59
37
|
end
|
60
38
|
end
|
@@ -5,6 +5,7 @@ module Solargraph
|
|
5
5
|
module ParserGem
|
6
6
|
module NodeProcessors
|
7
7
|
class OrasgnNode < Parser::NodeProcessor::Base
|
8
|
+
# @return [void]
|
8
9
|
def process
|
9
10
|
new_node = node.updated(node.children[0].type, node.children[0].children + [node.children[1]])
|
10
11
|
NodeProcessor.process(new_node, region, pins, locals)
|
@@ -42,6 +42,8 @@ module Solargraph
|
|
42
42
|
register :defs, ParserGem::NodeProcessors::DefsNode
|
43
43
|
register :if, ParserGem::NodeProcessors::IfNode
|
44
44
|
register :send, ParserGem::NodeProcessors::SendNode
|
45
|
+
register :class, Convention::StructDefinition::NodeProcessors::StructNode
|
46
|
+
register :class, Convention::DataDefinition::NodeProcessors::DataNode
|
45
47
|
register :class, ParserGem::NodeProcessors::NamespaceNode
|
46
48
|
register :module, ParserGem::NodeProcessors::NamespaceNode
|
47
49
|
register :sclass, ParserGem::NodeProcessors::SclassNode
|
@@ -49,6 +51,8 @@ module Solargraph
|
|
49
51
|
register :cvasgn, ParserGem::NodeProcessors::CvasgnNode
|
50
52
|
register :lvasgn, ParserGem::NodeProcessors::LvasgnNode
|
51
53
|
register :gvasgn, ParserGem::NodeProcessors::GvasgnNode
|
54
|
+
register :casgn, Convention::StructDefinition::NodeProcessors::StructNode
|
55
|
+
register :casgn, Convention::DataDefinition::NodeProcessors::DataNode
|
52
56
|
register :casgn, ParserGem::NodeProcessors::CasgnNode
|
53
57
|
register :masgn, ParserGem::NodeProcessors::MasgnNode
|
54
58
|
register :alias, ParserGem::NodeProcessors::AliasNode
|
data/lib/solargraph/pin/base.rb
CHANGED
@@ -51,6 +51,14 @@ module Solargraph
|
|
51
51
|
@docstring = docstring
|
52
52
|
@directives = directives
|
53
53
|
assert_source_provided
|
54
|
+
assert_location_provided
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [void]
|
58
|
+
def assert_location_provided
|
59
|
+
return unless best_location.nil? && %i[yardoc source rbs].include?(source)
|
60
|
+
|
61
|
+
Solargraph.assert_or_log(:best_location, "Neither location nor type_location provided - #{path} #{source} #{self.class}")
|
54
62
|
end
|
55
63
|
|
56
64
|
# @param other [self]
|
@@ -290,6 +298,9 @@ module Solargraph
|
|
290
298
|
choose_pin_attr(other, attr)
|
291
299
|
end
|
292
300
|
|
301
|
+
# @param other [self]
|
302
|
+
# @param attr [::Symbol]
|
303
|
+
# @return [undefined]
|
293
304
|
def choose_pin_attr(other, attr)
|
294
305
|
# @type [Pin::Base, nil]
|
295
306
|
val1 = send(attr)
|
@@ -304,6 +315,7 @@ module Solargraph
|
|
304
315
|
[val1, val2].compact.min_by { _1.best_location.to_s }
|
305
316
|
end
|
306
317
|
|
318
|
+
# @return [void]
|
307
319
|
def assert_source_provided
|
308
320
|
Solargraph.assert_or_log(:source, "source not provided - #{@path} #{@source} #{self.class}") if source.nil?
|
309
321
|
end
|
@@ -548,6 +560,7 @@ module Solargraph
|
|
548
560
|
"name=#{name.inspect} return_type=#{type_desc}, context=#{context.rooted_tags}, closure=#{closure_info}, binder=#{binder_info}"
|
549
561
|
end
|
550
562
|
|
563
|
+
# @return [String]
|
551
564
|
def desc
|
552
565
|
"[#{inner_desc}]"
|
553
566
|
end
|
@@ -557,6 +570,7 @@ module Solargraph
|
|
557
570
|
"#<#{self.class} `#{self.inner_desc}`#{all_location_text} via #{source.inspect}>"
|
558
571
|
end
|
559
572
|
|
573
|
+
# @return [String]
|
560
574
|
def all_location_text
|
561
575
|
if location.nil? && type_location.nil?
|
562
576
|
''
|
@@ -569,6 +583,7 @@ module Solargraph
|
|
569
583
|
end
|
570
584
|
end
|
571
585
|
|
586
|
+
# @return [void]
|
572
587
|
def reset_generated!
|
573
588
|
end
|
574
589
|
|
@@ -199,9 +199,11 @@ module Solargraph
|
|
199
199
|
)
|
200
200
|
end
|
201
201
|
yield_return_type = ComplexType.try_parse(*yieldreturn_tags.flat_map(&:types))
|
202
|
-
block = Signature.new(generics: generics, parameters: yield_parameters, return_type: yield_return_type, source: source,
|
202
|
+
block = Signature.new(generics: generics, parameters: yield_parameters, return_type: yield_return_type, source: source,
|
203
|
+
closure: self, location: location, type_location: type_location)
|
203
204
|
end
|
204
|
-
signature = Signature.new(generics: generics, parameters: parameters, return_type: return_type, block: block, closure: self, source: source
|
205
|
+
signature = Signature.new(generics: generics, parameters: parameters, return_type: return_type, block: block, closure: self, source: source,
|
206
|
+
location: location, type_location: type_location)
|
205
207
|
block.closure = signature if block
|
206
208
|
signature
|
207
209
|
end
|
@@ -22,12 +22,14 @@ module Solargraph
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
# @param loader [RBS::EnvironmentLoader]
|
25
26
|
def initialize(loader:)
|
26
27
|
@loader = loader
|
27
28
|
@pins = []
|
28
29
|
load_environment_to_pins(loader)
|
29
30
|
end
|
30
31
|
|
32
|
+
# @return [RBS::EnvironmentLoader]
|
31
33
|
attr_reader :loader
|
32
34
|
|
33
35
|
# @return [Array<Pin::Base>]
|
@@ -106,14 +108,14 @@ module Solargraph
|
|
106
108
|
# @param closure [Pin::Namespace]
|
107
109
|
# @return [void]
|
108
110
|
def convert_members_to_pins decl, closure
|
109
|
-
context = Context.new
|
111
|
+
context = Conversions::Context.new
|
110
112
|
decl.members.each { |m| context = convert_member_to_pin(m, closure, context) }
|
111
113
|
end
|
112
114
|
|
113
115
|
# @param member [RBS::AST::Members::Base,RBS::AST::Declarations::Base]
|
114
116
|
# @param closure [Pin::Namespace]
|
115
117
|
# @param context [Context]
|
116
|
-
# @return [
|
118
|
+
# @return [Context]
|
117
119
|
def convert_member_to_pin member, closure, context
|
118
120
|
case member
|
119
121
|
when RBS::AST::Members::MethodDefinition
|
@@ -295,6 +297,7 @@ module Solargraph
|
|
295
297
|
name: name,
|
296
298
|
closure: closure,
|
297
299
|
comments: decl.comment&.string,
|
300
|
+
type_location: location_decl_to_pin_location(decl.location),
|
298
301
|
source: :rbs
|
299
302
|
)
|
300
303
|
rooted_tag = ComplexType.parse(other_type_to_tag(decl.type)).force_rooted.rooted_tags
|
@@ -316,6 +319,7 @@ module Solargraph
|
|
316
319
|
# related overrides
|
317
320
|
# @todo externalize remaining overrides into yaml file, then
|
318
321
|
# allow that to be extended via .solargraph.yml
|
322
|
+
# @type [Hash{Array(String, Symbol, String) => Symbol}
|
319
323
|
VISIBILITY_OVERRIDE = {
|
320
324
|
["Rails::Engine", :instance, "run_tasks_blocks"] => :protected,
|
321
325
|
# Should have been marked as both instance and class method in module -e.g., 'module_function'
|
@@ -340,6 +344,13 @@ module Solargraph
|
|
340
344
|
["Rainbow::Presenter", :instance, "wrap_with_sgr"] => :private,
|
341
345
|
}
|
342
346
|
|
347
|
+
# @param decl [RBS::AST::Members::MethodDefinition, RBS::AST::Members::AttrReader, RBS::AST::Members::AttrAccessor]
|
348
|
+
# @param closure [Pin::Namespace]
|
349
|
+
# @param context [Context]
|
350
|
+
# @param scope [Symbol] :instance or :class
|
351
|
+
# @param name [String] The name of the method
|
352
|
+
# @sg-ignore
|
353
|
+
# @return [Symbol]
|
343
354
|
def calculate_method_visibility(decl, context, closure, scope, name)
|
344
355
|
override_key = [closure.path, scope, name]
|
345
356
|
visibility = VISIBILITY_OVERRIDE[override_key]
|
@@ -414,15 +425,16 @@ module Solargraph
|
|
414
425
|
# @return [void]
|
415
426
|
def method_def_to_sigs decl, pin
|
416
427
|
decl.overloads.map do |overload|
|
428
|
+
type_location = location_decl_to_pin_location(overload.method_type.location)
|
417
429
|
generics = overload.method_type.type_params.map(&:name).map(&:to_s)
|
418
430
|
signature_parameters, signature_return_type = parts_of_function(overload.method_type, pin)
|
419
431
|
block = if overload.method_type.block
|
420
432
|
block_parameters, block_return_type = parts_of_function(overload.method_type.block, pin)
|
421
|
-
Pin::Signature.new(generics: generics, parameters: block_parameters, return_type: block_return_type,
|
422
|
-
|
433
|
+
Pin::Signature.new(generics: generics, parameters: block_parameters, return_type: block_return_type, source: :rbs,
|
434
|
+
type_location: type_location, closure: pin)
|
423
435
|
end
|
424
|
-
Pin::Signature.new(generics: generics, parameters: signature_parameters, return_type: signature_return_type, block: block,
|
425
|
-
|
436
|
+
Pin::Signature.new(generics: generics, parameters: signature_parameters, return_type: signature_return_type, block: block, source: :rbs,
|
437
|
+
type_location: type_location, closure: pin)
|
426
438
|
end
|
427
439
|
end
|
428
440
|
|
@@ -441,44 +453,52 @@ module Solargraph
|
|
441
453
|
# @param pin [Pin::Method]
|
442
454
|
# @return [Array(Array<Pin::Parameter>, ComplexType)]
|
443
455
|
def parts_of_function type, pin
|
444
|
-
|
456
|
+
type_location = pin.type_location
|
457
|
+
if defined?(RBS::Types::UntypedFunction) && type.type.is_a?(RBS::Types::UntypedFunction)
|
458
|
+
return [
|
459
|
+
[Solargraph::Pin::Parameter.new(decl: :restarg, name: 'arg', closure: pin, source: :rbs, type_location: type_location)],
|
460
|
+
ComplexType.try_parse(method_type_to_tag(type)).force_rooted
|
461
|
+
]
|
462
|
+
end
|
445
463
|
|
446
464
|
parameters = []
|
447
465
|
arg_num = -1
|
448
466
|
type.type.required_positionals.each do |param|
|
449
467
|
name = param.name ? param.name.to_s : "arg_#{arg_num += 1}"
|
450
|
-
parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted, source: :rbs)
|
468
|
+
parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted, source: :rbs, type_location: type_location)
|
451
469
|
end
|
452
470
|
type.type.optional_positionals.each do |param|
|
453
471
|
name = param.name ? param.name.to_s : "arg_#{arg_num += 1}"
|
454
472
|
parameters.push Solargraph::Pin::Parameter.new(decl: :optarg, name: name, closure: pin,
|
455
473
|
return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted,
|
474
|
+
type_location: type_location,
|
456
475
|
source: :rbs)
|
457
476
|
end
|
458
477
|
if type.type.rest_positionals
|
459
478
|
name = type.type.rest_positionals.name ? type.type.rest_positionals.name.to_s : "arg_#{arg_num += 1}"
|
460
|
-
parameters.push Solargraph::Pin::Parameter.new(decl: :restarg, name: name, closure: pin, source: :rbs)
|
479
|
+
parameters.push Solargraph::Pin::Parameter.new(decl: :restarg, name: name, closure: pin, source: :rbs, type_location: type_location)
|
461
480
|
end
|
462
481
|
type.type.trailing_positionals.each do |param|
|
463
482
|
name = param.name ? param.name.to_s : "arg_#{arg_num += 1}"
|
464
|
-
parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, source: :rbs)
|
483
|
+
parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, source: :rbs, type_location: type_location)
|
465
484
|
end
|
466
485
|
type.type.required_keywords.each do |orig, param|
|
467
486
|
name = orig ? orig.to_s : "arg_#{arg_num += 1}"
|
468
487
|
parameters.push Solargraph::Pin::Parameter.new(decl: :kwarg, name: name, closure: pin,
|
469
488
|
return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted,
|
470
|
-
source: :rbs)
|
489
|
+
source: :rbs, type_location: type_location)
|
471
490
|
end
|
472
491
|
type.type.optional_keywords.each do |orig, param|
|
473
492
|
name = orig ? orig.to_s : "arg_#{arg_num += 1}"
|
474
493
|
parameters.push Solargraph::Pin::Parameter.new(decl: :kwoptarg, name: name, closure: pin,
|
475
494
|
return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted,
|
495
|
+
type_location: type_location,
|
476
496
|
source: :rbs)
|
477
497
|
end
|
478
498
|
if type.type.rest_keywords
|
479
499
|
name = type.type.rest_keywords.name ? type.type.rest_keywords.name.to_s : "arg_#{arg_num += 1}"
|
480
500
|
parameters.push Solargraph::Pin::Parameter.new(decl: :kwrestarg, name: type.type.rest_keywords.name.to_s, closure: pin,
|
481
|
-
source: :rbs)
|
501
|
+
source: :rbs, type_location: type_location)
|
482
502
|
end
|
483
503
|
|
484
504
|
rooted_tag = method_type_to_tag(type)
|
@@ -488,6 +508,7 @@ module Solargraph
|
|
488
508
|
|
489
509
|
# @param decl [RBS::AST::Members::AttrReader,RBS::AST::Members::AttrAccessor]
|
490
510
|
# @param closure [Pin::Namespace]
|
511
|
+
# @param context [Context]
|
491
512
|
# @return [void]
|
492
513
|
def attr_reader_to_pin(decl, closure, context)
|
493
514
|
name = decl.name.to_s
|
@@ -511,14 +532,16 @@ module Solargraph
|
|
511
532
|
|
512
533
|
# @param decl [RBS::AST::Members::AttrWriter, RBS::AST::Members::AttrAccessor]
|
513
534
|
# @param closure [Pin::Namespace]
|
535
|
+
# @param context [Context]
|
514
536
|
# @return [void]
|
515
537
|
def attr_writer_to_pin(decl, closure, context)
|
516
538
|
final_scope = decl.kind == :instance ? :instance : :class
|
517
539
|
name = "#{decl.name.to_s}="
|
518
540
|
visibility = calculate_method_visibility(decl, context, closure, final_scope, name)
|
541
|
+
type_location = location_decl_to_pin_location(decl.location)
|
519
542
|
pin = Solargraph::Pin::Method.new(
|
520
543
|
name: name,
|
521
|
-
type_location:
|
544
|
+
type_location: type_location,
|
522
545
|
closure: closure,
|
523
546
|
parameters: [],
|
524
547
|
comments: decl.comment&.string,
|
@@ -532,7 +555,8 @@ module Solargraph
|
|
532
555
|
name: 'value',
|
533
556
|
return_type: ComplexType.try_parse(other_type_to_tag(decl.type)).force_rooted,
|
534
557
|
source: :rbs,
|
535
|
-
closure: pin
|
558
|
+
closure: pin,
|
559
|
+
type_location: type_location
|
536
560
|
)
|
537
561
|
rooted_tag = ComplexType.parse(other_type_to_tag(decl.type)).force_rooted.rooted_tags
|
538
562
|
pin.docstring.add_tag(YARD::Tags::Tag.new(:return, '', rooted_tag))
|
@@ -541,6 +565,7 @@ module Solargraph
|
|
541
565
|
|
542
566
|
# @param decl [RBS::AST::Members::AttrAccessor]
|
543
567
|
# @param closure [Pin::Namespace]
|
568
|
+
# @param context [Context]
|
544
569
|
# @return [void]
|
545
570
|
def attr_accessor_to_pin(decl, closure, context)
|
546
571
|
attr_reader_to_pin(decl, closure, context)
|
@@ -572,6 +597,7 @@ module Solargraph
|
|
572
597
|
name: name,
|
573
598
|
closure: closure,
|
574
599
|
comments: decl.comment&.string,
|
600
|
+
type_location: location_decl_to_pin_location(decl.location),
|
575
601
|
source: :rbs
|
576
602
|
)
|
577
603
|
rooted_tag = ComplexType.parse(other_type_to_tag(decl.type)).force_rooted.rooted_tags
|
@@ -588,6 +614,7 @@ module Solargraph
|
|
588
614
|
name: name,
|
589
615
|
closure: closure,
|
590
616
|
comments: decl.comment&.string,
|
617
|
+
type_location: location_decl_to_pin_location(decl.location),
|
591
618
|
source: :rbs
|
592
619
|
)
|
593
620
|
rooted_tag = ComplexType.parse(other_type_to_tag(decl.type)).force_rooted.rooted_tags
|
data/lib/solargraph/version.rb
CHANGED
@@ -151,7 +151,7 @@ module Solargraph
|
|
151
151
|
# @return [Hash{String => Array, Hash, Integer}]
|
152
152
|
def default_config
|
153
153
|
{
|
154
|
-
'include' => ['**/*.rb'],
|
154
|
+
'include' => ['Rakefile', 'Gemfile', '*.gemspec', '**/*.rb'],
|
155
155
|
'exclude' => ['spec/**/*', 'test/**/*', 'vendor/**/*', '.bundle/**/*'],
|
156
156
|
'require' => [],
|
157
157
|
'domains' => [],
|
data/lib/solargraph/workspace.rb
CHANGED
@@ -155,6 +155,14 @@ module Solargraph
|
|
155
155
|
server['commandPath'] || 'solargraph'
|
156
156
|
end
|
157
157
|
|
158
|
+
# True if the workspace has a root Gemfile.
|
159
|
+
#
|
160
|
+
# @todo Handle projects with custom Bundler/Gemfile setups (see DocMap#gemspecs_required_from_bundler)
|
161
|
+
#
|
162
|
+
def gemfile?
|
163
|
+
directory && File.file?(File.join(directory, 'Gemfile'))
|
164
|
+
end
|
165
|
+
|
158
166
|
private
|
159
167
|
|
160
168
|
# The language server configuration (or an empty hash if the workspace was
|
@@ -7,10 +7,38 @@ module Solargraph
|
|
7
7
|
# @param spec [Gem::Specification, nil]
|
8
8
|
# @return [Solargraph::Location, nil]
|
9
9
|
def object_location code_object, spec
|
10
|
-
|
10
|
+
if spec.nil? || code_object.nil? || code_object.file.nil? || code_object.line.nil?
|
11
|
+
if code_object.namespace.is_a?(YARD::CodeObjects::NamespaceObject)
|
12
|
+
# If the code object is a namespace, use the namespace's location
|
13
|
+
return object_location(code_object.namespace, spec)
|
14
|
+
end
|
15
|
+
return Solargraph::Location.new(__FILE__, Solargraph::Range.from_to(__LINE__ - 1, 0, __LINE__ - 1, 0))
|
16
|
+
end
|
11
17
|
file = File.join(spec.full_gem_path, code_object.file)
|
12
18
|
Solargraph::Location.new(file, Solargraph::Range.from_to(code_object.line - 1, 0, code_object.line - 1, 0))
|
13
19
|
end
|
20
|
+
|
21
|
+
# @param code_object [YARD::CodeObjects::Base]
|
22
|
+
# @param spec [Gem::Specification, nil]
|
23
|
+
# @return [Solargraph::Pin::Namespace]
|
24
|
+
def create_closure_namespace_for(code_object, spec)
|
25
|
+
code_object_for_location = code_object
|
26
|
+
# code_object.namespace is sometimes a YARD proxy object pointing to a method path ("Object#new")
|
27
|
+
code_object_for_location = code_object.namespace if code_object.namespace.is_a?(YARD::CodeObjects::NamespaceObject)
|
28
|
+
namespace_location = object_location(code_object_for_location, spec)
|
29
|
+
ns_name = code_object.namespace.to_s
|
30
|
+
if ns_name.empty?
|
31
|
+
Solargraph::Pin::ROOT_PIN
|
32
|
+
else
|
33
|
+
Solargraph::Pin::Namespace.new(
|
34
|
+
name: ns_name,
|
35
|
+
closure: Pin::ROOT_PIN,
|
36
|
+
gates: [code_object.namespace.to_s],
|
37
|
+
source: :yardoc,
|
38
|
+
location: namespace_location
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
14
42
|
end
|
15
43
|
end
|
16
44
|
end
|
@@ -7,12 +7,12 @@ module Solargraph
|
|
7
7
|
extend YardMap::Helpers
|
8
8
|
|
9
9
|
# @param code_object [YARD::CodeObjects::Base]
|
10
|
+
# @param closure [Pin::Closure, nil]
|
11
|
+
# @param spec [Gem::Specification, nil]
|
12
|
+
# @return [Pin::Constant]
|
10
13
|
def self.make code_object, closure = nil, spec = nil
|
11
|
-
closure ||=
|
12
|
-
|
13
|
-
gates: [code_object.namespace.to_s],
|
14
|
-
source: :yardoc,
|
15
|
-
)
|
14
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
15
|
+
|
16
16
|
Pin::Constant.new(
|
17
17
|
location: object_location(code_object, spec),
|
18
18
|
closure: closure,
|
@@ -19,12 +19,7 @@ module Solargraph
|
|
19
19
|
# @param spec [Gem::Specification, nil]
|
20
20
|
# @return [Solargraph::Pin::Method]
|
21
21
|
def self.make code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
22
|
-
closure ||=
|
23
|
-
name: code_object.namespace.to_s,
|
24
|
-
gates: [code_object.namespace.to_s],
|
25
|
-
type: code_object.namespace.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
26
|
-
source: :yardoc,
|
27
|
-
)
|
22
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
28
23
|
location = object_location(code_object, spec)
|
29
24
|
name ||= code_object.name.to_s
|
30
25
|
return_type = ComplexType::SELF if name == 'new'
|
@@ -7,15 +7,15 @@ module Solargraph
|
|
7
7
|
extend YardMap::Helpers
|
8
8
|
|
9
9
|
# @param code_object [YARD::CodeObjects::NamespaceObject]
|
10
|
+
# @param spec [Gem::Specification, nil]
|
11
|
+
# @param closure [Pin::Closure, nil]
|
12
|
+
# @return [Pin::Namespace]
|
10
13
|
def self.make code_object, spec, closure = nil
|
11
|
-
closure ||=
|
12
|
-
|
13
|
-
|
14
|
-
gates: [code_object.namespace.to_s],
|
15
|
-
source: :yardoc,
|
16
|
-
)
|
14
|
+
closure ||= create_closure_namespace_for(code_object, spec)
|
15
|
+
location = object_location(code_object, spec)
|
16
|
+
|
17
17
|
Pin::Namespace.new(
|
18
|
-
location:
|
18
|
+
location: location,
|
19
19
|
name: code_object.name.to_s,
|
20
20
|
comments: code_object.docstring ? code_object.docstring.all.to_s : '',
|
21
21
|
type: code_object.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
data/lib/solargraph/yardoc.rb
CHANGED
data/lib/solargraph.rb
CHANGED
@@ -65,6 +65,10 @@ module Solargraph
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
# @param type [Symbol] The type of assertion to perform.
|
69
|
+
# @param msg [String, nil] An optional message to log
|
70
|
+
# @param block [Proc] A block that returns a message to log
|
71
|
+
# @return [void]
|
68
72
|
def self.assert_or_log(type, msg = nil, &block)
|
69
73
|
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
|
70
74
|
logger.info msg, &block
|
@@ -79,6 +83,11 @@ module Solargraph
|
|
79
83
|
|
80
84
|
# A helper method that runs Bundler.with_unbundled_env or falls back to
|
81
85
|
# Bundler.with_clean_env for earlier versions of Bundler.
|
86
|
+
#
|
87
|
+
# @generic T
|
88
|
+
# @yieldreturn [generic<T>]
|
89
|
+
# @sg-ignore dynamic call, but both functions behave the same
|
90
|
+
# @return [generic<T>]
|
82
91
|
def self.with_clean_env &block
|
83
92
|
meth = if Bundler.respond_to?(:with_original_env)
|
84
93
|
:with_original_env
|
@@ -88,3 +97,7 @@ module Solargraph
|
|
88
97
|
Bundler.send meth, &block
|
89
98
|
end
|
90
99
|
end
|
100
|
+
|
101
|
+
# Ensure that ParserGem node processors are properly loaded to avoid conflicts
|
102
|
+
# with Convention node processors
|
103
|
+
require 'solargraph/parser/parser_gem/node_processors'
|
data/solargraph.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.add_runtime_dependency 'ostruct', '~> 0.6'
|
36
36
|
s.add_runtime_dependency 'parser', '~> 3.0'
|
37
37
|
s.add_runtime_dependency 'prism', '~> 1.4'
|
38
|
-
s.add_runtime_dependency 'rbs', '~> 3.
|
38
|
+
s.add_runtime_dependency 'rbs', '~> 3.6.1'
|
39
39
|
s.add_runtime_dependency 'reverse_markdown', '~> 3.0'
|
40
40
|
s.add_runtime_dependency 'rubocop', '~> 1.38'
|
41
41
|
s.add_runtime_dependency 'thor', '~> 1.0'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.56.
|
4
|
+
version: 0.56.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-07-
|
10
|
+
date: 2025-07-29 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: backport
|
@@ -189,14 +189,14 @@ dependencies:
|
|
189
189
|
requirements:
|
190
190
|
- - "~>"
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version:
|
192
|
+
version: 3.6.1
|
193
193
|
type: :runtime
|
194
194
|
prerelease: false
|
195
195
|
version_requirements: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - "~>"
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version:
|
199
|
+
version: 3.6.1
|
200
200
|
- !ruby/object:Gem::Dependency
|
201
201
|
name: reverse_markdown
|
202
202
|
requirement: !ruby/object:Gem::Requirement
|
@@ -419,6 +419,9 @@ files:
|
|
419
419
|
- lib/solargraph/complex_type/unique_type.rb
|
420
420
|
- lib/solargraph/convention.rb
|
421
421
|
- lib/solargraph/convention/base.rb
|
422
|
+
- lib/solargraph/convention/data_definition.rb
|
423
|
+
- lib/solargraph/convention/data_definition/data_assignment_node.rb
|
424
|
+
- lib/solargraph/convention/data_definition/data_definition_node.rb
|
422
425
|
- lib/solargraph/convention/gemfile.rb
|
423
426
|
- lib/solargraph/convention/gemspec.rb
|
424
427
|
- lib/solargraph/convention/rakefile.rb
|