language_server 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f539c291399eeb7ea1e033307134aa1fd8b86c5
4
- data.tar.gz: 3f5c47d75fe00323a36ddc34d426e538e3a258f5
3
+ metadata.gz: 7139ff0bb62fcf30de5f216cc102cc2e06a52f8a
4
+ data.tar.gz: '019a3200bde8868ffa962478c9a0f5347adeebdb'
5
5
  SHA512:
6
- metadata.gz: 412ff31e6c1c49cd0ef3ab42afd604e35a9c7b2d02bfe86e2422644e02a44d86f73705e3c33a081b787c1d70d1590d179e4c817ade7084ef3734112e2d734dc6
7
- data.tar.gz: b431130afd449e31ba64a233c7649974840509ca6a048d9cb686e8866487ae9cf6c3c6ff1dd9a0297efe8fd0e066df3337690266323e23e1185b44e6b0f85937
6
+ metadata.gz: dae2397674045b4c88433c9efd9d4191739f2ed0cd36f908a86aca03d634bde4f1741900539439a72c252600f89008f7149d28b24cba6fc62e4d1963c724b406
7
+ data.tar.gz: 6c49f740e25807d8856df833c297d02a42802863d1abeb2b9c5278c9968d87c69c69b7be59ef7c79a1ebbc5d14a2a6e290adc91390e196aff4b75c54ca854818
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Not released
4
4
 
5
+ ## 0.8.0
6
+
7
+ - Use RubyVM::InstructionSequence.compile instead of open3
5
8
 
6
9
  ## 0.7.0
7
10
 
data/benchmark/ruby_wc ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'benchmark/ips'
5
+ require 'language_server'
6
+
7
+ error_code = <<-EOS
8
+ require "foo
9
+ if a == "\\n"
10
+ EOS
11
+ warn_code = <<-EOS
12
+ a = 1
13
+ EOS
14
+ valid_code = File.read(__FILE__)
15
+
16
+ Benchmark.ips do |x|
17
+ x.report do
18
+ [error_code, warn_code, valid_code].each do |code|
19
+ LanguageServer::Linter::RubyWC.new(code).call
20
+ end
21
+ end
22
+ end
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "minitest-power_assert"
36
36
  spec.add_development_dependency "m"
37
37
  spec.add_development_dependency "awesome_print"
38
+ spec.add_development_dependency "benchmark-ips"
38
39
  end
@@ -1,4 +1,4 @@
1
- require "open3"
1
+ require "stringio"
2
2
 
3
3
  module LanguageServer
4
4
  module Linter
@@ -26,12 +26,55 @@ module LanguageServer
26
26
  end
27
27
 
28
28
  def call
29
- _, err, _ = Open3.capture3("ruby -wc", stdin_data: @source)
30
-
31
- err.scan(/.+:(\d+):\s*(.+?)[,:]\s(.+)/).map do |line_num, type, message|
29
+ error_message.scan(/.+:(\d+):\s*(.+?)[,:]\s(.+)/).map do |line_num, type, message|
32
30
  Error.new(line_num: line_num.to_i - 1, message: message, type: type)
33
31
  end
34
32
  end
33
+
34
+ private
35
+
36
+ # Since Ruby 2.4, syntax error information is outputted to Exception#message instead of stderr
37
+ if begin; stderr = $stderr; $stderr = StringIO.new; RubyVM::InstructionSequence.compile('='); rescue SyntaxError => e; e.message != 'compile error'; ensure; $stderr = stderr; end
38
+ def error_message
39
+ with_verbose do
40
+ begin
41
+ capture_stderr { RubyVM::InstructionSequence.compile(@source) }
42
+ rescue SyntaxError => e
43
+ e.message
44
+ end
45
+ end
46
+ end
47
+ else
48
+ def error_message
49
+ with_verbose do
50
+ capture_stderr do
51
+ begin
52
+ RubyVM::InstructionSequence.compile(@source)
53
+ rescue SyntaxError
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ def with_verbose
61
+ origin = $VERBOSE
62
+ $VERBOSE = true
63
+ yield
64
+ ensure
65
+ $VERBOSE = origin
66
+ end
67
+
68
+ def capture_stderr
69
+ origin = $stderr
70
+ $stderr = StringIO.new
71
+
72
+ yield
73
+
74
+ $stderr.string
75
+ ensure
76
+ $stderr = origin
77
+ end
35
78
  end
36
79
  end
37
80
  end
@@ -1,3 +1,3 @@
1
1
  module LanguageServer
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
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.7.0
4
+ version: 0.8.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 00:00:00.000000000 Z
11
+ date: 2017-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rcodetools
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: benchmark-ips
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: A Ruby Language Server implementation
140
154
  email:
141
155
  - mtsmfm@gmail.com
@@ -154,6 +168,7 @@ files:
154
168
  - LICENSE.txt
155
169
  - README.md
156
170
  - Rakefile
171
+ - benchmark/ruby_wc
157
172
  - bin/console
158
173
  - bin/language_server-ruby
159
174
  - bin/m