ruby_language_server 0.3.7 → 0.3.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 +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/ruby_language_server/completion.rb +13 -15
- data/lib/ruby_language_server/good_cop.rb +3 -2
- data/lib/ruby_language_server/io.rb +2 -2
- data/lib/ruby_language_server/line_context.rb +3 -2
- data/lib/ruby_language_server/logger.rb +1 -1
- data/lib/ruby_language_server/project_manager.rb +4 -1
- data/lib/ruby_language_server/scope_data/scope.rb +0 -22
- data/lib/ruby_language_server/server.rb +2 -2
- data/lib/ruby_language_server/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: 87d63dcf81f034409b543e9a35073344a614e28aaa6c33ed9803f9fc130e192e
|
4
|
+
data.tar.gz: ab52a3ade63649d48adbbdcc3f03496762d514f5d6ca48b872f5272272ab80bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36791fa58a5f236d6be05e9600538065ceec7c53efb6bc2375d41120965863fcf739beada15d90ac27633b2a3859afc39a072d0bc96dc94cf5274646cdb0192
|
7
|
+
data.tar.gz: accecbb489f8f461b0c4c1d42d504f6a5339bc8af533522b02ffa6717e9e22367f05f1b42d2bd7ec23ad17f5bf800fd4f56baba1c59f2afec9db74d2fa4075ac
|
data/CHANGELOG.txt
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -52,7 +52,7 @@ Write tests and guard will run them. Make changes and reload the window. Test
|
|
52
52
|
* bump version in [version.rb](lib/ruby_language_server/version.rb) file and [Gemfile.lock](Gemfile.lock)
|
53
53
|
* [CHANGELOG.txt](CHANGELOG.txt)
|
54
54
|
* merge to master, etc
|
55
|
-
* make gem_release
|
55
|
+
* `make gem_release`
|
56
56
|
|
57
57
|
# Authors
|
58
58
|
|
@@ -28,39 +28,37 @@ module RubyLanguageServer
|
|
28
28
|
RubyLanguageServer.logger.debug("completion(#{context}, #{scopes.map(&:name)})")
|
29
29
|
completions =
|
30
30
|
if context.length < 2
|
31
|
-
scope_completions(context.
|
31
|
+
scope_completions(context.first, scopes)
|
32
32
|
else
|
33
33
|
scope_completions_in_target_context(context, context_scope, scopes)
|
34
34
|
end
|
35
|
+
RubyLanguageServer.logger.debug("completions: #{completions.as_json}")
|
35
36
|
{
|
36
37
|
isIncomplete: true,
|
37
38
|
items: completions.uniq.map do |word, hash|
|
38
39
|
{
|
39
40
|
label: word,
|
40
|
-
kind: COMPLETION_ITEM_KIND[hash[:type]]
|
41
|
+
kind: COMPLETION_ITEM_KIND[hash[:type]&.to_sym]
|
41
42
|
}
|
42
43
|
end
|
43
44
|
}
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
-
return scopes.where(name: name).first if scopes.respond_to?(:where)
|
47
|
+
private
|
48
48
|
|
49
|
-
|
49
|
+
def scopes_with_name(name, scopes)
|
50
|
+
return scopes.where(name: name) if scopes.respond_to?(:where)
|
51
|
+
|
52
|
+
scopes.select { |scope| scope.name == name }
|
50
53
|
end
|
51
54
|
|
52
55
|
def scope_completions_in_target_context(context, context_scope, scopes)
|
53
56
|
context_word = context[-2]
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
RubyLanguageServer.logger.debug("scope_with_name: #{scope}")
|
60
|
-
end
|
61
|
-
scope ||= context_scope
|
62
|
-
RubyLanguageServer.logger.debug("scope: #{scope.to_json}")
|
63
|
-
scope_completions(context.last, [scope] + scopes.includes(:variables))
|
57
|
+
context_word = context_word.split(/_/).map(&:capitalize).join('') unless context_word.match?(/^[A-Z]/)
|
58
|
+
context_scopes = scopes_with_name(context_word, scopes)
|
59
|
+
context_scopes ||= context_scope
|
60
|
+
RubyLanguageServer.logger.debug("context_scopes: #{context_scopes.to_json}")
|
61
|
+
scope_completions(context.last, Array(context_scopes) + scopes.includes(:variables))
|
64
62
|
end
|
65
63
|
|
66
64
|
def scope_completions(word, scopes)
|
@@ -8,6 +8,7 @@ module RubyLanguageServer
|
|
8
8
|
@initialization_error = nil
|
9
9
|
config_store = RuboCop::ConfigStore.new
|
10
10
|
config_store.options_config = config_path
|
11
|
+
RubyLanguageServer.logger.debug("Rubocop config_path: #{config_path}")
|
11
12
|
super({}, config_store)
|
12
13
|
rescue Exception => e
|
13
14
|
RubyLanguageServer.logger.error(e)
|
@@ -79,7 +80,7 @@ module RubyLanguageServer
|
|
79
80
|
def diagnostics(text, filename = nil)
|
80
81
|
return initialization_offenses unless @initialization_error.nil?
|
81
82
|
|
82
|
-
maximum_severity = (ENV['LINT_LEVEL'] || 4).to_i
|
83
|
+
maximum_severity = 4 # (ENV['LINT_LEVEL'] || 4).to_i
|
83
84
|
enabled_offenses = offenses(text, filename).reject { |offense| offense.status == :disabled }
|
84
85
|
enabled_offenses.map do |offense|
|
85
86
|
{
|
@@ -99,7 +100,7 @@ module RubyLanguageServer
|
|
99
100
|
if excluded_file?(filename)
|
100
101
|
[]
|
101
102
|
else
|
102
|
-
processed_source = RuboCop::ProcessedSource.new(text, 2.
|
103
|
+
processed_source = RuboCop::ProcessedSource.new(text, 2.7, filename)
|
103
104
|
offenses = inspect_file(processed_source)
|
104
105
|
offenses.compact.flatten
|
105
106
|
end
|
@@ -28,7 +28,7 @@ module RubyLanguageServer
|
|
28
28
|
result: response
|
29
29
|
}
|
30
30
|
response_body = JSON.unparse(full_response)
|
31
|
-
|
31
|
+
RubyLanguageServer.logger.info "return_response body: #{response_body}"
|
32
32
|
io.write "Content-Length: #{response_body.length + 0}\r\n"
|
33
33
|
io.write "\r\n"
|
34
34
|
io.write response_body
|
@@ -42,7 +42,7 @@ module RubyLanguageServer
|
|
42
42
|
params: params
|
43
43
|
}
|
44
44
|
body = JSON.unparse(full_response)
|
45
|
-
|
45
|
+
RubyLanguageServer.logger.info "send_notification body: #{body}"
|
46
46
|
io.write "Content-Length: #{body.length + 0}\r\n"
|
47
47
|
io.write "\r\n"
|
48
48
|
io.write body
|
@@ -17,19 +17,20 @@
|
|
17
17
|
|
18
18
|
module RubyLanguageServer
|
19
19
|
module LineContext
|
20
|
+
# This will not work if the search starts on the ending ? of "method?". Bummer.
|
20
21
|
def self.for(line, position)
|
21
22
|
# Grab just the last part of the line - from the index onward
|
22
23
|
line_end = line[position..-1]
|
23
24
|
return nil if line_end.nil?
|
24
25
|
|
25
26
|
# Grab the portion of the word that starts at the position toward the end of the line
|
26
|
-
match = line_end.partition(/^(@{0,2}\w
|
27
|
+
match = line_end.partition(/^(@{0,2}\w+\??)/)[1]
|
27
28
|
RubyLanguageServer.logger.debug("match: #{match}")
|
28
29
|
# Get the start of the line to the end of the matched word
|
29
30
|
line_start = line[0..(position + match.length - 1)]
|
30
31
|
RubyLanguageServer.logger.debug("line_start: #{line_start}")
|
31
32
|
# Match as much as we can to the end of the line - which is now the end of the word
|
32
|
-
end_match = line_start.partition(/(@{0,2}[:&\.\w]
|
33
|
+
end_match = line_start.partition(/(@{0,2}[:&\.\w]+\??)$/)[1]
|
33
34
|
matches = end_match.split('&.', -1)
|
34
35
|
matches = matches.map { |m| m.length.positive? ? m.split('.', -1) : m }.flatten
|
35
36
|
matches = matches.map { |m| m.length.positive? ? m.split('::', -1) : m }.flatten
|
@@ -185,7 +185,7 @@ module RubyLanguageServer
|
|
185
185
|
def scan_all_project_files(mutex)
|
186
186
|
project_ruby_files = Dir.glob("#{self.class.root_path}**/*.rb")
|
187
187
|
Thread.new do
|
188
|
-
RubyLanguageServer.logger.
|
188
|
+
RubyLanguageServer.logger.debug('Threading up!')
|
189
189
|
root_uri = @root_uri
|
190
190
|
root_uri += '/' unless root_uri.end_with? '/'
|
191
191
|
project_ruby_files.each do |container_path|
|
@@ -219,9 +219,12 @@ module RubyLanguageServer
|
|
219
219
|
|
220
220
|
def updated_diagnostics_for_codefile(code_file)
|
221
221
|
# Maybe we should be sharing this GoodCop across instances
|
222
|
+
RubyLanguageServer.logger.debug("updated_diagnostics_for_codefile: #{code_file.uri}")
|
222
223
|
@good_cop ||= GoodCop.new
|
223
224
|
project_relative_filename = filename_relative_to_project(code_file.uri)
|
224
225
|
code_file.diagnostics = @good_cop.diagnostics(code_file.text, project_relative_filename)
|
226
|
+
RubyLanguageServer.logger.debug("code_file.diagnostics: #{code_file.diagnostics}")
|
227
|
+
code_file.diagnostics
|
225
228
|
end
|
226
229
|
|
227
230
|
# Returns the context of what is being typed in the given line
|
@@ -44,16 +44,6 @@ module RubyLanguageServer
|
|
44
44
|
scope_parts.count
|
45
45
|
end
|
46
46
|
|
47
|
-
# Return the deepest child scopes of this scope - and on up.
|
48
|
-
# Not done recuresively because we don't really need to.
|
49
|
-
# Normally called on a root scope.
|
50
|
-
# def scopes_at(position)
|
51
|
-
# line = position.line
|
52
|
-
# matching_scopes = self_and_descendants.where('top_line <= ?', line).where('bottom_line >= ?', line)
|
53
|
-
# deepest_scope = matching_scopes.max_by(&:depth)
|
54
|
-
# deepest_scope&.self_and_ancestors || []
|
55
|
-
# end
|
56
|
-
|
57
47
|
# Self and all descendents flattened into array
|
58
48
|
def self_and_descendants
|
59
49
|
return Scope.all if root_scope?
|
@@ -65,18 +55,6 @@ module RubyLanguageServer
|
|
65
55
|
Scope.where('path like ?', "#{path}_%")
|
66
56
|
end
|
67
57
|
|
68
|
-
# [self, parent, parent.parent...]
|
69
|
-
# def self_and_ancestors
|
70
|
-
# return [self] if path.blank?
|
71
|
-
# remaining_path = path.dup
|
72
|
-
# ancestor_paths = scope_parts.inject([]) do |ary, scope_part|
|
73
|
-
# ary << remaining_path
|
74
|
-
# remaining_path =
|
75
|
-
# ary
|
76
|
-
# end
|
77
|
-
# [self, parent&.self_and_ancestors].flatten.compact
|
78
|
-
# end
|
79
|
-
|
80
58
|
def set_superclass_name(partial)
|
81
59
|
if partial.start_with?('::')
|
82
60
|
self.superclass_name = partial.gsub(/^::/, '')
|
@@ -50,7 +50,7 @@ module RubyLanguageServer
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def on_initialized(_hash)
|
53
|
-
RubyLanguageServer.logger.
|
53
|
+
RubyLanguageServer.logger.info("RubyLanguageServer::VERSION #{RubyLanguageServer::VERSION}")
|
54
54
|
end
|
55
55
|
|
56
56
|
def on_workspace_didChangeWatchedFiles(params)
|
@@ -109,7 +109,7 @@ module RubyLanguageServer
|
|
109
109
|
uri = uri_from_params(params)
|
110
110
|
position = postition_from_params(params)
|
111
111
|
completions = @project_manager.completion_at(uri, position)
|
112
|
-
|
112
|
+
RubyLanguageServer.logger.debug("completions: #{completions}")
|
113
113
|
completions
|
114
114
|
end
|
115
115
|
|
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.3.
|
4
|
+
version: 0.3.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: 2020-01-
|
11
|
+
date: 2020-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|