language_server 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/CHANGELOG.md +4 -0
- data/Guardfile +9 -0
- data/README.md +8 -0
- data/bin/_guard-core +17 -0
- data/bin/guard +17 -0
- data/bin/setup +0 -2
- data/language_server.gemspec +4 -0
- data/lib/language_server/linter/rubocop.rb +55 -0
- data/lib/language_server/version.rb +1 -1
- data/lib/language_server.rb +3 -1
- metadata +63 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eea2a987076e6db2c0d04467487fbe2e23af67ca
|
4
|
+
data.tar.gz: a171c9796c6cb96bc70175728d19f2ff093928e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 456d5911f25822d1fc2ffc270b4ea979a34aacb9fa79f283a7298f2647581032857242ce9e33afe6af2af8695fda533e2c93747c83fc378b12b1fb7bfdcf0124
|
7
|
+
data.tar.gz: 39a4b4ab6984d4d55d6de26d480817d3eaab800d04c06389242e61bbd574bf514da8fec3f8ef3ea53b6ecf4177cb1947cb0dceaa6565d3c08808669f5d61c95b
|
data/.dockerignore
ADDED
data/CHANGELOG.md
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# More info at https://github.com/guard/guard#readme
|
2
|
+
|
3
|
+
guard :minitest, all_after_pass: true do
|
4
|
+
# with Minitest::Unit
|
5
|
+
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
6
|
+
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
7
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
8
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
9
|
+
end
|
data/README.md
CHANGED
@@ -56,10 +56,18 @@ https://docs.docker.com/engine/installation
|
|
56
56
|
|
57
57
|
### Run test
|
58
58
|
|
59
|
+
You can run test via m:
|
60
|
+
|
59
61
|
$ docker-compose run app bin/m
|
60
62
|
$ docker-compose run ruby-2-3 bin/m
|
61
63
|
$ docker-compose run ruby-2-2 bin/m
|
62
64
|
|
65
|
+
Or run via guard:
|
66
|
+
|
67
|
+
$ docker-compose run app bin/guard
|
68
|
+
$ docker-compose run ruby-2-3 bin/guard
|
69
|
+
$ docker-compose run ruby-2-2 bin/guard
|
70
|
+
|
63
71
|
## Contributing
|
64
72
|
|
65
73
|
Bug reports and pull requests are welcome on GitHub at https://github.com/mtsmfm/language_server-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/bin/_guard-core
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application '_guard-core' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("guard", "_guard-core")
|
data/bin/guard
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'guard' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("guard", "guard")
|
data/bin/setup
CHANGED
data/language_server.gemspec
CHANGED
@@ -31,9 +31,13 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "bundler", "~> 1.14"
|
32
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
33
33
|
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
+
spec.add_development_dependency "guard"
|
35
|
+
spec.add_development_dependency "guard-minitest"
|
36
|
+
spec.add_development_dependency "minitest-color"
|
34
37
|
spec.add_development_dependency "pry-byebug"
|
35
38
|
spec.add_development_dependency "minitest-power_assert"
|
36
39
|
spec.add_development_dependency "m"
|
37
40
|
spec.add_development_dependency "awesome_print"
|
38
41
|
spec.add_development_dependency "benchmark-ips"
|
42
|
+
spec.add_development_dependency "rubocop"
|
39
43
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
begin
|
2
|
+
require 'rubocop'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
module LanguageServer
|
7
|
+
module Linter
|
8
|
+
class Rubocop
|
9
|
+
def initialize(source, config_path="")
|
10
|
+
@source = source
|
11
|
+
@config_path = config_path
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def call
|
16
|
+
return [] unless defined? ::RuboCop
|
17
|
+
args = []
|
18
|
+
args += ["--config", @config_path] if @config_path != ''
|
19
|
+
args += ["--format", "json","--stdin", "lsp_buffer.rb"]
|
20
|
+
o = nil
|
21
|
+
begin
|
22
|
+
$stdin = StringIO.new(@source)
|
23
|
+
$stdout = StringIO.new
|
24
|
+
config_store = ::RuboCop::ConfigStore.new
|
25
|
+
options, paths = ::RuboCop::Options.new.parse(args)
|
26
|
+
config_store.options_config = options[:config] if options[:config]
|
27
|
+
runner = ::RuboCop::Runner.new(options, config_store)
|
28
|
+
runner.run(paths)
|
29
|
+
o = $stdout.string
|
30
|
+
ensure
|
31
|
+
$stdin = STDIN
|
32
|
+
$stdout = STDOUT
|
33
|
+
end
|
34
|
+
return [] unless o
|
35
|
+
JSON
|
36
|
+
.parse(o)['files'].map { |v| v['offenses'] }
|
37
|
+
.flatten
|
38
|
+
.map { |v| Error.new(line_num: v['location']['line'].to_i - 1, message: v['message'], type: convert_type(v['severity'])) }
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def convert_type(type)
|
44
|
+
case type
|
45
|
+
when 'refactor' then 'warning'
|
46
|
+
when 'convention' then 'warning'
|
47
|
+
when 'warning' then 'warning'
|
48
|
+
when 'error' then 'error'
|
49
|
+
when 'fatal' then 'error'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/language_server.rb
CHANGED
@@ -2,6 +2,7 @@ require "language_server/version"
|
|
2
2
|
require "language_server/logger"
|
3
3
|
require "language_server/protocol"
|
4
4
|
require "language_server/linter/ruby_wc"
|
5
|
+
require "language_server/linter/rubocop"
|
5
6
|
require "language_server/completion_provider/rcodetools"
|
6
7
|
require "language_server/completion_provider/ad_hoc"
|
7
8
|
require "language_server/definition_provider/ad_hoc"
|
@@ -93,8 +94,9 @@ module LanguageServer
|
|
93
94
|
text = request[:params][:contentChanges][0][:text]
|
94
95
|
file_store.cache(uri, text)
|
95
96
|
project.recalculate_result(uri)
|
97
|
+
diagnostics = (Linter::Rubocop.new(text).call + Linter::RubyWC.new(text).call).flatten
|
96
98
|
|
97
|
-
diagnostics =
|
99
|
+
diagnostics = diagnostics.map do |error|
|
98
100
|
Protocol::Interface::Diagnostic.new(
|
99
101
|
message: error.message,
|
100
102
|
severity: error.warning? ? Protocol::Constant::DiagnosticSeverity::WARNING : Protocol::Constant::DiagnosticSeverity::ERROR,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: language_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fumiaki MATSUSHIMA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rcodetools
|
@@ -80,6 +80,48 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest-color
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
126
|
name: pry-byebug
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +192,20 @@ dependencies:
|
|
150
192
|
- - ">="
|
151
193
|
- !ruby/object:Gem::Version
|
152
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
153
209
|
description: A Ruby Language Server implementation
|
154
210
|
email:
|
155
211
|
- mtsmfm@gmail.com
|
@@ -158,6 +214,7 @@ executables:
|
|
158
214
|
extensions: []
|
159
215
|
extra_rdoc_files: []
|
160
216
|
files:
|
217
|
+
- ".dockerignore"
|
161
218
|
- ".gitignore"
|
162
219
|
- ".vscode/settings.json"
|
163
220
|
- CHANGELOG.md
|
@@ -165,11 +222,14 @@ files:
|
|
165
222
|
- Dockerfile
|
166
223
|
- Dockerfile.development
|
167
224
|
- Gemfile
|
225
|
+
- Guardfile
|
168
226
|
- LICENSE.txt
|
169
227
|
- README.md
|
170
228
|
- Rakefile
|
171
229
|
- benchmark/ruby_wc
|
230
|
+
- bin/_guard-core
|
172
231
|
- bin/console
|
232
|
+
- bin/guard
|
173
233
|
- bin/language_server-ruby
|
174
234
|
- bin/m
|
175
235
|
- bin/setup
|
@@ -184,6 +244,7 @@ files:
|
|
184
244
|
- lib/language_server/completion_provider/rcodetools.rb
|
185
245
|
- lib/language_server/definition_provider/ad_hoc.rb
|
186
246
|
- lib/language_server/file_store.rb
|
247
|
+
- lib/language_server/linter/rubocop.rb
|
187
248
|
- lib/language_server/linter/ruby_wc.rb
|
188
249
|
- lib/language_server/logger.rb
|
189
250
|
- lib/language_server/project.rb
|