solargraph 0.40.0 → 0.40.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 114793e89d26f6afb191184519f707ddad0563f5815a52f85cd7728dc10c6a0c
4
- data.tar.gz: 7e6a553bfeba840d1595a296d272cac316e5db6c382afeaf02802d86f3110e00
3
+ metadata.gz: e02cce6c25457bb0284d221d1a9bef97730b7d7be18129cdee0dcfa1aae9c02b
4
+ data.tar.gz: 5143879ae0f89fd7ca608646cfe96fccc1e6c15afd7940fc7948dff358f286f3
5
5
  SHA512:
6
- metadata.gz: b3d198065d425b885851210c894e5934cce862ad57464fea9f56271f52404d0770957e0b5f40bc9b98058e7255de24454b28f07f9dee73da459ebe236a3c70d4
7
- data.tar.gz: 5071313301cfa44cd4983fd437b9a4f5ba5d6ac70ee393b4539c47261ab0830ed342925010db9edf91898165026d1c1cc70814c2f63a3be86f91c04224e2ec29
6
+ metadata.gz: 7c868fd6c6bb344f532eeee02ef06f9b80df086b51a49e408f5c04961303524f36d6b27cfae37b200a92bf0b65e15a3e68be029aad66bf912dd1aa73b1f48714
7
+ data.tar.gz: 6a9cbcd839ab51d1c71d83a30a73464f337faffda715059e91de57a3519783793574901f23d738c83a49d1116d41268c4992fa304c08d8892e394e12bb5011c8
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.5
5
5
  - 2.6
6
6
  - 2.7
7
+ - 3.0
7
8
  - jruby-head
8
9
  matrix:
9
10
  include:
@@ -15,7 +16,7 @@ matrix:
15
16
  os: osx
16
17
  allow_failures:
17
18
  - rvm: jruby-head
18
-
19
+ - rvm: 3.0
19
20
  before_install:
20
21
  - gem update --system
21
22
  - gem install bundler
@@ -1,3 +1,7 @@
1
+ ## 0.40.1 - December 28, 2020
2
+ - Use temp directory for RuboCop formatting (#397)
3
+ - NodeMethods reads splatted hashes (#396)
4
+
1
5
  ## 0.40.0 - December 14, 2020
2
6
  - Fix alias behavior
3
7
  - Consolidate method pin classes
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rubocop'
4
4
  require 'securerandom'
5
+ require 'tmpdir'
5
6
 
6
7
  module Solargraph
7
8
  module LanguageServer
@@ -12,25 +13,22 @@ module Solargraph
12
13
 
13
14
  def process
14
15
  filename = uri_to_file(params['textDocument']['uri'])
15
- # Make the temp file in the original file's directory so RuboCop
16
- # detects the correct configuration
17
- # the .rb extension is needed for ruby file without extension, else rubocop won't format
18
- tempfile = File.join(File.dirname(filename), "_tmp_#{SecureRandom.hex(8)}_#{File.basename(filename)}.rb")
19
- rubocop_file = Diagnostics::RubocopHelpers.find_rubocop_file(filename)
20
- original = host.read_text(params['textDocument']['uri'])
21
- File.write tempfile, original
22
- begin
23
- args = ['-a', '-f', 'fi', tempfile]
24
- args.unshift('-c', fix_drive_letter(rubocop_file)) unless rubocop_file.nil?
25
- options, paths = RuboCop::Options.new.parse(args)
26
- store = RuboCop::ConfigStore.new
27
- redirect_stdout { RuboCop::Runner.new(options, store).run(paths) }
28
- result = File.read(tempfile)
29
- format original, result
30
- rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
31
- set_error(Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}")
32
- ensure
33
- File.unlink tempfile
16
+ Dir.mktmpdir do |tempdir|
17
+ tempfile = File.join(tempdir, File.basename(filename))
18
+ rubocop_file = Diagnostics::RubocopHelpers.find_rubocop_file(filename)
19
+ original = host.read_text(params['textDocument']['uri'])
20
+ File.write tempfile, original
21
+ begin
22
+ args = ['-a', '-f', 'fi', tempfile]
23
+ args.unshift('-c', fix_drive_letter(rubocop_file)) unless rubocop_file.nil?
24
+ options, paths = RuboCop::Options.new.parse(args)
25
+ store = RuboCop::ConfigStore.new
26
+ redirect_stdout { RuboCop::Runner.new(options, store).run(paths) }
27
+ result = File.read(tempfile)
28
+ format original, result
29
+ rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
30
+ set_error(Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}")
31
+ end
34
32
  end
35
33
  end
36
34
 
@@ -209,7 +209,6 @@ module Solargraph
209
209
  # @return [Array<Solargraph::Range>]
210
210
  # @todo Take a Location instead of filename/line/column
211
211
  def references_from filename, line, column, strip: false
212
- # checkout filename
213
212
  cursor = api_map.cursor_at(filename, Position.new(line, column))
214
213
  clip = api_map.clip(cursor)
215
214
  pins = clip.define
@@ -222,7 +221,7 @@ module Solargraph
222
221
  referenced = definitions_at(loc.filename, loc.range.ending.line, loc.range.ending.character)
223
222
  # HACK: The additional location comparison is necessary because
224
223
  # Clip#define can return proxies for parameter pins
225
- referenced.any?{|r| r == pin || r.location == pin.location}
224
+ referenced.any? { |r| r == pin || r.location == pin.location }
226
225
  end
227
226
  # HACK: for language clients that exclude special characters from the start of variable names
228
227
  if strip && match = cursor.word.match(/^[^a-z0-9_]+/i)
@@ -290,7 +289,6 @@ module Solargraph
290
289
  # @param filename [String]
291
290
  # @return [Array<Solargraph::Pin::Base>]
292
291
  def document_symbols filename
293
- # checkout filename
294
292
  api_map.document_symbols(filename)
295
293
  end
296
294
 
@@ -98,6 +98,7 @@ module Solargraph
98
98
 
99
99
  def convert_hash node
100
100
  return {} unless Parser.is_ast_node?(node) && node.type == :hash
101
+ return convert_hash(node.children[0].children[0]) if splatted_hash?(node)
101
102
  result = {}
102
103
  node.children.each do |pair|
103
104
  result[pair.children[0].children[0]] = Solargraph::Parser.chain(pair.children[1])
@@ -118,6 +119,10 @@ module Solargraph
118
119
  result
119
120
  end
120
121
 
122
+ def splatted_hash? node
123
+ Parser.is_ast_node?(node.children[0]) && node.children[0].type == :kwsplat
124
+ end
125
+
121
126
  # @todo Temporarily here for testing. Move to Solargraph::Parser.
122
127
  def call_nodes_from node
123
128
  return [] unless node.is_a?(::Parser::AST::Node)
@@ -90,7 +90,9 @@ module Solargraph
90
90
  end
91
91
 
92
92
  def convert_hash node
93
- return {} unless node?(node) && node.type == :HASH && node?(node.children[0])
93
+ return {} unless node?(node) && node.type == :HASH
94
+ return convert_hash(node.children[0].children[1]) if splatted_hash?(node)
95
+ return {} unless node?(node.children[0])
94
96
  result = {}
95
97
  index = 0
96
98
  until index > node.children[0].children.length - 2
@@ -103,6 +105,14 @@ module Solargraph
103
105
  result
104
106
  end
105
107
 
108
+ def splatted_hash? node
109
+ node?(node.children[0]) &&
110
+ [:ARRAY, :LIST].include?(node.children[0].type) &&
111
+ node.children[0].children[0].nil? &&
112
+ node?(node.children[0].children[1]) &&
113
+ node.children[0].children[1].type == :HASH
114
+ end
115
+
106
116
  def node? node
107
117
  node.is_a?(RubyVM::AbstractSyntaxTree::Node)
108
118
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.40.0'
4
+ VERSION = '0.40.1'
5
5
  end
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.0
4
+ version: 0.40.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-14 00:00:00.000000000 Z
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport