solargraph 0.40.3 → 0.42.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -5
  3. data/CHANGELOG.md +34 -0
  4. data/README.md +15 -0
  5. data/SPONSORS.md +1 -0
  6. data/lib/.rubocop.yml +4 -3
  7. data/lib/solargraph.rb +8 -7
  8. data/lib/solargraph/api_map.rb +40 -111
  9. data/lib/solargraph/api_map/store.rb +5 -0
  10. data/lib/solargraph/bench.rb +13 -16
  11. data/lib/solargraph/compat.rb +15 -1
  12. data/lib/solargraph/diagnostics/rubocop.rb +10 -2
  13. data/lib/solargraph/diagnostics/rubocop_helpers.rb +18 -0
  14. data/lib/solargraph/diagnostics/type_check.rb +1 -1
  15. data/lib/solargraph/language_server/host.rb +108 -7
  16. data/lib/solargraph/language_server/host/diagnoser.rb +9 -1
  17. data/lib/solargraph/language_server/host/sources.rb +1 -1
  18. data/lib/solargraph/language_server/message/completion_item/resolve.rb +1 -0
  19. data/lib/solargraph/language_server/message/extended/environment.rb +3 -3
  20. data/lib/solargraph/language_server/message/initialize.rb +37 -35
  21. data/lib/solargraph/language_server/message/text_document/formatting.rb +28 -7
  22. data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
  23. data/lib/solargraph/library.rb +132 -22
  24. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -1
  25. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +11 -12
  26. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +1 -6
  27. data/lib/solargraph/shell.rb +5 -1
  28. data/lib/solargraph/source.rb +1 -1
  29. data/lib/solargraph/source/chain/head.rb +0 -16
  30. data/lib/solargraph/source/source_chainer.rb +1 -0
  31. data/lib/solargraph/source_map/mapper.rb +0 -5
  32. data/lib/solargraph/type_checker.rb +2 -2
  33. data/lib/solargraph/type_checker/checks.rb +4 -4
  34. data/lib/solargraph/version.rb +1 -1
  35. data/lib/solargraph/workspace.rb +1 -0
  36. data/lib/solargraph/workspace/config.rb +4 -3
  37. data/lib/solargraph/yard_map.rb +41 -39
  38. data/lib/solargraph/yard_map/core_fills.rb +1 -0
  39. data/solargraph.gemspec +1 -0
  40. metadata +16 -2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.40.3'
4
+ VERSION = '0.42.0'
5
5
  end
@@ -18,6 +18,7 @@ module Solargraph
18
18
 
19
19
  # @return [Array<String>]
20
20
  attr_reader :gemnames
21
+ alias source_gems gemnames
21
22
 
22
23
  # @param directory [String]
23
24
  # @param config [Config, nil]
@@ -170,9 +170,10 @@ module Solargraph
170
170
  # @param globs [Array<String>]
171
171
  # @return [Array<String>]
172
172
  def process_globs globs
173
- result = []
174
- globs.each do |glob|
175
- result.concat Dir[File.join directory, glob].map{ |f| f.gsub(/\\/, '/') }
173
+ result = globs.flat_map do |glob|
174
+ Dir[File.join directory, glob]
175
+ .map{ |f| f.gsub(/\\/, '/') }
176
+ .select { |f| File.file?(f) }
176
177
  end
177
178
  result
178
179
  end
@@ -20,6 +20,8 @@ module Solargraph
20
20
  autoload :Helpers, 'solargraph/yard_map/helpers'
21
21
  autoload :ToMethod, 'solargraph/yard_map/to_method'
22
22
 
23
+ include ApiMap::BundlerMethods
24
+
23
25
  CoreDocs.require_minimum
24
26
 
25
27
  def stdlib_paths
@@ -37,33 +39,16 @@ module Solargraph
37
39
  end
38
40
  end
39
41
 
40
- # @return [Array<String>]
41
- attr_reader :required
42
-
43
42
  # @return [Boolean]
44
43
  attr_writer :with_dependencies
45
44
 
46
- # A hash of gem names and the version numbers to include in the map.
47
- #
48
- # @return [Hash{String => String}]
49
- attr_reader :gemset
50
-
51
- # @param required [Array<String>]
52
- # @param gemset [Hash{String => String}]
45
+ # @param required [Array<String>, Set<String>]
46
+ # @param directory [String]
47
+ # @param source_gems [Array<String>, Set<String>]
53
48
  # @param with_dependencies [Boolean]
54
- def initialize(required: [], gemset: {}, with_dependencies: true)
55
- # HACK: YardMap needs its own copy of this array
56
- @required = required.clone
57
- # HACK: Hardcoded YAML handling
58
- @required.push 'psych' if @required.include?('yaml')
49
+ def initialize(required: [], directory: '', source_gems: [], with_dependencies: true)
59
50
  @with_dependencies = with_dependencies
60
- @gem_paths = {}
61
- @stdlib_namespaces = []
62
- @gemset = gemset
63
- @source_gems = []
64
- process_requires
65
- yardocs.uniq!
66
- @pin_select_cache = {}
51
+ change required.to_set, directory, source_gems.to_set
67
52
  end
68
53
 
69
54
  # @return [Array<Solargraph::Pin::Base>]
@@ -76,25 +61,24 @@ module Solargraph
76
61
  @with_dependencies
77
62
  end
78
63
 
79
- # @param new_requires [Array<String>]
80
- # @param new_gemset [Hash{String => String}]
64
+ # @param new_requires [Set<String>] Required paths to use for loading gems
65
+ # @param new_directory [String] The workspace directory
66
+ # @param new_source_gems [Set<String>] Gems under local development (i.e., part of the workspace)
81
67
  # @return [Boolean]
82
- def change new_requires, new_gemset, source_gems = []
68
+ def change new_requires, new_directory, new_source_gems
69
+ return false if new_requires == base_required && new_directory == @directory && new_source_gems == @source_gems
70
+ @gem_paths = {}
71
+ base_required.replace new_requires
72
+ required.replace new_requires
83
73
  # HACK: Hardcoded YAML handling
84
- new_requires.push 'psych' if new_requires.include?('yaml')
85
- if new_requires.uniq.sort == required.uniq.sort && new_gemset == gemset && @source_gems.uniq.sort == source_gems.uniq.sort
86
- false
87
- else
88
- required.clear
89
- required.concat new_requires
90
- @gemset = new_gemset
91
- @source_gems = source_gems
92
- process_requires
93
- @rebindable_method_names = nil
94
- @pin_class_hash = nil
95
- @pin_select_cache = {}
96
- true
97
- end
74
+ required.add 'psych' if new_requires.include?('yaml')
75
+ @source_gems = new_source_gems
76
+ @directory = directory
77
+ process_requires
78
+ @rebindable_method_names = nil
79
+ @pin_class_hash = nil
80
+ @pin_select_cache = {}
81
+ true
98
82
  end
99
83
 
100
84
  # @return [Set<String>]
@@ -111,6 +95,11 @@ module Solargraph
111
95
  @yardocs ||= []
112
96
  end
113
97
 
98
+ # @return [Set<String>]
99
+ def required
100
+ @required ||= Set.new
101
+ end
102
+
114
103
  # @return [Array<String>]
115
104
  def unresolved_requires
116
105
  @unresolved_requires ||= []
@@ -163,8 +152,16 @@ module Solargraph
163
152
  @stdlib_pins ||= []
164
153
  end
165
154
 
155
+ def base_required
156
+ @base_required ||= Set.new
157
+ end
158
+
166
159
  private
167
160
 
161
+ def directory
162
+ @directory ||= ''
163
+ end
164
+
168
165
  # @return [YardMap::Cache]
169
166
  def cache
170
167
  @cache ||= YardMap::Cache.new
@@ -193,6 +190,11 @@ module Solargraph
193
190
 
194
191
  # @return [void]
195
192
  def process_requires
193
+ @gemset = if required.include?('bundler/require')
194
+ require_from_bundle(directory)
195
+ else
196
+ {}
197
+ end
196
198
  pins.replace core_pins
197
199
  unresolved_requires.clear
198
200
  stdlib_pins.clear
@@ -111,6 +111,7 @@ module Solargraph
111
111
  @param y [Numeric]
112
112
  @return [Numeric]
113
113
  )),
114
+ Override.method_return('Integer#times', 'Enumerator', delete: [:overload]),
114
115
 
115
116
  Override.method_return('Kernel#puts', 'nil'),
116
117
 
data/solargraph.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency 'backport', '~> 1.1'
23
23
  s.add_runtime_dependency 'benchmark'
24
24
  s.add_runtime_dependency 'bundler', '>= 1.17.2'
25
+ s.add_runtime_dependency 'diff-lcs', '~> 1.4'
25
26
  s.add_runtime_dependency 'e2mmap'
26
27
  s.add_runtime_dependency 'jaro_winkler', '~> 1.5'
27
28
  s.add_runtime_dependency 'kramdown', '~> 2.3'
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.40.3
4
+ version: 0.42.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: 2021-02-07 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.17.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: diff-lcs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: e2mmap
57
71
  requirement: !ruby/object:Gem::Requirement