solargraph 0.60.4 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/plugins.yml +1 -1
- data/.github/workflows/rspec.yml +3 -1
- data/CHANGELOG.md +16 -0
- data/Gemfile +0 -3
- data/lib/solargraph/api_map/index.rb +15 -2
- data/lib/solargraph/api_map/store.rb +13 -0
- data/lib/solargraph/api_map.rb +60 -81
- data/lib/solargraph/cache_dir.rb +58 -0
- data/lib/solargraph/collection/base.rb +50 -0
- data/lib/solargraph/collection/core.rb +17 -0
- data/lib/solargraph/collection/gem.rb +57 -0
- data/lib/solargraph/collection/rbs.rb +49 -0
- data/lib/solargraph/collection/stdlib.rb +25 -0
- data/lib/solargraph/collection.rb +31 -0
- data/lib/solargraph/convention.rb +5 -3
- data/lib/solargraph/diagnostics/require_not_found.rb +0 -4
- data/lib/solargraph/external.rb +159 -0
- data/lib/solargraph/language_server/message/text_document/definition.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -2
- data/lib/solargraph/library.rb +11 -24
- data/lib/solargraph/metagem.rb +80 -0
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +22 -3
- data/lib/solargraph/pin/closure.rb +17 -0
- data/lib/solargraph/pin/factory_parameter.rb +84 -0
- data/lib/solargraph/pin.rb +1 -0
- data/lib/solargraph/rbs_map/base.rb +31 -0
- data/lib/solargraph/rbs_map/conversions.rb +3 -1
- data/lib/solargraph/rbs_map/{core_map.rb → core.rb} +18 -39
- data/lib/solargraph/rbs_map/core_fills.rb +1 -1
- data/lib/solargraph/rbs_map/gem.rb +13 -0
- data/lib/solargraph/rbs_map/helpers.rb +60 -0
- data/lib/solargraph/rbs_map/path.rb +19 -0
- data/lib/solargraph/rbs_map/stdlib.rb +24 -0
- data/lib/solargraph/rbs_map.rb +7 -198
- data/lib/solargraph/repo.rb +177 -0
- data/lib/solargraph/shell.rb +49 -99
- data/lib/solargraph/source/chain/call.rb +29 -4
- data/lib/solargraph/source/chain/literal.rb +17 -17
- data/lib/solargraph/source/chain/parameter.rb +79 -0
- data/lib/solargraph/source/chain.rb +8 -0
- data/lib/solargraph/source/source_chainer.rb +40 -44
- data/lib/solargraph/source_map/clip.rb +5 -3
- data/lib/solargraph/source_map/mapper.rb +6 -2
- data/lib/solargraph/source_map.rb +10 -5
- data/lib/solargraph/type_checker/rules.rb +2 -1
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace.rb +0 -1
- data/lib/solargraph/yard_map/cache.rb +1 -1
- data/lib/solargraph/yard_map/directives/attribute_directive.rb +1 -1
- data/lib/solargraph/yard_map/directives/domain_directive.rb +1 -1
- data/lib/solargraph/yard_map/directives/method_directive.rb +1 -1
- data/lib/solargraph/yard_map/directives/override_directive.rb +1 -1
- data/lib/solargraph/yard_map/directives/parse_directive.rb +1 -1
- data/lib/solargraph/yard_map/directives/scope_directive.rb +178 -0
- data/lib/solargraph/yard_map/directives/visibility_directive.rb +1 -1
- data/lib/solargraph/yard_map/directives.rb +5 -2
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/macro.rb +34 -5
- data/lib/solargraph/yard_map/mapper/to_constant.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +1 -1
- data/lib/solargraph/yard_map/mapper.rb +2 -2
- data/lib/solargraph/yard_map.rb +1 -1
- data/lib/solargraph/yardoc.rb +43 -60
- data/lib/solargraph.rb +6 -3
- data/solargraph.gemspec +1 -1
- metadata +22 -9
- data/lib/solargraph/doc_map.rb +0 -439
- data/lib/solargraph/gem_pins.rb +0 -87
- data/lib/solargraph/pin_cache.rb +0 -248
- data/lib/solargraph/rbs_map/stdlib_map.rb +0 -71
- data/lib/solargraph/workspace/gemspecs.rb +0 -373
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
module YardMap
|
|
5
|
+
module Directives
|
|
6
|
+
# Implements YARD's @!scope directive.
|
|
7
|
+
#
|
|
8
|
+
# As described in YARD::Tags::ScopeDirective, a @!scope directive that
|
|
9
|
+
# appears in a docstring attached to a method definition applies only to
|
|
10
|
+
# that method. Anywhere else it applies to all of the methods that follow
|
|
11
|
+
# it within the namespace it was defined in.
|
|
12
|
+
#
|
|
13
|
+
# class Example
|
|
14
|
+
# # @!scope class
|
|
15
|
+
# def foo; end # => Example.foo
|
|
16
|
+
#
|
|
17
|
+
# def bar; end # => Example#bar
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# class Other
|
|
21
|
+
# # @!scope class
|
|
22
|
+
#
|
|
23
|
+
# def foo; end # => Other.foo
|
|
24
|
+
#
|
|
25
|
+
# def bar; end # => Other.bar
|
|
26
|
+
# end
|
|
27
|
+
#
|
|
28
|
+
module ScopeDirective
|
|
29
|
+
module_function
|
|
30
|
+
|
|
31
|
+
VALID_SCOPES = %i[class instance].freeze
|
|
32
|
+
|
|
33
|
+
# Directives that define an object whose scope is inherited from a
|
|
34
|
+
# @!scope directive. @!parse is not one of them because the code it
|
|
35
|
+
# contains already declares the scope of everything it defines.
|
|
36
|
+
SCOPED_DIRECTIVES = %w[method attribute].freeze
|
|
37
|
+
|
|
38
|
+
# @param source [Solargraph::Source]
|
|
39
|
+
# @param pins [Array<Solargraph::Pin::Base>]
|
|
40
|
+
# @param source_position [Position]
|
|
41
|
+
# @param comment_position [Position]
|
|
42
|
+
# @param directive [YARD::Tags::Directive]
|
|
43
|
+
# @return [Array<Solargraph::Pin::Base>]
|
|
44
|
+
def process_directive source, pins, source_position, comment_position, directive
|
|
45
|
+
kind = parse_scope directive
|
|
46
|
+
return [] if kind.nil?
|
|
47
|
+
|
|
48
|
+
attached = attached_method pins, source_position
|
|
49
|
+
if attached && no_empty_lines?(source.code, comment_position.line, source_position.line)
|
|
50
|
+
attached.scope = kind
|
|
51
|
+
else
|
|
52
|
+
apply_to_namespace pins, kind, source_position
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
[]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @param directive [YARD::Tags::Directive]
|
|
59
|
+
# @return [::Symbol, nil] :class, :instance, or nil if the directive is malformed
|
|
60
|
+
def parse_scope directive
|
|
61
|
+
kind = directive.tag.text.to_s.strip.downcase.to_sym
|
|
62
|
+
VALID_SCOPES.include?(kind) ? kind : nil
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# True if the scope of the object defined by this directive can be set
|
|
66
|
+
# by a @!scope directive.
|
|
67
|
+
#
|
|
68
|
+
# @param directive [YARD::Tags::Directive]
|
|
69
|
+
# @return [Boolean]
|
|
70
|
+
def scopes_directive? directive
|
|
71
|
+
SCOPED_DIRECTIVES.include? directive.tag.tag_name
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# The scope set by a @!scope directive that appears in the indented
|
|
75
|
+
# text of another directive:
|
|
76
|
+
#
|
|
77
|
+
# @!method foo
|
|
78
|
+
# @!scope class
|
|
79
|
+
#
|
|
80
|
+
# YARD parses the indented text of a directive with a state of its own,
|
|
81
|
+
# so a directive nested this way applies only to the object the
|
|
82
|
+
# enclosing directive defines. It never affects the objects that
|
|
83
|
+
# follow.
|
|
84
|
+
#
|
|
85
|
+
# @param directive [YARD::Tags::Directive]
|
|
86
|
+
# @return [::Symbol, nil] :class, :instance, or nil if there is none
|
|
87
|
+
def nested_scope directive
|
|
88
|
+
text = directive.tag.text.to_s
|
|
89
|
+
return nil unless text.include? '@!scope'
|
|
90
|
+
|
|
91
|
+
kind = nil
|
|
92
|
+
Solargraph::Source.parse_docstring(text).directives.each do |nested|
|
|
93
|
+
next unless nested.tag.tag_name == 'scope'
|
|
94
|
+
|
|
95
|
+
# A later directive overrides an earlier one, but an invalid value
|
|
96
|
+
# leaves the current one in place, as it does in YARD.
|
|
97
|
+
kind = parse_scope(nested) || kind
|
|
98
|
+
end
|
|
99
|
+
kind
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Set the scope of pins generated by a directive.
|
|
103
|
+
#
|
|
104
|
+
# @param pins [Array<Solargraph::Pin::Base>]
|
|
105
|
+
# @param kind [::Symbol, nil] :class or :instance; nothing happens if nil
|
|
106
|
+
# @return [void]
|
|
107
|
+
def apply_scope pins, kind
|
|
108
|
+
return if kind.nil?
|
|
109
|
+
|
|
110
|
+
# Only methods have a scope. Applying one to any other kind of pin,
|
|
111
|
+
# such as a namespace generated by @!parse, would corrupt its path.
|
|
112
|
+
pins.each { |pin| pin.scope = kind if pin.is_a?(Pin::Method) }
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Apply a @!scope directive from the indented text of another directive
|
|
116
|
+
# to the pins that directive generated.
|
|
117
|
+
#
|
|
118
|
+
# @param directive [YARD::Tags::Directive]
|
|
119
|
+
# @param pins [Array<Solargraph::Pin::Base>] the pins generated by the directive
|
|
120
|
+
# @return [void]
|
|
121
|
+
def apply_nested directive, pins
|
|
122
|
+
return unless scopes_directive? directive
|
|
123
|
+
|
|
124
|
+
apply_scope pins, nested_scope(directive)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Applies the scope to each method that follows the directive within
|
|
128
|
+
# the namespace the directive appears in. Methods in nested namespaces
|
|
129
|
+
# are excluded, since the directive only affects its own namespace.
|
|
130
|
+
#
|
|
131
|
+
# @param pins [Array<Solargraph::Pin::Base>]
|
|
132
|
+
# @param kind [::Symbol] :class or :instance
|
|
133
|
+
# @param source_position [Position]
|
|
134
|
+
# @return [void]
|
|
135
|
+
def apply_to_namespace pins, kind, source_position
|
|
136
|
+
namespace = namespace_at pins, source_position
|
|
137
|
+
return if namespace.nil?
|
|
138
|
+
|
|
139
|
+
pins.each do |pin|
|
|
140
|
+
next unless pin.is_a?(Pin::Method)
|
|
141
|
+
next unless pin.namespace == namespace.path
|
|
142
|
+
# @sg-ignore flow sensitive typing should narrow location after the nil check
|
|
143
|
+
next if pin.location.nil? || pin.location.range.start.line < source_position.line
|
|
144
|
+
|
|
145
|
+
pin.scope = kind
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# The method defined on the line the comment is attached to, if any.
|
|
150
|
+
#
|
|
151
|
+
# @param pins [Array<Solargraph::Pin::Base>]
|
|
152
|
+
# @param source_position [Position]
|
|
153
|
+
# @return [Pin::Method, nil]
|
|
154
|
+
def attached_method pins, source_position
|
|
155
|
+
pins.select { |pin| pin.is_a?(Pin::Method) && pin.location&.range&.contain?(source_position) }.last
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# @param pins [Array<Solargraph::Pin::Base>]
|
|
159
|
+
# @param position [Position]
|
|
160
|
+
# @return [Pin::Namespace, nil]
|
|
161
|
+
def namespace_at pins, position
|
|
162
|
+
pins.select { |pin| pin.is_a?(Pin::Namespace) && pin.location&.range&.contain?(position) }.last
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# @param code [String]
|
|
166
|
+
# @param line1 [Integer]
|
|
167
|
+
# @param line2 [Integer]
|
|
168
|
+
# @return [Boolean]
|
|
169
|
+
def no_empty_lines? code, line1, line2
|
|
170
|
+
lines = code.lines[line1..line2]
|
|
171
|
+
return false if lines.nil?
|
|
172
|
+
|
|
173
|
+
lines.none? { |line| line.strip.empty? }
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Solargraph
|
|
4
|
-
|
|
4
|
+
module YardMap
|
|
5
5
|
module Directives
|
|
6
6
|
autoload :AttributeDirective, 'solargraph/yard_map/directives/attribute_directive'
|
|
7
7
|
autoload :MethodDirective, 'solargraph/yard_map/directives/method_directive'
|
|
8
8
|
autoload :DomainDirective, 'solargraph/yard_map/directives/domain_directive'
|
|
9
9
|
autoload :OverrideDirective, 'solargraph/yard_map/directives/override_directive'
|
|
10
10
|
autoload :ParseDirective, 'solargraph/yard_map/directives/parse_directive'
|
|
11
|
+
autoload :ScopeDirective, 'solargraph/yard_map/directives/scope_directive'
|
|
11
12
|
autoload :VisibilityDirective, 'solargraph/yard_map/directives/visibility_directive'
|
|
12
13
|
|
|
13
14
|
# @param directive [YARD::Tags::Directive]
|
|
14
|
-
# @return [Class<AttributeDirective>, Class<MethodDirective>, Class<DomainDirective>, Class<OverrideDirective>, Class<ParseDirective>, Class<VisibilityDirective>, nil]
|
|
15
|
+
# @return [Class<AttributeDirective>, Class<MethodDirective>, Class<DomainDirective>, Class<OverrideDirective>, Class<ParseDirective>, Class<ScopeDirective>, Class<VisibilityDirective>, nil]
|
|
15
16
|
def self.for directive
|
|
16
17
|
case directive.tag.tag_name
|
|
17
18
|
when 'attribute'
|
|
@@ -24,6 +25,8 @@ module Solargraph
|
|
|
24
25
|
OverrideDirective
|
|
25
26
|
when 'parse'
|
|
26
27
|
ParseDirective
|
|
28
|
+
when 'scope'
|
|
29
|
+
ScopeDirective
|
|
27
30
|
when 'visibility'
|
|
28
31
|
VisibilityDirective
|
|
29
32
|
else # rubocop:disable Style/EmptyElse
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Solargraph
|
|
4
|
-
|
|
4
|
+
module YardMap
|
|
5
5
|
class Macro
|
|
6
|
-
PROCESSABLE_DIRECTIVES = %w[method attribute parse].freeze
|
|
6
|
+
PROCESSABLE_DIRECTIVES = %w[method attribute parse scope].freeze
|
|
7
|
+
|
|
8
|
+
# Directives whose text is a value rather than a definition. The comments
|
|
9
|
+
# attached to the macro's call site belong to the objects the macro
|
|
10
|
+
# generates, but adding them to one of these directives would invalidate
|
|
11
|
+
# its content.
|
|
12
|
+
VALUE_DIRECTIVES = %w[parse scope].freeze
|
|
7
13
|
|
|
8
14
|
class << self
|
|
9
15
|
# @param directive [YARD::Tags::Directive]
|
|
@@ -73,13 +79,34 @@ module Solargraph
|
|
|
73
79
|
# @return [Array<Pin::Base>]
|
|
74
80
|
def generate_pins_from chain, pin, source_map
|
|
75
81
|
call_location = Solargraph::Location.from_node(chain.node)
|
|
82
|
+
return [] unless call_location
|
|
83
|
+
|
|
84
|
+
# A @!scope directive in a macro applies to the objects the macro
|
|
85
|
+
# generates after it, the same way it applies to the objects that
|
|
86
|
+
# follow it in a namespace. Its effect ends with the macro.
|
|
87
|
+
#
|
|
88
|
+
# @type [::Symbol, nil]
|
|
89
|
+
inherited_scope = nil
|
|
90
|
+
|
|
76
91
|
# @param generated_pins [Array<Pin::Base>]
|
|
77
92
|
generate_yardoc_from(chain, source_map).reduce([]) do |generated_pins, directive|
|
|
93
|
+
# @sg-ignore flow sensitive typing confuses this block variable with the #directive attr reader
|
|
94
|
+
if directive.tag.tag_name == 'scope'
|
|
95
|
+
inherited_scope = Directives::ScopeDirective.parse_scope(directive) || inherited_scope
|
|
96
|
+
next generated_pins
|
|
97
|
+
end
|
|
78
98
|
directive_processor = YardMap::Directives.for(directive)
|
|
79
|
-
next generated_pins unless directive_processor
|
|
80
|
-
|
|
99
|
+
next generated_pins unless directive_processor
|
|
100
|
+
new_pins = directive_processor.process_directive(
|
|
81
101
|
source_map.source, source_map.pins, call_location.range.start, call_location.range.start, directive
|
|
82
102
|
)
|
|
103
|
+
if Directives::ScopeDirective.scopes_directive?(directive)
|
|
104
|
+
# A @!scope directive nested in another directive's text applies
|
|
105
|
+
# only to the object that directive defines.
|
|
106
|
+
scope = Directives::ScopeDirective.nested_scope(directive) || inherited_scope
|
|
107
|
+
Directives::ScopeDirective.apply_scope new_pins, scope
|
|
108
|
+
end
|
|
109
|
+
generated_pins + new_pins
|
|
83
110
|
end
|
|
84
111
|
end
|
|
85
112
|
|
|
@@ -100,9 +127,11 @@ module Solargraph
|
|
|
100
127
|
PROCESSABLE_DIRECTIVES.include?(directive.tag.tag_name)
|
|
101
128
|
end
|
|
102
129
|
directives.each do |directive|
|
|
130
|
+
next if VALUE_DIRECTIVES.include? directive.tag.tag_name
|
|
131
|
+
|
|
103
132
|
# @sg-ignore chain.node is assumed to exist
|
|
104
133
|
comments = source_map.source.comments_for(chain.node)
|
|
105
|
-
if comments&.length&.positive?
|
|
134
|
+
if comments&.length&.positive?
|
|
106
135
|
directive.tag.text += "\n#{comments}"
|
|
107
136
|
end
|
|
108
137
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Solargraph
|
|
4
|
-
|
|
4
|
+
module YardMap
|
|
5
5
|
class Mapper
|
|
6
6
|
autoload :ToMethod, 'solargraph/yard_map/mapper/to_method'
|
|
7
7
|
autoload :ToNamespace, 'solargraph/yard_map/mapper/to_namespace'
|
|
@@ -33,7 +33,7 @@ module Solargraph
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
35
|
def core_store
|
|
36
|
-
@core_store ||= ApiMap::Store.new(RbsMap::
|
|
36
|
+
@core_store ||= ApiMap::Store.new(RbsMap::Core.new.pins)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# @param code_object [YARD::CodeObjects::Base]
|
data/lib/solargraph/yard_map.rb
CHANGED
data/lib/solargraph/yardoc.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'open3'
|
|
4
|
+
require 'fileutils'
|
|
4
5
|
|
|
5
6
|
module Solargraph
|
|
6
7
|
# Methods for caching and loading YARD documentation for gems.
|
|
@@ -8,83 +9,65 @@ module Solargraph
|
|
|
8
9
|
module Yardoc
|
|
9
10
|
module_function
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# @param
|
|
16
|
-
# @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
12
|
+
def path_for metagem
|
|
13
|
+
File.join(CacheDir.yard_dir, "#{metagem.cache_name}.yardoc")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @param metagem [Metagem]
|
|
17
|
+
# @param force [Boolean]
|
|
18
|
+
# @return [void]
|
|
19
|
+
def cache metagem, force: false
|
|
20
|
+
return unless force || !cached?(metagem)
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
end
|
|
22
|
+
Solargraph.logger.info "Caching yardoc for #{metagem.cache_name}"
|
|
23
|
+
path = path_for(metagem)
|
|
24
|
+
FileUtils.mkdir_p File.dirname(path)
|
|
25
|
+
cmd = ['yardoc', '--db', path, '--no-output', '--plugin', 'solargraph', '--plugin', 'activesupport-concern']
|
|
26
|
+
Solargraph.logger.debug "Running: #{cmd.inspect}"
|
|
27
|
+
output, status = Open3.capture2e(*cmd, chdir: metagem.full_path)
|
|
28
|
+
return if status.success?
|
|
29
29
|
|
|
30
|
-
Solargraph.logger.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# @sg-ignore Unrecognized keyword argument chdir to Open3.capture2e
|
|
37
|
-
stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir)
|
|
38
|
-
unless status.success?
|
|
39
|
-
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" }
|
|
40
|
-
Solargraph.logger.info stdout_and_stderr_str
|
|
41
|
-
end
|
|
42
|
-
path
|
|
30
|
+
Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{metagem.full_path}" }
|
|
31
|
+
Solargraph.logger.info output
|
|
32
|
+
# @todo Ignore missing metagems for now. We need to figure out why this
|
|
33
|
+
# happens in GitHub actions.
|
|
34
|
+
rescue Errno::ENOENT => _e
|
|
35
|
+
Solargraph.logger.warn "Gem #{metagem.name} #{metagem.version} not found at #{metagem.full_path}"
|
|
43
36
|
end
|
|
44
37
|
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
# @param metagem [Metagem]
|
|
39
|
+
# @return [void]
|
|
40
|
+
def uncache metagem
|
|
41
|
+
FileUtils.rm_rf path_for(metagem)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @param metagem [Metagem]
|
|
45
|
+
def cached? metagem
|
|
46
|
+
yardoc = File.join(path_for(metagem), 'complete')
|
|
50
47
|
File.exist?(yardoc)
|
|
51
48
|
end
|
|
49
|
+
alias exist? cached?
|
|
52
50
|
|
|
53
51
|
# True if another process is currently building the yardoc cache.
|
|
54
52
|
#
|
|
55
|
-
# @param
|
|
56
|
-
def processing?
|
|
57
|
-
yardoc = File.join(
|
|
53
|
+
# @param metagem [Metagem]
|
|
54
|
+
def processing? metagem
|
|
55
|
+
yardoc = File.join(path_for(metagem), 'processing')
|
|
58
56
|
File.exist?(yardoc)
|
|
59
57
|
end
|
|
60
58
|
|
|
61
|
-
# Load a gem's yardoc and return its code objects.
|
|
59
|
+
# Load a gem's yardoc cache and return its code objects.
|
|
62
60
|
#
|
|
63
61
|
# @note This method modifies the global YARD registry.
|
|
64
62
|
#
|
|
65
|
-
# @param
|
|
63
|
+
# @param metagem [Metagem]
|
|
66
64
|
# @return [Array<YARD::CodeObjects::Base>]
|
|
67
|
-
def load!
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
end
|
|
65
|
+
def load! metagem
|
|
66
|
+
cache metagem
|
|
67
|
+
return [] unless cached?(metagem)
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# directories.
|
|
75
|
-
#
|
|
76
|
-
# 'bundle exec' sets an absolute path here, but at least the
|
|
77
|
-
# overcommit gem does not, breaking on-the-fly documention with a
|
|
78
|
-
# spawned yardoc command from our current bundle
|
|
79
|
-
#
|
|
80
|
-
# @return [Hash{String => String}] a hash of environment variables to override
|
|
81
|
-
def current_bundle_env_tweaks
|
|
82
|
-
tweaks = {}
|
|
83
|
-
# @sg-ignore Unresolved call to empty? on String, nil
|
|
84
|
-
if ENV['BUNDLE_GEMFILE'] && !ENV['BUNDLE_GEMFILE'].empty?
|
|
85
|
-
tweaks['BUNDLE_GEMFILE'] = File.expand_path(ENV['BUNDLE_GEMFILE'])
|
|
86
|
-
end
|
|
87
|
-
tweaks
|
|
69
|
+
YARD::Registry.load! path_for(metagem)
|
|
70
|
+
YARD::Registry.all
|
|
88
71
|
end
|
|
89
72
|
end
|
|
90
73
|
end
|
data/lib/solargraph.rb
CHANGED
|
@@ -4,6 +4,7 @@ Encoding.default_external = 'UTF-8'
|
|
|
4
4
|
|
|
5
5
|
require 'bundler'
|
|
6
6
|
require 'set'
|
|
7
|
+
require 'yard-activesupport-concern'
|
|
7
8
|
require 'yard-solargraph'
|
|
8
9
|
require 'solargraph/yard_tags'
|
|
9
10
|
require 'solargraph/version'
|
|
@@ -31,7 +32,10 @@ module Solargraph
|
|
|
31
32
|
autoload :Yardoc, 'solargraph/yardoc'
|
|
32
33
|
autoload :YardMap, 'solargraph/yard_map'
|
|
33
34
|
autoload :Pin, 'solargraph/pin'
|
|
34
|
-
autoload :
|
|
35
|
+
autoload :Metagem, 'solargraph/metagem'
|
|
36
|
+
autoload :Repo, 'solargraph/repo'
|
|
37
|
+
autoload :External, 'solargraph/external'
|
|
38
|
+
autoload :Collection, 'solargraph/collection'
|
|
35
39
|
autoload :ServerMethods, 'solargraph/server_methods'
|
|
36
40
|
autoload :LanguageServer, 'solargraph/language_server'
|
|
37
41
|
autoload :Workspace, 'solargraph/workspace'
|
|
@@ -47,8 +51,7 @@ module Solargraph
|
|
|
47
51
|
autoload :Convention, 'solargraph/convention'
|
|
48
52
|
autoload :Parser, 'solargraph/parser'
|
|
49
53
|
autoload :RbsMap, 'solargraph/rbs_map'
|
|
50
|
-
autoload :
|
|
51
|
-
autoload :PinCache, 'solargraph/pin_cache'
|
|
54
|
+
autoload :CacheDir, 'solargraph/cache_dir'
|
|
52
55
|
autoload :RbsTranslator, 'solargraph/rbs_translator'
|
|
53
56
|
|
|
54
57
|
dir = File.dirname(__FILE__)
|
data/solargraph.gemspec
CHANGED
|
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
|
44
44
|
s.add_dependency 'ostruct', '~> 0.6'
|
|
45
45
|
s.add_dependency 'parser', '~> 3.0'
|
|
46
46
|
s.add_dependency 'prism', '~> 1.4'
|
|
47
|
-
s.add_dependency 'rbs', '>= 3.10.
|
|
47
|
+
s.add_dependency 'rbs', '>= 3.10.4'
|
|
48
48
|
s.add_dependency 'rdoc', '~> 7.0'
|
|
49
49
|
s.add_dependency 'reverse_markdown', '~> 3.0'
|
|
50
50
|
s.add_dependency 'rubocop', '~> 1.76'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solargraph
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.61.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
@@ -217,14 +217,14 @@ dependencies:
|
|
|
217
217
|
requirements:
|
|
218
218
|
- - ">="
|
|
219
219
|
- !ruby/object:Gem::Version
|
|
220
|
-
version: 3.10.
|
|
220
|
+
version: 3.10.4
|
|
221
221
|
type: :runtime
|
|
222
222
|
prerelease: false
|
|
223
223
|
version_requirements: !ruby/object:Gem::Requirement
|
|
224
224
|
requirements:
|
|
225
225
|
- - ">="
|
|
226
226
|
- !ruby/object:Gem::Version
|
|
227
|
-
version: 3.10.
|
|
227
|
+
version: 3.10.4
|
|
228
228
|
- !ruby/object:Gem::Dependency
|
|
229
229
|
name: rdoc
|
|
230
230
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -588,6 +588,13 @@ files:
|
|
|
588
588
|
- lib/solargraph/api_map/source_to_yard.rb
|
|
589
589
|
- lib/solargraph/api_map/store.rb
|
|
590
590
|
- lib/solargraph/bench.rb
|
|
591
|
+
- lib/solargraph/cache_dir.rb
|
|
592
|
+
- lib/solargraph/collection.rb
|
|
593
|
+
- lib/solargraph/collection/base.rb
|
|
594
|
+
- lib/solargraph/collection/core.rb
|
|
595
|
+
- lib/solargraph/collection/gem.rb
|
|
596
|
+
- lib/solargraph/collection/rbs.rb
|
|
597
|
+
- lib/solargraph/collection/stdlib.rb
|
|
591
598
|
- lib/solargraph/complex_type.rb
|
|
592
599
|
- lib/solargraph/complex_type/conformance.rb
|
|
593
600
|
- lib/solargraph/complex_type/type_methods.rb
|
|
@@ -616,10 +623,9 @@ files:
|
|
|
616
623
|
- lib/solargraph/diagnostics/severities.rb
|
|
617
624
|
- lib/solargraph/diagnostics/type_check.rb
|
|
618
625
|
- lib/solargraph/diagnostics/update_errors.rb
|
|
619
|
-
- lib/solargraph/doc_map.rb
|
|
620
626
|
- lib/solargraph/environ.rb
|
|
621
627
|
- lib/solargraph/equality.rb
|
|
622
|
-
- lib/solargraph/
|
|
628
|
+
- lib/solargraph/external.rb
|
|
623
629
|
- lib/solargraph/language_server.rb
|
|
624
630
|
- lib/solargraph/language_server/completion_item_kinds.rb
|
|
625
631
|
- lib/solargraph/language_server/error_codes.rb
|
|
@@ -684,6 +690,7 @@ files:
|
|
|
684
690
|
- lib/solargraph/library.rb
|
|
685
691
|
- lib/solargraph/location.rb
|
|
686
692
|
- lib/solargraph/logging.rb
|
|
693
|
+
- lib/solargraph/metagem.rb
|
|
687
694
|
- lib/solargraph/page.rb
|
|
688
695
|
- lib/solargraph/parser.rb
|
|
689
696
|
- lib/solargraph/parser/comment_ripper.rb
|
|
@@ -738,6 +745,7 @@ files:
|
|
|
738
745
|
- lib/solargraph/pin/delegated_method.rb
|
|
739
746
|
- lib/solargraph/pin/documenting.rb
|
|
740
747
|
- lib/solargraph/pin/duck_method.rb
|
|
748
|
+
- lib/solargraph/pin/factory_parameter.rb
|
|
741
749
|
- lib/solargraph/pin/global_variable.rb
|
|
742
750
|
- lib/solargraph/pin/instance_variable.rb
|
|
743
751
|
- lib/solargraph/pin/keyword.rb
|
|
@@ -762,15 +770,19 @@ files:
|
|
|
762
770
|
- lib/solargraph/pin/symbol.rb
|
|
763
771
|
- lib/solargraph/pin/until.rb
|
|
764
772
|
- lib/solargraph/pin/while.rb
|
|
765
|
-
- lib/solargraph/pin_cache.rb
|
|
766
773
|
- lib/solargraph/position.rb
|
|
767
774
|
- lib/solargraph/range.rb
|
|
768
775
|
- lib/solargraph/rbs_map.rb
|
|
776
|
+
- lib/solargraph/rbs_map/base.rb
|
|
769
777
|
- lib/solargraph/rbs_map/conversions.rb
|
|
778
|
+
- lib/solargraph/rbs_map/core.rb
|
|
770
779
|
- lib/solargraph/rbs_map/core_fills.rb
|
|
771
|
-
- lib/solargraph/rbs_map/
|
|
772
|
-
- lib/solargraph/rbs_map/
|
|
780
|
+
- lib/solargraph/rbs_map/gem.rb
|
|
781
|
+
- lib/solargraph/rbs_map/helpers.rb
|
|
782
|
+
- lib/solargraph/rbs_map/path.rb
|
|
783
|
+
- lib/solargraph/rbs_map/stdlib.rb
|
|
773
784
|
- lib/solargraph/rbs_translator.rb
|
|
785
|
+
- lib/solargraph/repo.rb
|
|
774
786
|
- lib/solargraph/server_methods.rb
|
|
775
787
|
- lib/solargraph/shell.rb
|
|
776
788
|
- lib/solargraph/source.rb
|
|
@@ -789,6 +801,7 @@ files:
|
|
|
789
801
|
- lib/solargraph/source/chain/link.rb
|
|
790
802
|
- lib/solargraph/source/chain/literal.rb
|
|
791
803
|
- lib/solargraph/source/chain/or.rb
|
|
804
|
+
- lib/solargraph/source/chain/parameter.rb
|
|
792
805
|
- lib/solargraph/source/chain/q_call.rb
|
|
793
806
|
- lib/solargraph/source/chain/variable.rb
|
|
794
807
|
- lib/solargraph/source/chain/z_super.rb
|
|
@@ -815,7 +828,6 @@ files:
|
|
|
815
828
|
- lib/solargraph/views/search.erb
|
|
816
829
|
- lib/solargraph/workspace.rb
|
|
817
830
|
- lib/solargraph/workspace/config.rb
|
|
818
|
-
- lib/solargraph/workspace/gemspecs.rb
|
|
819
831
|
- lib/solargraph/workspace/require_paths.rb
|
|
820
832
|
- lib/solargraph/yard_map.rb
|
|
821
833
|
- lib/solargraph/yard_map/cache.rb
|
|
@@ -825,6 +837,7 @@ files:
|
|
|
825
837
|
- lib/solargraph/yard_map/directives/method_directive.rb
|
|
826
838
|
- lib/solargraph/yard_map/directives/override_directive.rb
|
|
827
839
|
- lib/solargraph/yard_map/directives/parse_directive.rb
|
|
840
|
+
- lib/solargraph/yard_map/directives/scope_directive.rb
|
|
828
841
|
- lib/solargraph/yard_map/directives/visibility_directive.rb
|
|
829
842
|
- lib/solargraph/yard_map/helpers.rb
|
|
830
843
|
- lib/solargraph/yard_map/macro.rb
|