solargraph 0.51.2 → 0.52.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/.yardopts +2 -2
- data/CHANGELOG.md +25 -5
- data/lib/solargraph/api_map/cache.rb +2 -0
- data/lib/solargraph/api_map/store.rb +2 -2
- data/lib/solargraph/api_map.rb +11 -4
- data/lib/solargraph/complex_type/type_methods.rb +1 -1
- data/lib/solargraph/complex_type/unique_type.rb +20 -13
- data/lib/solargraph/complex_type.rb +13 -9
- data/lib/solargraph/documentor.rb +1 -1
- data/lib/solargraph/library.rb +12 -5
- data/lib/solargraph/parser/comment_ripper.rb +1 -0
- data/lib/solargraph/parser/legacy/class_methods.rb +2 -2
- data/lib/solargraph/parser/legacy/node_chainer.rb +9 -4
- data/lib/solargraph/parser/legacy/node_methods.rb +5 -3
- data/lib/solargraph/parser/node_methods.rb +1 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser/rubyvm/class_methods.rb +1 -3
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +5 -2
- data/lib/solargraph/parser.rb +2 -0
- data/lib/solargraph/pin/base.rb +1 -1
- data/lib/solargraph/pin/block.rb +2 -2
- data/lib/solargraph/pin/delegated_method.rb +1 -1
- data/lib/solargraph/pin/method.rb +62 -5
- data/lib/solargraph/pin/namespace.rb +10 -3
- data/lib/solargraph/pin/parameter.rb +9 -10
- data/lib/solargraph/pin/signature.rb +9 -1
- data/lib/solargraph/rbs_map/conversions.rb +86 -31
- data/lib/solargraph/rbs_map/core_fills.rb +9 -10
- data/lib/solargraph/rbs_map/core_map.rb +1 -1
- data/lib/solargraph/rbs_map.rb +2 -3
- data/lib/solargraph/source/chain/array.rb +29 -0
- data/lib/solargraph/source/chain/call.rb +14 -30
- data/lib/solargraph/source/chain/link.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +1 -1
- data/lib/solargraph/source/chain.rb +9 -10
- data/lib/solargraph/source/source_chainer.rb +2 -0
- data/lib/solargraph/source.rb +3 -3
- data/lib/solargraph/source_map/clip.rb +0 -16
- data/lib/solargraph/source_map/mapper.rb +2 -1
- data/lib/solargraph/source_map.rb +2 -2
- data/lib/solargraph/type_checker.rb +18 -7
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace.rb +2 -1
- data/lib/solargraph/yard_map/mapper.rb +1 -1
- data/lib/solargraph/yard_map.rb +6 -5
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph.rb +2 -3
- data/solargraph.gemspec +1 -0
- metadata +18 -3
- data/lib/yard-solargraph.rb +0 -33
@@ -107,7 +107,8 @@ module Solargraph
|
|
107
107
|
begin
|
108
108
|
src = Solargraph::Source.load_string("def #{directive.tag.name};end", @source.filename)
|
109
109
|
region = Parser::Region.new(source: src, closure: namespace)
|
110
|
-
|
110
|
+
method_gen_pins = Parser.process_node(src.node, region).first.select { |pin| pin.is_a?(Pin::Method) }
|
111
|
+
gen_pin = method_gen_pins.last
|
111
112
|
return if gen_pin.nil?
|
112
113
|
# Move the location to the end of the line so it gets recognized
|
113
114
|
# as originating from a comment
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yard'
|
4
|
-
require '
|
4
|
+
require 'solargraph/yard_tags'
|
5
5
|
require 'set'
|
6
6
|
|
7
7
|
module Solargraph
|
@@ -41,7 +41,7 @@ module Solargraph
|
|
41
41
|
|
42
42
|
def rebindable_method_names
|
43
43
|
@rebindable_method_names ||= pins_by_class(Pin::Method)
|
44
|
-
.select { |pin| pin.comments && pin.comments.include?('@
|
44
|
+
.select { |pin| pin.comments && pin.comments.include?('@yieldreceiver') }
|
45
45
|
.map(&:name)
|
46
46
|
.to_set
|
47
47
|
end
|
@@ -22,7 +22,7 @@ module Solargraph
|
|
22
22
|
attr_reader :api_map
|
23
23
|
|
24
24
|
# @param filename [String]
|
25
|
-
# @param api_map [ApiMap]
|
25
|
+
# @param api_map [ApiMap, nil]
|
26
26
|
# @param level [Symbol]
|
27
27
|
def initialize filename, api_map: nil, level: :normal
|
28
28
|
@filename = filename
|
@@ -91,7 +91,12 @@ module Solargraph
|
|
91
91
|
declared = pin.typify(api_map).self_to(pin.full_context.namespace)
|
92
92
|
if declared.undefined?
|
93
93
|
if pin.return_type.undefined? && rules.require_type_tags?
|
94
|
-
|
94
|
+
if pin.attribute?
|
95
|
+
inferred = pin.probe(api_map).self_to(pin.full_context.namespace)
|
96
|
+
result.push Problem.new(pin.location, "Missing @return tag for #{pin.path}", pin: pin) unless inferred.defined?
|
97
|
+
else
|
98
|
+
result.push Problem.new(pin.location, "Missing @return tag for #{pin.path}", pin: pin)
|
99
|
+
end
|
95
100
|
elsif pin.return_type.defined? && !resolved_constant?(pin)
|
96
101
|
result.push Problem.new(pin.location, "Unresolved return type #{pin.return_type} for #{pin.path}", pin: pin)
|
97
102
|
elsif rules.must_tag_or_infer? && pin.probe(api_map).undefined?
|
@@ -141,7 +146,14 @@ module Solargraph
|
|
141
146
|
sig.parameters.each do |par|
|
142
147
|
break if par.decl == :restarg || par.decl == :kwrestarg || par.decl == :blockarg
|
143
148
|
unless params[par.name]
|
144
|
-
|
149
|
+
if pin.attribute?
|
150
|
+
inferred = pin.probe(api_map).self_to(pin.full_context.namespace)
|
151
|
+
if inferred.undefined?
|
152
|
+
result.push Problem.new(pin.location, "Missing @param tag for #{par.name} on #{pin.path}", pin: pin)
|
153
|
+
end
|
154
|
+
else
|
155
|
+
result.push Problem.new(pin.location, "Missing @param tag for #{par.name} on #{pin.path}", pin: pin)
|
156
|
+
end
|
145
157
|
end
|
146
158
|
end
|
147
159
|
end
|
@@ -243,7 +255,7 @@ module Solargraph
|
|
243
255
|
end
|
244
256
|
closest = found.typify(api_map) if found
|
245
257
|
if !found || found.is_a?(Pin::BaseVariable) || (closest.defined? && internal_or_core?(found))
|
246
|
-
unless closest.
|
258
|
+
unless closest.generic? || ignored_pins.include?(found)
|
247
259
|
result.push Problem.new(location, "Unresolved call to #{missing.links.last.word}")
|
248
260
|
@marked_ranges.push rng
|
249
261
|
end
|
@@ -279,7 +291,8 @@ module Solargraph
|
|
279
291
|
result.concat ap
|
280
292
|
break
|
281
293
|
end
|
282
|
-
break
|
294
|
+
break if !rules.validate_calls? || base.links.first.is_a?(Solargraph::Source::Chain::ZSuper)
|
295
|
+
|
283
296
|
params = first_param_hash(pins)
|
284
297
|
|
285
298
|
all_errors = []
|
@@ -455,8 +468,6 @@ module Solargraph
|
|
455
468
|
return [] if parameters.empty? && arguments.empty?
|
456
469
|
return [] if pin.anon_splat?
|
457
470
|
if parameters.empty?
|
458
|
-
# Functions tagged param_tuple accepts two arguments (e.g., Hash#[]=)
|
459
|
-
return [] if pin.docstring.tag(:param_tuple) && arguments.length == 2
|
460
471
|
return [] if arguments.length == 1 && arguments.last.links.last.is_a?(Source::Chain::BlockVariable)
|
461
472
|
return [Problem.new(location, "Too many arguments to #{pin.path}")]
|
462
473
|
end
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/workspace.rb
CHANGED
@@ -104,7 +104,8 @@ module Solargraph
|
|
104
104
|
# @return [Boolean]
|
105
105
|
def would_require? path
|
106
106
|
require_paths.each do |rp|
|
107
|
-
|
107
|
+
full = File.join rp, path
|
108
|
+
return true if File.exist?(full) or File.exist?(full << ".rb")
|
108
109
|
end
|
109
110
|
false
|
110
111
|
end
|
@@ -8,7 +8,7 @@ module Solargraph
|
|
8
8
|
autoload :ToConstant, 'solargraph/yard_map/mapper/to_constant'
|
9
9
|
|
10
10
|
# @param code_objects [Array<YARD::CodeObjects::Base>]
|
11
|
-
# @param spec [Gem::Specification]
|
11
|
+
# @param spec [Gem::Specification, nil]
|
12
12
|
def initialize code_objects, spec = nil
|
13
13
|
@code_objects = code_objects
|
14
14
|
@spec = spec
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yard'
|
4
|
-
require '
|
4
|
+
require 'solargraph/yard_tags'
|
5
5
|
require 'rubygems/package'
|
6
6
|
require 'set'
|
7
7
|
|
@@ -66,7 +66,7 @@ module Solargraph
|
|
66
66
|
# @return [Set<String>]
|
67
67
|
def rebindable_method_names
|
68
68
|
@rebindable_method_names ||= pins_by_class(Pin::Method)
|
69
|
-
.select { |pin| pin.comments && pin.comments.include?('@
|
69
|
+
.select { |pin| pin.comments && pin.comments.include?('@yieldreceiver') }
|
70
70
|
.map(&:name)
|
71
71
|
.concat(['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec', 'define_method'])
|
72
72
|
.to_set
|
@@ -120,8 +120,9 @@ module Solargraph
|
|
120
120
|
# @type [Gem::Specification]
|
121
121
|
spec = spec_for_require(path)
|
122
122
|
spec.full_require_paths.each do |rp|
|
123
|
-
file = File.join(rp,
|
124
|
-
|
123
|
+
file = File.join(rp, path)
|
124
|
+
file = [file, file + ".rb"].find { |file| File.file?(file) }
|
125
|
+
next unless file
|
125
126
|
return Solargraph::Location.new(file, Solargraph::Range.from_to(0, 0, 0, 0))
|
126
127
|
end
|
127
128
|
nil
|
@@ -144,7 +145,7 @@ module Solargraph
|
|
144
145
|
@cache ||= YardMap::Cache.new
|
145
146
|
end
|
146
147
|
|
147
|
-
# @return [Hash]
|
148
|
+
# @return [Hash{Class<Pin::Base> => Array<Pin::Base>}]
|
148
149
|
def pin_class_hash
|
149
150
|
@pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a)
|
150
151
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
# Change YARD log IO to avoid sending unexpected messages to STDOUT
|
6
|
+
YARD::Logger.instance.io = File.new(File::NULL, 'w')
|
7
|
+
|
8
|
+
module Solargraph
|
9
|
+
# A placeholder for the @!domain directive. It doesn't need to do anything
|
10
|
+
# for yardocs. It's only used for Solargraph API maps.
|
11
|
+
class DomainDirective < YARD::Tags::Directive
|
12
|
+
def call; end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Define a @type tag for documenting variables
|
17
|
+
YARD::Tags::Library.define_tag("Type", :type, :with_types_and_name)
|
18
|
+
|
19
|
+
# Define an @!override directive for overriding method tags
|
20
|
+
YARD::Tags::Library.define_directive("override", :with_name, Solargraph::DomainDirective)
|
data/lib/solargraph.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Encoding.default_external = 'UTF-8'
|
4
4
|
|
5
|
+
require 'yard-solargraph'
|
6
|
+
require 'solargraph/yard_tags'
|
5
7
|
require 'solargraph/version'
|
6
8
|
|
7
9
|
# The top-level namespace for the Solargraph code mapping, documentation,
|
@@ -44,7 +46,6 @@ module Solargraph
|
|
44
46
|
autoload :Cache, 'solargraph/cache'
|
45
47
|
|
46
48
|
dir = File.dirname(__FILE__)
|
47
|
-
YARD_EXTENSION_FILE = File.join(dir, 'yard-solargraph.rb')
|
48
49
|
VIEWS_PATH = File.join(dir, 'solargraph', 'views')
|
49
50
|
|
50
51
|
# A convenience method for Solargraph::Logging.logger.
|
@@ -56,8 +57,6 @@ module Solargraph
|
|
56
57
|
|
57
58
|
# A helper method that runs Bundler.with_unbundled_env or falls back to
|
58
59
|
# Bundler.with_clean_env for earlier versions of Bundler.
|
59
|
-
#
|
60
|
-
# @return [void]
|
61
60
|
def self.with_clean_env &block
|
62
61
|
meth = if Bundler.respond_to?(:with_original_env)
|
63
62
|
:with_original_env
|
data/solargraph.gemspec
CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.add_runtime_dependency 'thor', '~> 1.0'
|
41
41
|
s.add_runtime_dependency 'tilt', '~> 2.0'
|
42
42
|
s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24'
|
43
|
+
s.add_runtime_dependency 'yard-solargraph', '~> 0.1'
|
43
44
|
|
44
45
|
s.add_development_dependency 'pry'
|
45
46
|
s.add_development_dependency 'public_suffix', '~> 3.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.52.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -260,6 +260,20 @@ dependencies:
|
|
260
260
|
- - ">="
|
261
261
|
- !ruby/object:Gem::Version
|
262
262
|
version: 0.9.24
|
263
|
+
- !ruby/object:Gem::Dependency
|
264
|
+
name: yard-solargraph
|
265
|
+
requirement: !ruby/object:Gem::Requirement
|
266
|
+
requirements:
|
267
|
+
- - "~>"
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: '0.1'
|
270
|
+
type: :runtime
|
271
|
+
prerelease: false
|
272
|
+
version_requirements: !ruby/object:Gem::Requirement
|
273
|
+
requirements:
|
274
|
+
- - "~>"
|
275
|
+
- !ruby/object:Gem::Version
|
276
|
+
version: '0.1'
|
263
277
|
- !ruby/object:Gem::Dependency
|
264
278
|
name: pry
|
265
279
|
requirement: !ruby/object:Gem::Requirement
|
@@ -575,6 +589,7 @@ files:
|
|
575
589
|
- lib/solargraph/shell.rb
|
576
590
|
- lib/solargraph/source.rb
|
577
591
|
- lib/solargraph/source/chain.rb
|
592
|
+
- lib/solargraph/source/chain/array.rb
|
578
593
|
- lib/solargraph/source/chain/block_variable.rb
|
579
594
|
- lib/solargraph/source/chain/call.rb
|
580
595
|
- lib/solargraph/source/chain/class_variable.rb
|
@@ -621,7 +636,7 @@ files:
|
|
621
636
|
- lib/solargraph/yard_map/mapper/to_method.rb
|
622
637
|
- lib/solargraph/yard_map/mapper/to_namespace.rb
|
623
638
|
- lib/solargraph/yard_map/to_method.rb
|
624
|
-
- lib/
|
639
|
+
- lib/solargraph/yard_tags.rb
|
625
640
|
- solargraph.gemspec
|
626
641
|
homepage: https://solargraph.org
|
627
642
|
licenses:
|
data/lib/yard-solargraph.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yard'
|
4
|
-
|
5
|
-
# Change YARD log IO to avoid sending unexpected messages to STDOUT
|
6
|
-
YARD::Logger.instance.io = File.new(File::NULL, 'w')
|
7
|
-
|
8
|
-
module Solargraph
|
9
|
-
# A placeholder for the @!domain directive. It doesn't need to do anything
|
10
|
-
# for yardocs. It's only used for Solargraph API maps.
|
11
|
-
class DomainDirective < YARD::Tags::Directive
|
12
|
-
def call; end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Define a @type tag for documenting variables
|
17
|
-
YARD::Tags::Library.define_tag("Type", :type, :with_types_and_name)
|
18
|
-
# Define a @yieldself tag for documenting block contexts
|
19
|
-
YARD::Tags::Library.define_tag("Yieldself", :yieldself, :with_types)
|
20
|
-
# Define a @yieldpublic tag for documenting block domains
|
21
|
-
YARD::Tags::Library.define_tag("Yieldpublic", :yieldpublic, :with_types)
|
22
|
-
# Define a @return_single_parameter tag for returning e.g. Array parameters
|
23
|
-
YARD::Tags::Library.define_tag('ReturnSingleParameter', :return_single_parameter)
|
24
|
-
# Define a @yieldparam_single_parameter tag for yielding e.g. Array parameters
|
25
|
-
YARD::Tags::Library.define_tag('YieldparamSingleParameter', :yieldparam_single_parameter)
|
26
|
-
# Define a @return_value_parameter tag for returning e.g. Hash values
|
27
|
-
YARD::Tags::Library.define_tag('ReturnValueParameter', :return_value_parameter)
|
28
|
-
# Define a @param_tuple tag for e.g. Hash#[]= parameters
|
29
|
-
YARD::Tags::Library.define_tag('ParamTuple', :param_tuple)
|
30
|
-
# Define a @!domain directive for documenting DSLs
|
31
|
-
YARD::Tags::Library.define_directive("domain", :with_types, Solargraph::DomainDirective)
|
32
|
-
# Define an @!override directive for overriding method tags
|
33
|
-
YARD::Tags::Library.define_directive("override", :with_name, Solargraph::DomainDirective)
|