solargraph 0.40.0 → 0.40.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.md +4 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +17 -19
- data/lib/solargraph/library.rb +1 -3
- data/lib/solargraph/parser/legacy/node_methods.rb +5 -0
- data/lib/solargraph/parser/rubyvm/node_methods.rb +11 -1
- data/lib/solargraph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e02cce6c25457bb0284d221d1a9bef97730b7d7be18129cdee0dcfa1aae9c02b
|
4
|
+
data.tar.gz: 5143879ae0f89fd7ca608646cfe96fccc1e6c15afd7940fc7948dff358f286f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c868fd6c6bb344f532eeee02ef06f9b80df086b51a49e408f5c04961303524f36d6b27cfae37b200a92bf0b65e15a3e68be029aad66bf912dd1aa73b1f48714
|
7
|
+
data.tar.gz: 6a9cbcd839ab51d1c71d83a30a73464f337faffda715059e91de57a3519783793574901f23d738c83a49d1116d41268c4992fa304c08d8892e394e12bb5011c8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
|
data/lib/solargraph/library.rb
CHANGED
@@ -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
|
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
|
data/lib/solargraph/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|