solargraph 0.48.0 → 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/rspec.yml +1 -1
  4. data/CHANGELOG.md +9 -0
  5. data/LICENSE +1 -1
  6. data/SPONSORS.md +2 -4
  7. data/lib/solargraph/api_map/store.rb +13 -1
  8. data/lib/solargraph/api_map.rb +30 -12
  9. data/lib/solargraph/cache.rb +51 -0
  10. data/lib/solargraph/complex_type/type_methods.rb +3 -6
  11. data/lib/solargraph/complex_type/unique_type.rb +57 -0
  12. data/lib/solargraph/complex_type.rb +20 -1
  13. data/lib/solargraph/convention/rakefile.rb +17 -0
  14. data/lib/solargraph/convention.rb +2 -0
  15. data/lib/solargraph/diagnostics/rubocop.rb +15 -2
  16. data/lib/solargraph/diagnostics/rubocop_helpers.rb +3 -1
  17. data/lib/solargraph/language_server/host.rb +22 -18
  18. data/lib/solargraph/language_server/message/extended/download_core.rb +1 -5
  19. data/lib/solargraph/language_server/message/initialize.rb +2 -0
  20. data/lib/solargraph/language_server/message/text_document/formatting.rb +1 -1
  21. data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
  22. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
  23. data/lib/solargraph/library.rb +21 -20
  24. data/lib/solargraph/parser/rubyvm/class_methods.rb +6 -1
  25. data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +20 -8
  26. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +14 -3
  27. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +4 -2
  28. data/lib/solargraph/parser/rubyvm/node_wrapper.rb +47 -0
  29. data/lib/solargraph/pin/base.rb +5 -2
  30. data/lib/solargraph/pin/conversions.rb +2 -6
  31. data/lib/solargraph/pin/method.rb +84 -10
  32. data/lib/solargraph/pin/namespace.rb +4 -1
  33. data/lib/solargraph/pin/parameter.rb +8 -3
  34. data/lib/solargraph/pin/signature.rb +23 -0
  35. data/lib/solargraph/pin.rb +1 -0
  36. data/lib/solargraph/rbs_map/conversions.rb +394 -0
  37. data/lib/solargraph/rbs_map/core_fills.rb +61 -0
  38. data/lib/solargraph/rbs_map/core_map.rb +38 -0
  39. data/lib/solargraph/rbs_map/core_signs.rb +33 -0
  40. data/lib/solargraph/rbs_map/stdlib_map.rb +36 -0
  41. data/lib/solargraph/rbs_map.rb +73 -0
  42. data/lib/solargraph/shell.rb +38 -30
  43. data/lib/solargraph/source/chain/call.rb +30 -22
  44. data/lib/solargraph/source/chain.rb +21 -6
  45. data/lib/solargraph/source_map/clip.rb +5 -0
  46. data/lib/solargraph/source_map/mapper.rb +2 -0
  47. data/lib/solargraph/type_checker.rb +71 -65
  48. data/lib/solargraph/version.rb +1 -1
  49. data/lib/solargraph/views/environment.erb +2 -2
  50. data/lib/solargraph/workspace.rb +11 -14
  51. data/lib/solargraph/yard_map/mapper/to_method.rb +7 -4
  52. data/lib/solargraph/yard_map.rb +7 -148
  53. data/lib/solargraph.rb +2 -2
  54. data/solargraph.gemspec +8 -6
  55. metadata +43 -36
  56. data/lib/solargraph/compat.rb +0 -37
  57. data/lib/solargraph/yard_map/core_docs.rb +0 -170
  58. data/lib/solargraph/yard_map/core_fills.rb +0 -208
  59. data/lib/solargraph/yard_map/core_gen.rb +0 -76
  60. data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -143
  61. data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
  62. data/yardoc/2.2.2.tar.gz +0 -0
@@ -1,170 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'net/http'
4
- require 'uri'
5
- require 'json'
6
- require 'fileutils'
7
-
8
- module Solargraph
9
- class YardMap
10
- # Tools for managing core documentation.
11
- #
12
- module CoreDocs
13
- # The URL for downloading core documentation
14
- SOURCE = 'https://solargraph.org/download'
15
-
16
- # The default core documentation version
17
- DEFAULT = '2.2.2'
18
-
19
- class << self
20
- # The directory where core documentation is installed.
21
- #
22
- # @return [String]
23
- def cache_dir
24
- # The directory is not stored in a variable so it can be overridden
25
- # in specs.
26
- ENV['SOLARGRAPH_CACHE'] || File.join(Dir.home, '.solargraph', 'cache')
27
- end
28
-
29
- # Ensure installation of minimum documentation.
30
- #
31
- # @return [void]
32
- def require_minimum
33
- FileUtils.mkdir_p File.join(cache_dir, 'gems')
34
- return unless best_match.nil?
35
- FileUtils.cp File.join(Solargraph::YARDOC_PATH, "#{DEFAULT}.tar.gz"), cache_dir
36
- install_archive File.join(cache_dir, "#{DEFAULT}.tar.gz")
37
- end
38
-
39
- # True if core documentation is installed for the specified version
40
- # number.
41
- #
42
- # @param ver [String] The version number to check
43
- # @return [Boolean]
44
- def valid?(ver)
45
- dir = File.join(cache_dir, ver)
46
- return false unless File.directory?(dir)
47
- return false unless File.directory?(File.join(dir, 'yardoc'))
48
- return false unless File.directory?(File.join(dir, 'yardoc-stdlib'))
49
- true
50
- end
51
-
52
- # Get a list of version numbers for currently installed core
53
- # documentation.
54
- #
55
- # @return [Array<String>] The installed version numbers
56
- def versions
57
- dirs = Dir[File.join(cache_dir, '*')].map{|d| File.basename(d)}
58
- dirs.keep_if{|d| valid?(d)}
59
- dirs.sort!{|a, b| Gem::Version.new(b) <=> Gem::Version.new(a)}
60
- dirs
61
- end
62
-
63
- # Get the version number of the installed core documentation that is
64
- # the closest match for the current Ruby version.
65
- #
66
- # @return [String] The closest match
67
- def best_match
68
- avail = versions
69
- cur = Gem::Version.new(RUBY_VERSION)
70
- avail.each do |v|
71
- return v if Gem::Version.new(v) <= cur
72
- end
73
- avail.last
74
- end
75
-
76
- # Get a list of core documentation versions that are available for
77
- # download.
78
- #
79
- # @return [Array<String>] The version numbers
80
- def available
81
- uri = URI.parse("#{SOURCE}/versions.json")
82
- response = Net::HTTP.get_response(uri)
83
- obj = JSON.parse(response.body)
84
- raise SourceNotAvailableError, "Error connecting to #{SOURCE}" unless obj['status'] == 'ok'
85
- obj['cores']
86
- end
87
-
88
- # Get the version number of core documentation available for download
89
- # that is the closest match for the current Ruby version.
90
- #
91
- # @param current [String] The version to compare
92
- # @return [String] The version number of the best match
93
- def best_download current = RUBY_VERSION
94
- rv = Gem::Version.new(current)
95
- found = available
96
- found.each do |ver|
97
- return ver if Gem::Version.new(ver) <= rv
98
- end
99
- found.last
100
- end
101
-
102
- # Get the path to a yardoc file for Ruby core documentation.
103
- #
104
- # @param ver [String] The version number (best match is default)
105
- # @return [String] The path to the yardoc
106
- def yardoc_file(ver = best_match)
107
- raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
108
- File.join(cache_dir, ver, 'yardoc')
109
- end
110
-
111
- # Get the path to a yardoc file for Ruby stdlib documentation.
112
- #
113
- # @param ver [String] The version number (best match is default)
114
- # @return [String] The path to the yardoc
115
- def yardoc_stdlib_file(ver = best_match)
116
- raise ArgumentError, "Invalid core yardoc version #{ver}" unless valid?(ver)
117
- File.join(cache_dir, ver, 'yardoc-stdlib')
118
- end
119
-
120
- # Download the specified version of core documentation.
121
- #
122
- # @param version [String]
123
- # @return [void]
124
- def download version
125
- FileUtils.mkdir_p cache_dir
126
- uri = URI.parse("#{SOURCE}/#{version}.tar.gz")
127
- # @type [Net::HTTPResponse]
128
- response = Net::HTTP.get_response(uri)
129
- if response.code == '404'
130
- raise ArgumentError, "Version #{version} is not available from #{SOURCE}"
131
- else
132
- zipfile = File.join(cache_dir, "#{version}.tar.gz")
133
- File.binwrite zipfile, response.body
134
- install_archive zipfile
135
- end
136
- end
137
-
138
- # Reset the core documentation cache to the minimum requirement.
139
- #
140
- # @return [void]
141
- def clear
142
- FileUtils.rm_rf cache_dir, secure: true
143
- require_minimum
144
- end
145
-
146
- private
147
-
148
- # Extract the specified archive to the core cache directory.
149
- #
150
- # @param filename [String]
151
- # @return [void]
152
- def install_archive filename
153
- tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
154
- tar_extract.rewind
155
- tar_extract.each do |entry|
156
- if entry.directory?
157
- FileUtils.mkdir_p File.join(cache_dir, entry.full_name)
158
- else
159
- FileUtils.mkdir_p File.join(cache_dir, File.dirname(entry.full_name))
160
- File.open(File.join(cache_dir, entry.full_name), 'wb') do |f|
161
- f << entry.read
162
- end
163
- end
164
- end
165
- tar_extract.close
166
- end
167
- end
168
- end
169
- end
170
- end
@@ -1,208 +0,0 @@
1
- module Solargraph
2
- class YardMap
3
- module CoreFills
4
- Override = Pin::Reference::Override
5
-
6
- KEYWORDS = [
7
- '__ENCODING__', '__LINE__', '__FILE__', 'BEGIN', 'END', 'alias', 'and',
8
- 'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
9
- 'elsif', 'end', 'ensure', 'false', 'for', 'if', 'in', 'module', 'next',
10
- 'nil', 'not', 'or', 'redo', 'rescue', 'retry', 'return', 'self', 'super',
11
- 'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
12
- ].map { |k| Pin::Keyword.new(k) }
13
-
14
- methods_with_yieldparam_subtypes = %w[
15
- Array#each Array#map Array#map! Array#any? Array#all? Array#index
16
- Array#keep_if Array#delete_if
17
- Enumerable#each_entry Enumerable#map Enumerable#any? Enumerable#all?
18
- Enumerable#select Enumerable#reject
19
- Set#each
20
- ]
21
-
22
- OVERRIDES = [
23
- Override.method_return('Array#concat', 'Array'),
24
- Override.method_return('Array#keep_if', 'self'),
25
- Override.method_return('Array#delete_if', 'self'),
26
- Override.from_comment('Array#map', %(
27
- @overload map(&block)
28
- @return [Array]
29
- @overload map()
30
- @return [Enumerator]
31
- )),
32
- Override.from_comment('Array#reject', %(
33
- @overload reject(&block)
34
- @return [self]
35
- @overload reject()
36
- @return [Enumerator]
37
- )),
38
- Override.method_return('Array#reverse', 'self', delete: ['overload']),
39
- Override.from_comment('Array#select', %(
40
- @overload select(&block)
41
- @return [self]
42
- @overload select()
43
- @return [Enumerator]
44
- )),
45
- Override.from_comment('Array#[]', %(
46
- @overload [](range)
47
- @param range [Range]
48
- @return [self]
49
- @overload [](num1, num2)
50
- @param num1 [Integer]
51
- @param num2 [Integer]
52
- @return [self]
53
- @overload [](num)
54
- @param num [Integer]
55
- @return_single_parameter
56
- @return_single_parameter
57
- )),
58
- Override.from_comment('Array#first', %(
59
- @overload first(num)
60
- @param num [Integer]
61
- @return [self]
62
- @return_single_parameter
63
- )),
64
- Override.from_comment('Array#last', %(
65
- @overload last(num)
66
- @param num [Integer]
67
- @return [self]
68
- @return_single_parameter
69
- )),
70
- Override.method_return('Array#map', 'Array'),
71
- Override.method_return('Array#uniq', 'self'),
72
- Override.method_return('Array#zip', 'Array, nil'),
73
-
74
- Override.from_comment('BasicObject#==', %(
75
- @param other [BasicObject]
76
- @return [Boolean]
77
- )),
78
- Override.method_return('BasicObject#initialize', 'void'),
79
-
80
- Override.method_return('Class#new', 'self'),
81
- Override.method_return('Class.new', 'Class<Object>'),
82
- Override.method_return('Class#allocate', 'self'),
83
- Override.method_return('Class.allocate', 'Class<Object>'),
84
-
85
- Override.from_comment('Enumerable#detect', %(
86
- @overload detect(&block)
87
- @return_single_parameter
88
- @overload detect()
89
- @return [Enumerator]
90
- )),
91
- Override.from_comment('Enumerable#find', %(
92
- @overload find(&block)
93
- @return_single_parameter
94
- @overload find()
95
- @return [Enumerator]
96
- )),
97
- Override.method_return('Enumerable#select', 'self'),
98
-
99
- Override.method_return('File.absolute_path', 'String'),
100
- Override.method_return('File.basename', 'String'),
101
- Override.method_return('File.dirname', 'String'),
102
- Override.method_return('File.extname', 'String'),
103
- Override.method_return('File.join', 'String'),
104
- Override.method_return('File.open', 'File'),
105
-
106
- Override.from_comment('Float#+', %(
107
- @param y [Numeric]
108
- @return [Numeric]
109
- )),
110
-
111
- Override.from_comment('Hash#[]', %(
112
- @return_value_parameter
113
- )),
114
- # @todo This override isn't robust enough. It needs to allow for
115
- # parameterized Hash types, e.g., [Hash{Symbol => String}].
116
- Override.from_comment('Hash#[]=', %(
117
- @param_tuple
118
- )),
119
- Override.method_return('Hash#merge', 'Hash'),
120
- Override.from_comment('Hash#store', %{
121
- @overload store(key, value)
122
- }),
123
-
124
- Override.from_comment('Integer#+', %(
125
- @param y [Numeric]
126
- @return [Numeric]
127
- )),
128
- Override.from_comment('Integer#times', %(
129
- @overload times(&block)
130
- @return [Integer]
131
- @overload times()
132
- @return [Enumerator]
133
- )),
134
-
135
- Override.method_return('Kernel#puts', 'nil'),
136
-
137
- Override.from_comment('Numeric#+', %(
138
- @param y [Numeric]
139
- @return [Numeric]
140
- )),
141
-
142
- Override.method_return('Object#!', 'Boolean'),
143
- Override.method_return('Object#clone', 'self', delete: [:overload]),
144
- Override.method_return('Object#dup', 'self', delete: [:overload]),
145
- Override.method_return('Object#freeze', 'self', delete: [:overload]),
146
- Override.method_return('Object#inspect', 'String'),
147
- Override.method_return('Object#taint', 'self'),
148
- Override.method_return('Object#to_s', 'String'),
149
- Override.method_return('Object#untaint', 'self'),
150
- Override.from_comment('Object#tap', %(
151
- @return [self]
152
- @yieldparam [self]
153
- )),
154
-
155
- Override.from_comment('STDERR', %(
156
- @type [IO]
157
- )),
158
-
159
- Override.from_comment('STDIN', %(
160
- @type [IO]
161
- )),
162
-
163
- Override.from_comment('STDOUT', %(
164
- @type [IO]
165
- )),
166
-
167
- Override.method_return('String#freeze', 'self'),
168
- Override.method_return('String#split', 'Array<String>'),
169
- Override.method_return('String#lines', 'Array<String>'),
170
- Override.from_comment('String#each_line', %(
171
- @yieldparam [String]
172
- )),
173
- Override.from_comment('String.new', %(
174
- @overload new(*)
175
- @return [self]
176
- ))
177
- ].concat(
178
- methods_with_yieldparam_subtypes.map do |path|
179
- Override.from_comment(path, %(
180
- @yieldparam_single_parameter
181
- ))
182
- end
183
- )
184
-
185
- PINS = [
186
- # HACK: Extending Hash is not accurate to the implementation, but
187
- # accurate enough to the behavior
188
- Pin::Reference::Extend.new(closure: Pin::Namespace.new(name: 'ENV'), name: 'Hash'),
189
- Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'File'), name: 'IO'),
190
- Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'Integer'), name: 'Numeric'),
191
- Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'Float'), name: 'Numeric')
192
- ].concat(
193
- # HACK: Add Errno exception classes
194
- begin
195
- errno = Solargraph::Pin::Namespace.new(name: 'Errno')
196
- result = []
197
- Errno.constants.each do |const|
198
- result.push Solargraph::Pin::Namespace.new(type: :class, name: const.to_s, closure: errno)
199
- result.push Solargraph::Pin::Reference::Superclass.new(closure: result.last, name: 'SystemCallError')
200
- end
201
- result
202
- end
203
- )
204
-
205
- ALL = KEYWORDS + PINS + OVERRIDES
206
- end
207
- end
208
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
- require 'tmpdir'
5
- require 'pathname'
6
- require 'rubygems/package'
7
- require 'shellwords'
8
-
9
- module Solargraph
10
- class YardMap
11
- # Tools for generating core documentation.
12
- #
13
- module CoreGen
14
- class << self
15
- # Generate documentation from the specified Ruby source directory.
16
- #
17
- # @param ruby_dir [String] The Ruby source directory
18
- # @param dest_dir [String] The destination directory for the yardocs
19
- # @return [void]
20
- def generate_docs ruby_dir, dest_dir
21
- path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
22
- FileUtils.mkdir_p path_name
23
- Dir.chdir(ruby_dir) do
24
- `yardoc -b "#{File.join(path_name, 'yardoc')}" -n *.c`
25
- raise 'An error occurred generating the core yardoc.' unless $?.success?
26
- `yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
27
- raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
28
- end
29
- end
30
-
31
- # Generate a gzip of documentation from the specified Ruby source
32
- # directory.
33
- #
34
- # This method is designed to generate the directory architecture that
35
- # YardMap core docs expect.
36
- #
37
- # @param ruby_dir [String] The Ruby source directory
38
- # @param ver_name [String, nil] The version name
39
- # @param dest_dir [String] The destination directory
40
- # @return [void]
41
- def generate_gzip ruby_dir, ver_name = nil, dest_dir = Dir.pwd
42
- Dir.mktmpdir do |tmp|
43
- base_name = ver_name || begin
44
- match = ruby_dir.match(/\d+\.\d+\.\d+$/)
45
- raise "Unable to determine version name from #{ruby_dir}" if match.nil?
46
- match[0]
47
- end
48
- path_name = Pathname.new(tmp).join(base_name).to_s
49
- generate_docs ruby_dir, path_name
50
- gzip path_name, Pathname.new(dest_dir).join("#{base_name}.tar.gz").to_s
51
- end
52
- end
53
-
54
- private
55
-
56
- # @param dir [String] The directory to compress
57
- # @param dst [String] The destination file
58
- def gzip dir, dst
59
- File.open(dst, 'wb') do |file|
60
- Zlib::GzipWriter.wrap(file) do |gzip|
61
- Gem::Package::TarWriter.new(gzip) do |tar|
62
- Dir["#{dir}/**/*"].each do |filename|
63
- next if File.directory?(filename)
64
- relname = File.join(File.basename(dir), filename[dir.length+1..-1])
65
- tar.add_file_simple(relname, 0o644, File.size(filename)) do |io|
66
- io.write File.read_binary(filename)
67
- end
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,143 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rdoc'
4
- require 'rdoc/rdoc'
5
- require 'tmpdir'
6
- require 'fileutils'
7
-
8
- module Solargraph
9
- class YardMap
10
- module RdocToYard
11
- extend ApiMap::SourceToYard
12
-
13
- # @param spec [Gem::Specification]
14
- # @param cache_dir [String]
15
- # @return [void]
16
- def self.run spec, cache_dir: nil
17
- Dir.mktmpdir do |tmpdir|
18
- rdir = File.join(tmpdir, 'sg_tmp_rdoc')
19
- FileUtils.cp_r Dir.glob(File.join(spec.full_gem_path, '*')), tmpdir
20
- Dir.chdir tmpdir do
21
- pins = []
22
- pins.push Solargraph::Pin::ROOT_PIN
23
- name_hash = {}
24
-
25
- argv = ['-q', '-r', '-N', '-o', rdir]
26
- spec.load_paths.each do |path|
27
- argv.concat ['-i', path]
28
- end
29
- rdoc = RDoc::RDoc.new
30
- rdoc.document argv
31
- # @type [RDoc::Store]
32
- store = rdoc.store
33
- store.path = rdir
34
- store.cache[:modules].each do |mod|
35
- # @type [RDoc::NormalClass]
36
- mod = store.find_class_or_module(mod)
37
- closure = pins.select { |pin| pin.path == mod.full_name.split('::')[0..-2].join('::') }.first || pins.first
38
- namepin = Solargraph::Pin::Namespace.new(
39
- type: (mod.module? ? :module : :class),
40
- name: mod.name,
41
- comments: commentary(mod.comment),
42
- closure: closure,
43
- location: locate(mod)
44
- )
45
- mod.parse(mod.comment_location)
46
- # @param inc [RDoc::Include]
47
- mod.includes.each do |inc|
48
- pins.push Solargraph::Pin::Reference::Include.new(
49
- location: locate(inc),
50
- name: inc.name,
51
- closure: namepin
52
- )
53
- end
54
- # @param ext [RDoc::Extend]
55
- mod.extends.each do |ext|
56
- pins.push Solargraph::Pin::Reference::Extend.new(
57
- location: locate(ext),
58
- name: ext.name,
59
- closure: namepin
60
- )
61
- end
62
- pins.push namepin
63
- name_hash[mod.full_name] = namepin
64
- # @param met [RDoc::AnyMethod]
65
- mod.each_method do |met|
66
- pin = Solargraph::SourceMap.load_string("def Object.tmp#{met.param_seq};end").first_pin('Object.tmp') || Solargraph::Pin::Method.new
67
- pins.push Solargraph::Pin::Method.new(
68
- name: met.name,
69
- closure: namepin,
70
- comments: commentary(met.comment),
71
- scope: met.type.to_sym,
72
- parameters: pin.parameters,
73
- visibility: met.visibility,
74
- location: locate(met)
75
- )
76
- end
77
- # @param const [RDoc::Constant]
78
- mod.each_constant do |const|
79
- pins.push Solargraph::Pin::Constant.new(
80
- name: const.name,
81
- closure: namepin,
82
- comments: commentary(const.comment),
83
- location: locate(const)
84
- )
85
- end
86
- end
87
- mapstore = Solargraph::ApiMap::Store.new(pins)
88
- rake_yard(mapstore)
89
- YARD::Registry.clear
90
- code_object_map.values.each do |co|
91
- YARD::Registry.register(co)
92
- end
93
- cache_dir ||= File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}", "yardoc")
94
- FileUtils.remove_entry_secure cache_dir if File.exist?(cache_dir)
95
- FileUtils.mkdir_p cache_dir
96
- # @todo Should merge be true?
97
- YARD::Registry.save true, cache_dir
98
- # Clear the serialized cache if it exists
99
- FileUtils.safe_unlink File.join(CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}.ser")
100
- end
101
- end
102
- end
103
-
104
- def self.base_name mod
105
- mod.full_name.split('::')[0..-2].join('::')
106
- end
107
-
108
- # @param cmnt [RDoc::Comment]
109
- # @return [String]
110
- def self.commentary cmnt
111
- return cmnt if cmnt.is_a?(String)
112
- return cmnt.text if cmnt.is_a?(RDoc::Comment)
113
- result = []
114
- cmnt.parts.each do |part|
115
- result.push RDoc::Markup::ToHtml.new({}).to_html(part.text) if part.respond_to?(:text)
116
- end
117
- result.join("\n\n")
118
- end
119
-
120
- # @param obj [RDoc::Context]
121
- def self.locate obj
122
- # @todo line is always nil for some reason
123
- file, line = find_file(obj)
124
- return nil if file.nil?
125
- Location.new(
126
- file,
127
- Range.from_to(line || 1, 0, line || 1, 0)
128
- )
129
- end
130
-
131
- def self.find_file obj
132
- file = if obj.respond_to?(:in_files) && !obj.in_files.empty?
133
- obj.in_files.first
134
- else
135
- obj.file
136
- end
137
-
138
- file = file.to_s.sub(/^file /, '') unless file.nil?
139
- [file, obj.line]
140
- end
141
- end
142
- end
143
- end
@@ -1,43 +0,0 @@
1
- module Solargraph
2
- class YardMap
3
- module StdlibFills
4
- Override = Pin::Reference::Override
5
-
6
- LIBS = {
7
- 'benchmark' => [
8
- Override.method_return('Benchmark.measure', 'Benchmark::Tms')
9
- ],
10
-
11
- 'pathname' => [
12
- Override.method_return('Pathname#join', 'Pathname'),
13
- Override.method_return('Pathname#basename', 'Pathname'),
14
- Override.method_return('Pathname#dirname', 'Pathname'),
15
- Override.method_return('Pathname#cleanpath', 'Pathname'),
16
- Override.method_return('Pathname#children', 'Array<Pathname>'),
17
- Override.method_return('Pathname#entries', 'Array<Pathname>')
18
- ],
19
-
20
- 'set' => [
21
- Override.method_return('Enumerable#to_set', 'Set'),
22
- Override.method_return('Set#add', 'self'),
23
- Override.method_return('Set#add?', 'self, nil'),
24
- Override.method_return('Set#classify', 'Hash'),
25
- Override.from_comment('Set#each', '@yieldparam_single_parameter'),
26
- ],
27
-
28
- 'tempfile' => [
29
- Override.from_comment('Tempfile.open', %(
30
- @yieldparam [Tempfile]
31
- @return [Tempfile]
32
- ))
33
- ]
34
- }.freeze
35
-
36
- # @param path [String]
37
- # @return [Array<Pin::Reference::Override>]
38
- def self.get path
39
- LIBS[path] || []
40
- end
41
- end
42
- end
43
- end
data/yardoc/2.2.2.tar.gz DELETED
Binary file