ruby_language_server 0.2.2 → 0.2.4

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: 7b2dfa5417b83c47771e2d76120a05b8ed6362154172c26fb62aeb8d191a8a4b
4
- data.tar.gz: 4b2e5af2ae686e6c32bd879f943f09dfaf60b28b7bb41de6da08b6005074473f
3
+ metadata.gz: 60974ac65c0aacc79f9908f9f5afc5dff607ec21122904782f5479a5b266b63a
4
+ data.tar.gz: cc93e7a695b0dd2d0fae15f9d40d54c7307b388e367773598a1ceb78892bd137
5
5
  SHA512:
6
- metadata.gz: 91a449cc1d66ed119916fb8128bc7138121df3be540fb41ffeadb95e81d74d9bd27fc784bff45e091bbeb76763fc0cd3a8ce3071070a88eaccc9074041081490
7
- data.tar.gz: 6a649291988104f65aaf6f24c61cbf4f24ad98e1223c00a4e0198e62360f06135d1569a4ecbcb52e481992866758b30c890f306f0ed3f86432881080b65dbd70
6
+ metadata.gz: 35be0584ef0e925aa4cbca2edcd82e015cf19012b969fad1cb1ecd628789ba3e6ca1e0c92991acd934574dc2d33e054141b49bcb73935d0068ed4216d2a58a57
7
+ data.tar.gz: e86ebb35b637cf6f49894e42720b7e4d46a2f4ec6f126faabe8ae045d9a46838cc3444f5b13c202910f0bfe45b4b836f3d088ec24c915098383797441a07ca04
data/CHANGELOG.txt CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ #### 0.2.3 Wed Jan 30 11:46:09 PST 2019
4
+
5
+ * Fixed a few bugs having to do with block variables
6
+ * More tests
7
+
3
8
  #### 0.2.1 Wed Jan 30 11:46:09 PST 2019
4
9
 
5
10
  * Convert to Gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_language_server (0.2.2)
4
+ ruby_language_server (0.2.4)
5
5
  amatch
6
6
  bundler
7
7
  etc
data/Guardfile CHANGED
@@ -29,7 +29,7 @@ guard :minitest, all_after_pass: true do
29
29
  watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
30
30
  end
31
31
 
32
- guard :rubocop, cli: ['-c', '.rubocop_ruby_language_parser.yml'] do
32
+ guard :rubocop, cli: [] do
33
33
  watch('.rubocop_ruby_language_parser.yml')
34
34
  watch(/.+\.rb$/)
35
35
  watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
@@ -0,0 +1 @@
1
+ # This is a blank rubocop file just to have a handle to make rubocop happy
@@ -10,12 +10,8 @@ module RubyLanguageServer
10
10
  def initialize
11
11
  @initialization_error = nil
12
12
  config_store = RuboCop::ConfigStore.new
13
- config_store.options_config =
14
- if File.exist?(CONFIG_PATH)
15
- CONFIG_PATH
16
- else
17
- FALLBACK_PATH
18
- end
13
+
14
+ config_store.options_config = config_path
19
15
  super({}, config_store)
20
16
  rescue Exception => exception
21
17
  RubyLanguageServer.logger.error(exception)
@@ -79,7 +75,7 @@ module RubyLanguageServer
79
75
  when 'refactor', 'convention'
80
76
  3
81
77
  else
82
- RubyLanguageServer.logger.warn("Could not map severity for #{severity} - returning 2")
78
+ RubyLanguageServer.logger.error("Could not map severity for #{severity} - returning 2")
83
79
  2
84
80
  end
85
81
  end
@@ -121,5 +117,14 @@ module RubyLanguageServer
121
117
  }
122
118
  ]
123
119
  end
120
+
121
+ def config_path
122
+ my_path = __FILE__
123
+ pathname = Pathname.new(my_path)
124
+ my_directory = pathname.dirname
125
+ fallback_pathname = my_directory + '../resources/fallback_rubocop.yml'
126
+ possible_config_paths = [RubyLanguageServer::ProjectManager.root_path, fallback_pathname.to_s]
127
+ possible_config_paths.detect { |path| File.exist?(path) }
128
+ end
124
129
  end
125
130
  end
@@ -8,9 +8,26 @@ module RubyLanguageServer
8
8
  class ProjectManager
9
9
  attr_reader :uri_code_file_hash
10
10
 
11
- def initialize(uri)
12
- @root_path = uri
13
- @root_uri = "file://#{@root_path}"
11
+ # GoodCop wants to know where to find its config. So here we are.
12
+ ROOT_PATH_MUTEX = Mutex.new
13
+ @_root_path = nil
14
+
15
+ class << self
16
+ def root_path=(path)
17
+ ROOT_PATH_MUTEX.synchronize do
18
+ @_root_path = path
19
+ end
20
+ end
21
+
22
+ def root_path
23
+ @_root_path
24
+ end
25
+ end
26
+
27
+ def initialize(path)
28
+ # Should probably lock for read, but I'm feeling crazy!
29
+ self.class.root_path = path if self.class.root_path.nil?
30
+ @root_uri = "file://#{path}"
14
31
  # This is {uri: code_file} where content stuff is like
15
32
  @uri_code_file_hash = {}
16
33
  @update_mutext = Mutex.new
@@ -14,12 +14,7 @@ module RubyLanguageServer
14
14
  @column = column
15
15
  @full_name = [scope.full_name, @name].join(JoinHash[TYPE_VARIABLE])
16
16
  @type = type
17
- # rubocop:disable Style/GuardClause
18
- unless @name.instance_of? String
19
- RubyLanguageServer.logger.error("@name is not a string! #{self}, #{scope.inspect}")
20
- @name = @name.to_s
21
- end
22
- # rubocop:enable Style/GuardClause
17
+ raise "bogus variable #{inspect}" unless @name.instance_of? String
23
18
  end
24
19
 
25
20
  def constant?
@@ -130,10 +130,6 @@ module RubyLanguageServer
130
130
  end
131
131
 
132
132
  def on_block_var(args, rest)
133
- (_, ((_, name, (line, column)))) = args
134
- add_variable(name, line, column)
135
- # blocks don't declare their first line in the parser
136
- current_scope.top_line ||= line
137
133
  process(args)
138
134
  process(rest)
139
135
  end
@@ -157,7 +153,14 @@ module RubyLanguageServer
157
153
  # def self.something(par)...
158
154
  # [:var_ref, [:@kw, "self", [28, 14]]], [[:@period, ".", [28, 18]], [:@ident, "something", [28, 19]], [:paren, [:params, [[:@ident, "par", [28, 23]]], nil, nil, nil, nil, nil, nil]], [:bodystmt, [[:assign, [:var_field, [:@ident, "pax", [29, 12]]], [:var_ref, [:@ident, "par", [29, 18]]]]], nil, nil, nil]]
159
155
  def on_defs(args, rest)
160
- on_def(rest[1], rest[2]) if args[1][1] == 'self' && rest[0][1] == '.'
156
+ on_def(rest[1], rest[2..-1]) if args[1][1] == 'self' && rest[0][1] == '.'
157
+ end
158
+
159
+ # Multiple left hand side
160
+ # (foo, bar) = somethingg...
161
+ def on_mlhs(args, rest)
162
+ process(args)
163
+ process(rest)
161
164
  end
162
165
 
163
166
  # ident is something that gets processed at parameters to a function or block
@@ -266,6 +269,8 @@ module RubyLanguageServer
266
269
 
267
270
  def add_variable(name, line, column, scope = @current_scope)
268
271
  new_variable = ScopeData::Variable.new(scope, name, line, column)
272
+ # blocks don't declare their first line in the parser
273
+ scope.top_line ||= line
269
274
  scope.variables << new_variable unless scope.has_variable_or_constant?(new_variable)
270
275
  end
271
276
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLanguageServer
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.4'
5
5
  end
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.2
4
+ version: 0.2.4
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-01-30 00:00:00.000000000 Z
11
+ date: 2019-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -242,6 +242,7 @@ files:
242
242
  - bin/console
243
243
  - bin/setup
244
244
  - exe/ruby_language_server
245
+ - lib/resources/fallback_rubocop.yml
245
246
  - lib/ruby_language_server.rb
246
247
  - lib/ruby_language_server/code_file.rb
247
248
  - lib/ruby_language_server/completion.rb