ruby_language_server 0.2.5 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +13 -0
- data/Gemfile.lock +19 -21
- data/Guardfile +16 -14
- data/Makefile +2 -2
- data/README.md +1 -0
- data/lib/ruby_language_server/code_file.rb +1 -7
- data/lib/ruby_language_server/good_cop.rb +16 -10
- data/lib/ruby_language_server/io.rb +2 -2
- data/lib/ruby_language_server/project_manager.rb +48 -13
- data/lib/ruby_language_server/scope_parser.rb +2 -2
- data/lib/ruby_language_server/server.rb +2 -1
- data/lib/ruby_language_server/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 285ad2144f635133ae96f19b46a9761a784fff11a58288e6ca260f111fbf60e1
|
4
|
+
data.tar.gz: 8627bc9f34ed97b9f86f11e73a90d71fc94f50bb936b2423534cf7e8d70ea293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fafa5f0caa4d1f712e6e0ed8fff4ba02ee47babba1f565151b8fc26905adbb36403cf29979c1a46b7683d828cbc2b1ffa21f7fcbc817b31f4e08673d680eef52
|
7
|
+
data.tar.gz: 76d6193d16b82bf7c5830625bf1bbaedec0b6acfc0305a4b413443043fdf5bc88f422c1028b84a12e105e50f3a40da5d7b9e37f4206e17d6e5c52e4146a41532
|
data/CHANGELOG.txt
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
#### 0.2.8 Sun Jun 2 16:17:04 PDT 2019
|
4
|
+
|
5
|
+
* #37 - Bundler::LockfileError: You must use Bundler 2 or greater. Thanks to Dmytro Konstantinov for the heads up
|
6
|
+
|
7
|
+
#### 0.2.7 Sun May 5 15:36:21 PDT 2019
|
8
|
+
|
9
|
+
* #34 - fix rubocop exclude paths. Thanks to Sebastian Delmont!
|
10
|
+
|
11
|
+
#### 0.2.6 Wed Feb 6 12:50:52 PST 2019
|
12
|
+
|
13
|
+
* Fixed a couple of issues with projecy root
|
14
|
+
* Main upshot: .rubocop.yml file will be found again
|
15
|
+
|
3
16
|
#### 0.2.3 Wed Jan 30 11:46:09 PST 2019
|
4
17
|
|
5
18
|
* Fixed a few bugs having to do with block variables
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby_language_server (0.2.
|
4
|
+
ruby_language_server (0.2.8)
|
5
5
|
amatch
|
6
6
|
bundler
|
7
7
|
etc
|
@@ -17,10 +17,10 @@ GEM
|
|
17
17
|
mize
|
18
18
|
tins (~> 1.0)
|
19
19
|
ast (2.4.0)
|
20
|
-
byebug (
|
20
|
+
byebug (11.0.1)
|
21
21
|
coderay (1.1.2)
|
22
22
|
etc (1.0.1)
|
23
|
-
ffi (1.
|
23
|
+
ffi (1.11.1)
|
24
24
|
formatador (0.2.5)
|
25
25
|
fuzzy_match (2.1.0)
|
26
26
|
guard (2.15.0)
|
@@ -39,8 +39,8 @@ GEM
|
|
39
39
|
guard-rubocop (1.3.0)
|
40
40
|
guard (~> 2.0)
|
41
41
|
rubocop (~> 0.20)
|
42
|
-
jaro_winkler (1.5.
|
43
|
-
json (2.
|
42
|
+
jaro_winkler (1.5.2)
|
43
|
+
json (2.2.0)
|
44
44
|
listen (3.1.5)
|
45
45
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
46
46
|
rb-inotify (~> 0.9, >= 0.9.7)
|
@@ -56,42 +56,40 @@ GEM
|
|
56
56
|
notiffany (0.1.1)
|
57
57
|
nenv (~> 0.1)
|
58
58
|
shellany (~> 0.0)
|
59
|
-
parallel (1.
|
60
|
-
parser (2.
|
59
|
+
parallel (1.17.0)
|
60
|
+
parser (2.6.3.0)
|
61
61
|
ast (~> 2.4.0)
|
62
|
-
powerpack (0.1.2)
|
63
62
|
protocol (1.0.1)
|
64
63
|
ruby_parser (~> 3.0)
|
65
64
|
pry (0.12.2)
|
66
65
|
coderay (~> 1.1.0)
|
67
66
|
method_source (~> 0.9.0)
|
68
|
-
pry-byebug (3.
|
69
|
-
byebug (~>
|
67
|
+
pry-byebug (3.7.0)
|
68
|
+
byebug (~> 11.0)
|
70
69
|
pry (~> 0.10)
|
71
70
|
rainbow (3.0.0)
|
72
71
|
rake (12.3.2)
|
73
72
|
rb-fsevent (0.10.3)
|
74
73
|
rb-inotify (0.10.0)
|
75
74
|
ffi (~> 1.0)
|
76
|
-
rubocop (0.
|
75
|
+
rubocop (0.71.0)
|
77
76
|
jaro_winkler (~> 1.5.1)
|
78
77
|
parallel (~> 1.10)
|
79
|
-
parser (>= 2.
|
80
|
-
powerpack (~> 0.1)
|
78
|
+
parser (>= 2.6)
|
81
79
|
rainbow (>= 2.2.2, < 4.0)
|
82
80
|
ruby-progressbar (~> 1.7)
|
83
|
-
unicode-display_width (
|
84
|
-
rubocop-rspec (1.
|
81
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
82
|
+
rubocop-rspec (1.33.0)
|
85
83
|
rubocop (>= 0.60.0)
|
86
|
-
ruby-progressbar (1.10.
|
84
|
+
ruby-progressbar (1.10.1)
|
87
85
|
ruby_dep (1.5.0)
|
88
|
-
ruby_parser (3.
|
86
|
+
ruby_parser (3.13.1)
|
89
87
|
sexp_processor (~> 4.9)
|
90
|
-
sexp_processor (4.
|
88
|
+
sexp_processor (4.12.0)
|
91
89
|
shellany (0.0.1)
|
92
90
|
thor (0.20.3)
|
93
|
-
tins (1.20.
|
94
|
-
unicode-display_width (1.
|
91
|
+
tins (1.20.3)
|
92
|
+
unicode-display_width (1.6.0)
|
95
93
|
|
96
94
|
PLATFORMS
|
97
95
|
ruby
|
@@ -108,4 +106,4 @@ DEPENDENCIES
|
|
108
106
|
ruby_language_server!
|
109
107
|
|
110
108
|
BUNDLED WITH
|
111
|
-
|
109
|
+
2.0.1
|
data/Guardfile
CHANGED
@@ -17,20 +17,22 @@
|
|
17
17
|
#
|
18
18
|
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
group :red_green_refactor, halt_on_fail: true do
|
21
|
+
guard :minitest, all_after_pass: true do
|
22
|
+
# with Minitest::Unit
|
23
|
+
# watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
24
|
+
# watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
25
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
27
|
+
# with Minitest::Spec
|
28
|
+
watch(%r{^spec/**/(.*)_spec\.rb$})
|
29
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
30
|
+
watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
31
|
+
end
|
31
32
|
|
32
|
-
guard :rubocop, cli: [] do
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
guard :rubocop, cli: [] do
|
34
|
+
watch('.rubocop_ruby_language_parser.yml')
|
35
|
+
watch(/.+\.rb$/)
|
36
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
37
|
+
end
|
36
38
|
end
|
data/Makefile
CHANGED
@@ -5,7 +5,7 @@ build:
|
|
5
5
|
docker build -t $(PROJECT_NAME) .
|
6
6
|
|
7
7
|
guard: build
|
8
|
-
docker run -it $(LOCAL_LINK) $(PROJECT_NAME)
|
8
|
+
docker run -it $(LOCAL_LINK) $(PROJECT_NAME) bundle exec guard
|
9
9
|
|
10
10
|
continuous_development: build
|
11
11
|
echo "You are going to want to set the ide-ruby 'Image Name' to local_ruby_language_server"
|
@@ -20,7 +20,7 @@ console: build
|
|
20
20
|
docker run -it $(LOCAL_LINK) $(PROJECT_NAME) bin/console
|
21
21
|
|
22
22
|
test: build
|
23
|
-
docker run -it $(LOCAL_LINK) $(PROJECT_NAME) rake test && rubocop
|
23
|
+
docker run -it $(LOCAL_LINK) $(PROJECT_NAME) rake test && rubocop
|
24
24
|
|
25
25
|
shell: build
|
26
26
|
docker run -it $(LOCAL_LINK) $(PROJECT_NAME) sh
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ module RubyLanguageServer
|
|
8
8
|
class CodeFile
|
9
9
|
attr_reader :uri
|
10
10
|
attr_reader :text
|
11
|
-
|
11
|
+
attr_accessor :diagnostics
|
12
12
|
|
13
13
|
def initialize(uri, text)
|
14
14
|
RubyLanguageServer.logger.debug("CodeFile initialize #{uri}")
|
@@ -106,12 +106,6 @@ module RubyLanguageServer
|
|
106
106
|
@tags
|
107
107
|
end
|
108
108
|
|
109
|
-
def diagnostics
|
110
|
-
# Maybe we should be sharing this GoodCop across instances
|
111
|
-
@good_cop ||= GoodCop.new
|
112
|
-
@good_cop.diagnostics(@text, @uri)
|
113
|
-
end
|
114
|
-
|
115
109
|
def root_scope
|
116
110
|
# RubyLanguageServer.logger.error("Asking about root_scope with #{text}")
|
117
111
|
if @refresh_root_scope
|
@@ -4,17 +4,13 @@ require 'rubocop'
|
|
4
4
|
|
5
5
|
module RubyLanguageServer
|
6
6
|
class GoodCop < RuboCop::Runner
|
7
|
-
CONFIG_PATH = '/project/.rubocop.yml'
|
8
|
-
FALLBACK_PATH = '/app/.rubocop.yml'
|
9
|
-
|
10
7
|
def initialize
|
11
8
|
@initialization_error = nil
|
12
9
|
config_store = RuboCop::ConfigStore.new
|
13
|
-
|
14
10
|
config_store.options_config = config_path
|
15
11
|
super({}, config_store)
|
16
|
-
rescue Exception =>
|
17
|
-
RubyLanguageServer.logger.error(
|
12
|
+
rescue Exception => e
|
13
|
+
RubyLanguageServer.logger.error(e)
|
18
14
|
@initialization_error = "There was an issue loading the rubocop configuration file: #{exception}. Maybe you need to add some additional gems to the ide-ruby settings?"
|
19
15
|
end
|
20
16
|
|
@@ -100,9 +96,13 @@ module RubyLanguageServer
|
|
100
96
|
private
|
101
97
|
|
102
98
|
def offenses(text, filename)
|
103
|
-
|
104
|
-
|
105
|
-
|
99
|
+
if excluded_file?(filename)
|
100
|
+
[]
|
101
|
+
else
|
102
|
+
processed_source = RuboCop::ProcessedSource.new(text, 2.4, filename)
|
103
|
+
offenses = inspect_file(processed_source)
|
104
|
+
offenses.compact.flatten
|
105
|
+
end
|
106
106
|
end
|
107
107
|
|
108
108
|
def initialization_offenses
|
@@ -123,8 +123,14 @@ module RubyLanguageServer
|
|
123
123
|
pathname = Pathname.new(my_path)
|
124
124
|
my_directory = pathname.dirname
|
125
125
|
fallback_pathname = my_directory + '../resources/fallback_rubocop.yml'
|
126
|
-
|
126
|
+
project_path = RubyLanguageServer::ProjectManager.root_path + '.rubocop.yml'
|
127
|
+
possible_config_paths = [project_path, fallback_pathname.to_s]
|
127
128
|
possible_config_paths.detect { |path| File.exist?(path) }
|
128
129
|
end
|
130
|
+
|
131
|
+
def excluded_file?(filename)
|
132
|
+
file_config = @config_store.for(filename)
|
133
|
+
file_config.file_to_exclude?(filename)
|
134
|
+
end
|
129
135
|
end
|
130
136
|
end
|
@@ -74,8 +74,8 @@ module RubyLanguageServer
|
|
74
74
|
while content.length < length + 2
|
75
75
|
begin
|
76
76
|
content += get_content(length + 2, io) # Why + 2? CRLF?
|
77
|
-
rescue Exception =>
|
78
|
-
RubyLanguageServer.logger.error
|
77
|
+
rescue Exception => e
|
78
|
+
RubyLanguageServer.logger.error e
|
79
79
|
# We have almost certainly been disconnected from the server
|
80
80
|
exit!(1)
|
81
81
|
end
|
@@ -20,13 +20,33 @@ module RubyLanguageServer
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def root_path
|
23
|
-
|
23
|
+
# I'm torn about this. Should this be set in the Server? Or is this right.
|
24
|
+
# Rather than worry too much, I'll just do this here and change it later if it feels wrong.
|
25
|
+
path = ENV['RUBY_LANGUAGE_SERVER_PROJECT_ROOT'] || @_root_path
|
26
|
+
return path if path.nil?
|
27
|
+
|
28
|
+
path.end_with?(File::SEPARATOR) ? path : "#{path}#{File::SEPARATOR}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def root_uri=(uri)
|
32
|
+
ROOT_PATH_MUTEX.synchronize do
|
33
|
+
if uri
|
34
|
+
uri = "#{uri}/" unless uri.end_with?('/')
|
35
|
+
@_root_uri = uri
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def root_uri
|
41
|
+
@_root_uri || "file://#{root_path}"
|
24
42
|
end
|
25
43
|
end
|
26
44
|
|
27
|
-
def initialize(path)
|
45
|
+
def initialize(path, uri = nil)
|
28
46
|
# Should probably lock for read, but I'm feeling crazy!
|
29
47
|
self.class.root_path = path if self.class.root_path.nil?
|
48
|
+
self.class.root_uri = uri if uri
|
49
|
+
|
30
50
|
@root_uri = "file://#{path}"
|
31
51
|
# This is {uri: code_file} where content stuff is like
|
32
52
|
@uri_code_file_hash = {}
|
@@ -54,12 +74,6 @@ module RubyLanguageServer
|
|
54
74
|
code_file&.text || ''
|
55
75
|
end
|
56
76
|
|
57
|
-
def code_file_for_uri(uri, text = nil)
|
58
|
-
code_file = @uri_code_file_hash[uri]
|
59
|
-
code_file = @uri_code_file_hash[uri] = CodeFile.new(uri, text) if code_file.nil?
|
60
|
-
code_file
|
61
|
-
end
|
62
|
-
|
63
77
|
def tags_for_uri(uri)
|
64
78
|
code_file = code_file_for_uri(uri)
|
65
79
|
return {} if code_file.nil?
|
@@ -170,28 +184,37 @@ module RubyLanguageServer
|
|
170
184
|
# }
|
171
185
|
|
172
186
|
def scan_all_project_files
|
173
|
-
project_ruby_files = Dir.glob(
|
174
|
-
RubyLanguageServer.logger.debug("scan_all_project_files: #{project_ruby_files * ','}")
|
187
|
+
project_ruby_files = Dir.glob("#{self.class.root_path}**/*.rb")
|
175
188
|
Thread.new do
|
176
189
|
project_ruby_files.each do |container_path|
|
177
190
|
text = File.read(container_path)
|
178
|
-
relative_path = container_path.delete_prefix(
|
191
|
+
relative_path = container_path.delete_prefix(self.class.root_path)
|
179
192
|
host_uri = @root_uri + relative_path
|
180
193
|
update_document_content(host_uri, text)
|
181
194
|
end
|
182
195
|
end
|
183
196
|
end
|
184
197
|
|
198
|
+
# returns diagnostic info (if possible)
|
185
199
|
def update_document_content(uri, text)
|
186
200
|
@update_mutext.synchronize do
|
187
201
|
RubyLanguageServer.logger.debug("update_document_content: #{uri}")
|
188
202
|
# RubyLanguageServer.logger.error("@root_path: #{@root_path}")
|
189
|
-
code_file = code_file_for_uri(uri
|
203
|
+
code_file = code_file_for_uri(uri)
|
204
|
+
return code_file.diagnostics if code_file.text == text
|
205
|
+
|
190
206
|
code_file.text = text
|
191
|
-
diagnostics_ready? ? code_file
|
207
|
+
diagnostics_ready? ? updated_diagnostics_for_codefile(code_file) : []
|
192
208
|
end
|
193
209
|
end
|
194
210
|
|
211
|
+
def updated_diagnostics_for_codefile(code_file)
|
212
|
+
# Maybe we should be sharing this GoodCop across instances
|
213
|
+
@good_cop ||= GoodCop.new
|
214
|
+
project_relative_filename = filename_relative_to_project(code_file.uri)
|
215
|
+
code_file.diagnostics = @good_cop.diagnostics(code_file.text, project_relative_filename)
|
216
|
+
end
|
217
|
+
|
195
218
|
# Returns the context of what is being typed in the given line
|
196
219
|
def context_at_location(uri, position)
|
197
220
|
code_file = code_file_for_uri(uri)
|
@@ -240,5 +263,17 @@ module RubyLanguageServer
|
|
240
263
|
end
|
241
264
|
return_array
|
242
265
|
end
|
266
|
+
|
267
|
+
private
|
268
|
+
|
269
|
+
def code_file_for_uri(uri)
|
270
|
+
code_file = @uri_code_file_hash[uri]
|
271
|
+
code_file = @uri_code_file_hash[uri] = CodeFile.new(uri, nil) if code_file.nil?
|
272
|
+
code_file
|
273
|
+
end
|
274
|
+
|
275
|
+
def filename_relative_to_project(filename)
|
276
|
+
filename.gsub(self.class.root_uri, self.class.root_path)
|
277
|
+
end
|
243
278
|
end
|
244
279
|
end
|
@@ -345,8 +345,8 @@ module RubyLanguageServer
|
|
345
345
|
text ||= '' # empty is the same as nil - but it doesn't crash
|
346
346
|
begin
|
347
347
|
sexp = self.class.sexp(text)
|
348
|
-
rescue TypeError =>
|
349
|
-
RubyLanguageServer.logger.error("Exception in sexp: #{
|
348
|
+
rescue TypeError => e
|
349
|
+
RubyLanguageServer.logger.error("Exception in sexp: #{e} for text: #{text}")
|
350
350
|
end
|
351
351
|
processor = SEXPProcessor.new(sexp, text.split("\n").length)
|
352
352
|
@root_scope = processor.root_scope
|
@@ -10,7 +10,8 @@ module RubyLanguageServer
|
|
10
10
|
def on_initialize(params)
|
11
11
|
RubyLanguageServer.logger.info("on_initialize: #{params}")
|
12
12
|
root_path = params['rootPath']
|
13
|
-
|
13
|
+
root_uri = params['rootUri']
|
14
|
+
@project_manager = ProjectManager.new(root_path, root_uri)
|
14
15
|
gem_string = ENV.fetch('ADDITIONAL_GEMS') {}
|
15
16
|
gem_array = (gem_string.split(',').compact.map(&:strip).reject { |string| string == '' } if gem_string && !gem_string.empty?)
|
16
17
|
@project_manager.install_additional_gems(gem_array)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_language_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurt Werle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02
|
11
|
+
date: 2019-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
287
287
|
- !ruby/object:Gem::Version
|
288
288
|
version: '0'
|
289
289
|
requirements: []
|
290
|
-
rubygems_version: 3.0.
|
290
|
+
rubygems_version: 3.0.3
|
291
291
|
signing_key:
|
292
292
|
specification_version: 4
|
293
293
|
summary: Provide a language server implementation for ruby in ruby.
|