rsense-server 0.5.0
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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +14 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +1 -0
- data/README.md +51 -0
- data/Rakefile +9 -0
- data/bin/_rsense.rb +115 -0
- data/config/puma.rb +2 -0
- data/lib/rsense/server/code.rb +38 -0
- data/lib/rsense/server/command/completion_result.rb +11 -0
- data/lib/rsense/server/command/special_meth.rb +18 -0
- data/lib/rsense/server/command/type_inference_method.rb +24 -0
- data/lib/rsense/server/command.rb +239 -0
- data/lib/rsense/server/config.rb +70 -0
- data/lib/rsense/server/gem_path.rb +18 -0
- data/lib/rsense/server/listeners/find_definition_event_listener.rb +91 -0
- data/lib/rsense/server/listeners/where_event_listener.rb +39 -0
- data/lib/rsense/server/load_path.rb +62 -0
- data/lib/rsense/server/options.rb +85 -0
- data/lib/rsense/server/parser.rb +17 -0
- data/lib/rsense/server/path_info.rb +17 -0
- data/lib/rsense/server/project.rb +24 -0
- data/lib/rsense/server/version.rb +5 -0
- data/lib/rsense/server.rb +18 -0
- data/rsense-server.gemspec +35 -0
- data/spec/fixtures/config_fixture/.rsense +4 -0
- data/spec/fixtures/deeply/nested/thing.rb +0 -0
- data/spec/fixtures/find_def_sample.json +10 -0
- data/spec/fixtures/sample.json +10 -0
- data/spec/fixtures/test_gem/.gitignore +22 -0
- data/spec/fixtures/test_gem/Gemfile +4 -0
- data/spec/fixtures/test_gem/LICENSE.txt +22 -0
- data/spec/fixtures/test_gem/README.md +29 -0
- data/spec/fixtures/test_gem/Rakefile +2 -0
- data/spec/fixtures/test_gem/lib/sample/version.rb +3 -0
- data/spec/fixtures/test_gem/lib/sample.rb +16 -0
- data/spec/fixtures/test_gem/sample.gemspec +23 -0
- data/spec/fixtures/test_gem/test.json +10 -0
- data/spec/rsense/server/code_spec.rb +44 -0
- data/spec/rsense/server/command/special_meth_spec.rb +23 -0
- data/spec/rsense/server/command_spec.rb +108 -0
- data/spec/rsense/server/config_spec.rb +27 -0
- data/spec/rsense/server/gem_path_spec.rb +16 -0
- data/spec/rsense/server/load_path_spec.rb +63 -0
- data/spec/rsense/server/options_spec.rb +33 -0
- data/spec/rsense/server/path_info_spec.rb +11 -0
- data/spec/rsense/server/project_spec.rb +18 -0
- data/spec/rsense/server_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- data/vendor/gems/puma-2.8.2-java/COPYING +55 -0
- data/vendor/gems/puma-2.8.2-java/DEPLOYMENT.md +92 -0
- data/vendor/gems/puma-2.8.2-java/Gemfile +17 -0
- data/vendor/gems/puma-2.8.2-java/History.txt +532 -0
- data/vendor/gems/puma-2.8.2-java/LICENSE +26 -0
- data/vendor/gems/puma-2.8.2-java/Manifest.txt +68 -0
- data/vendor/gems/puma-2.8.2-java/README.md +251 -0
- data/vendor/gems/puma-2.8.2-java/Rakefile +158 -0
- data/vendor/gems/puma-2.8.2-java/bin/puma +10 -0
- data/vendor/gems/puma-2.8.2-java/bin/puma-wild +17 -0
- data/vendor/gems/puma-2.8.2-java/bin/pumactl +12 -0
- data/vendor/gems/puma-2.8.2-java/docs/config.md +0 -0
- data/vendor/gems/puma-2.8.2-java/docs/nginx.md +80 -0
- data/vendor/gems/puma-2.8.2-java/docs/signals.md +42 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/PumaHttp11Service.java +17 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/ext_help.h +15 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/extconf.rb +8 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/http11_parser.c +1225 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/http11_parser.h +64 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/http11_parser.java.rl +161 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/http11_parser.rl +146 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/http11_parser_common.rl +54 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/io_buffer.c +155 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/mini_ssl.c +195 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/org/jruby/puma/Http11.java +225 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/org/jruby/puma/Http11Parser.java +488 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/org/jruby/puma/MiniSSL.java +289 -0
- data/vendor/gems/puma-2.8.2-java/ext/puma_http11/puma_http11.c +491 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/accept_nonblock.rb +23 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/app/status.rb +59 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/binder.rb +298 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/capistrano.rb +86 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/cli.rb +587 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/client.rb +289 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/cluster.rb +389 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/compat.rb +18 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/configuration.rb +377 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/const.rb +165 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/control_cli.rb +251 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/daemon_ext.rb +25 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/delegation.rb +11 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/detect.rb +4 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/events.rb +130 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/io_buffer.rb +7 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/java_io_buffer.rb +45 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/jruby_restart.rb +83 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/minissl.rb +148 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/null_io.rb +34 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/puma_http11.jar +0 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/rack_default.rb +7 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/rack_patch.rb +45 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/reactor.rb +183 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/runner.rb +146 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/server.rb +801 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/single.rb +102 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/tcp_logger.rb +32 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/thread_pool.rb +185 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma/util.rb +9 -0
- data/vendor/gems/puma-2.8.2-java/lib/puma.rb +14 -0
- data/vendor/gems/puma-2.8.2-java/lib/rack/handler/puma.rb +66 -0
- data/vendor/gems/puma-2.8.2-java/puma.gemspec +55 -0
- data/vendor/gems/puma-2.8.2-java/test/test_app_status.rb +92 -0
- data/vendor/gems/puma-2.8.2-java/test/test_cli.rb +173 -0
- data/vendor/gems/puma-2.8.2-java/test/test_config.rb +26 -0
- data/vendor/gems/puma-2.8.2-java/test/test_http10.rb +27 -0
- data/vendor/gems/puma-2.8.2-java/test/test_http11.rb +144 -0
- data/vendor/gems/puma-2.8.2-java/test/test_integration.rb +165 -0
- data/vendor/gems/puma-2.8.2-java/test/test_iobuffer.rb +38 -0
- data/vendor/gems/puma-2.8.2-java/test/test_minissl.rb +25 -0
- data/vendor/gems/puma-2.8.2-java/test/test_null_io.rb +31 -0
- data/vendor/gems/puma-2.8.2-java/test/test_persistent.rb +238 -0
- data/vendor/gems/puma-2.8.2-java/test/test_puma_server.rb +323 -0
- data/vendor/gems/puma-2.8.2-java/test/test_rack_handler.rb +10 -0
- data/vendor/gems/puma-2.8.2-java/test/test_rack_server.rb +141 -0
- data/vendor/gems/puma-2.8.2-java/test/test_tcp_rack.rb +42 -0
- data/vendor/gems/puma-2.8.2-java/test/test_thread_pool.rb +156 -0
- data/vendor/gems/puma-2.8.2-java/test/test_unix_socket.rb +39 -0
- data/vendor/gems/puma-2.8.2-java/test/test_ws.rb +89 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/README.md +9 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/init.d/README.md +54 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/init.d/puma +332 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/init.d/run-puma +3 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/upstart/README.md +61 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/upstart/puma-manager.conf +31 -0
- data/vendor/gems/puma-2.8.2-java/tools/jungle/upstart/puma.conf +63 -0
- data/vendor/gems/puma-2.8.2-java/tools/trickletest.rb +45 -0
- metadata +389 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require "set"
|
|
2
|
+
|
|
3
|
+
module Rsense
|
|
4
|
+
module Server
|
|
5
|
+
module Listeners
|
|
6
|
+
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Rsense::Server::Listeners::FindDefinitionEventListener
|
|
12
|
+
include Java::org.cx4a.rsense::Project::EventListener
|
|
13
|
+
|
|
14
|
+
EventType = Rsense::Typing::Graph::EventListener::EventType
|
|
15
|
+
SourceLocation = Rsense::Util::SourceLocation
|
|
16
|
+
|
|
17
|
+
attr_accessor :prefix, :locations, :context
|
|
18
|
+
|
|
19
|
+
def initialize(context)
|
|
20
|
+
@context = context
|
|
21
|
+
@@counter = 0
|
|
22
|
+
@locations = Set.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def setup
|
|
26
|
+
@locations.clear
|
|
27
|
+
@prefix = Rsense::Server::Command::FIND_DEFINITION_METHOD_NAME_PREFIX + @@counter
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.counter
|
|
31
|
+
old = @@counter
|
|
32
|
+
@@counter += 1
|
|
33
|
+
return old
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def getLocations
|
|
37
|
+
@locations
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def update(event)
|
|
41
|
+
vertex = event.vertex
|
|
42
|
+
if check_vertex(vertex)
|
|
43
|
+
realName = vertex.getName().substring(@prefix.length)
|
|
44
|
+
receivers = vertex.getReceiverVertex().getTypeSet()
|
|
45
|
+
receivers.each do |receiver|
|
|
46
|
+
|
|
47
|
+
receiver_type = receiver.getMetaClass()
|
|
48
|
+
if receiver_type
|
|
49
|
+
location = nil
|
|
50
|
+
method = receiver_type.search_method(realName)
|
|
51
|
+
if method
|
|
52
|
+
@locations.add(method.getLocation) if method.getLocation
|
|
53
|
+
else
|
|
54
|
+
klass = nil
|
|
55
|
+
if receiver_type instance_of? Rsense::Ruby::MetaClass
|
|
56
|
+
metaClass = receiver_type
|
|
57
|
+
if metaClass.getAttached instance_of? Rsense::Ruby::RubyModule
|
|
58
|
+
klass = metaClass.getAttached
|
|
59
|
+
end
|
|
60
|
+
else
|
|
61
|
+
klass = @context.project.graph().getRuntime().getContext().getCurrentScope().getModule()
|
|
62
|
+
end
|
|
63
|
+
if klass
|
|
64
|
+
constant = klass.getConstant(realName)
|
|
65
|
+
if constant instance_of? Rsense::Typing::Runtime::VertexHolder
|
|
66
|
+
location = SourceLocation.of(constant.getVertex().getNode())
|
|
67
|
+
elsif constant instance_of? Rsense::Ruby::RubyModule
|
|
68
|
+
location = constant.getLocation()
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if location
|
|
74
|
+
@locations.add(location)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
vertex.cutout()
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def check_vertex(vertex)
|
|
84
|
+
if @context.main && event.type == EventType::METHOD_MISSING
|
|
85
|
+
if vertex && vertex.getName().startsWith(@prefix) && vertex.getReceiverVertex()
|
|
86
|
+
return true
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Rsense
|
|
2
|
+
module Server
|
|
3
|
+
module Listeners
|
|
4
|
+
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class Rsense::Server::Listeners::WhereEventListener
|
|
10
|
+
include Java::org.cx4a.rsense::Project::EventListener
|
|
11
|
+
|
|
12
|
+
EventType = Rsense::Typing::Graph::EventListener::EventType
|
|
13
|
+
SourceLocation = Rsense::Util::SourceLocation
|
|
14
|
+
|
|
15
|
+
attr_accessor :line, :closest, :name, :context
|
|
16
|
+
|
|
17
|
+
def initialize(context)
|
|
18
|
+
@context = context
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def prepare(line)
|
|
22
|
+
@line = line
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def update(event)
|
|
26
|
+
eligible = [ EventType::DEFINE, EventType::CLASS, EventType::MODULE ]
|
|
27
|
+
if context.main && eligible.any? {|e| event.type == e}
|
|
28
|
+
if event.name && event.node
|
|
29
|
+
loc = SourceLocation.of(event.node)
|
|
30
|
+
loc_line = loc.getLine()
|
|
31
|
+
if loc && @line >= loc_line && @line - @closest > @line - loc_line
|
|
32
|
+
@closest = loc_line
|
|
33
|
+
@name = event.name
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
|
|
3
|
+
module Rsense
|
|
4
|
+
module Server
|
|
5
|
+
module LoadPath
|
|
6
|
+
|
|
7
|
+
Dependency = Struct.new(:name, :full_name, :path)
|
|
8
|
+
|
|
9
|
+
module_function
|
|
10
|
+
def paths
|
|
11
|
+
fetch.map { |p| p unless p.to_s =~ /^file:/ }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def fetch
|
|
15
|
+
$LOAD_PATH
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def dependencies(project)
|
|
19
|
+
@gemfile = find_gemfile(project)
|
|
20
|
+
if @gemfile
|
|
21
|
+
lockfile = Bundler::LockfileParser.new(Bundler.read_file(@gemfile))
|
|
22
|
+
gem_info(lockfile)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def gem_info(lfile)
|
|
27
|
+
lfile.specs.map do |s|
|
|
28
|
+
generate_struct(s.name, s.version)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def generate_struct(name, version)
|
|
33
|
+
paths = check_version(find_paths(name), version)
|
|
34
|
+
Dependency.new(name, "#{name}-#{version.to_s}", paths)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def check_version(gem_paths, version)
|
|
38
|
+
gem_paths.select do |p|
|
|
39
|
+
p.to_s =~ /#{version}/
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def find_paths(name)
|
|
44
|
+
paths = Gem.find_files(name)
|
|
45
|
+
return paths unless paths.empty? && name.length > 1
|
|
46
|
+
find_paths(name.chop)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def find_gemfile(project)
|
|
50
|
+
pth = Pathname.new(project).expand_path
|
|
51
|
+
lockfile = Dir.glob(pth.join("**/Gemfile.lock")).first
|
|
52
|
+
unless lockfile
|
|
53
|
+
unless pth.parent == pth
|
|
54
|
+
lockfile = find_gemfile(pth.parent)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
lockfile
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
require "set"
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Rsense
|
|
6
|
+
module Server
|
|
7
|
+
class Options
|
|
8
|
+
attr_accessor :rest, :command, :location, :log, :log_level, :debug, :project_path, :name, :prefix, :config, :code, :file
|
|
9
|
+
|
|
10
|
+
def initialize(opts)
|
|
11
|
+
@rest = {}
|
|
12
|
+
@command = opts["command"] if opts["command"]
|
|
13
|
+
parse_args(opts)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def parse_args(opts)
|
|
17
|
+
opts.each_pair do |k, v|
|
|
18
|
+
if respond_to?("#{k}=")
|
|
19
|
+
__send__("#{k}=", v)
|
|
20
|
+
else
|
|
21
|
+
@rest[k] = v
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def project=(path)
|
|
27
|
+
@project_path = Pathname.new(path).expand_path
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def file=(path)
|
|
31
|
+
@file = Pathname.new(path).expand_path
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def here_doc_reader(reader)
|
|
35
|
+
Rsense::Util::HereDocReader.new(reader, "EOF")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def debug?
|
|
39
|
+
@debug
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def log_level
|
|
43
|
+
if debug?
|
|
44
|
+
Rsense::Util::Logger::Level::DEBUG
|
|
45
|
+
end
|
|
46
|
+
level = @log_level
|
|
47
|
+
if level
|
|
48
|
+
Rsense::Util::Logger::Level.valueOf(level.upcase)
|
|
49
|
+
else
|
|
50
|
+
Rsense::Util::Logger::Level::MESSAGE
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def progress
|
|
55
|
+
if @progress
|
|
56
|
+
@progress.to_i
|
|
57
|
+
else
|
|
58
|
+
0
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def inherit(parent)
|
|
63
|
+
if parent.debug?
|
|
64
|
+
@debug = true
|
|
65
|
+
end
|
|
66
|
+
@log = parent.log()
|
|
67
|
+
@log_level = parent.log_level
|
|
68
|
+
@load_path = parent.load_path
|
|
69
|
+
@gem_path = parent.gem_path
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def load_config(config)
|
|
73
|
+
path = Pathname.new(config).expand_path
|
|
74
|
+
if path.exist?
|
|
75
|
+
json = JSON.parse(path.read)
|
|
76
|
+
parse_args(json)
|
|
77
|
+
else
|
|
78
|
+
puts "Config file: #{path} does not exist"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "jruby-parser"
|
|
2
|
+
|
|
3
|
+
module Rsense
|
|
4
|
+
module Server
|
|
5
|
+
class Parser
|
|
6
|
+
include JRubyParser
|
|
7
|
+
|
|
8
|
+
def parse_string(source_string, filename='')
|
|
9
|
+
filename = filename || '(string)'
|
|
10
|
+
version = org.jrubyparser.CompatVersion::RUBY2_0
|
|
11
|
+
opts = { filename: filename, version: version }
|
|
12
|
+
parse(source_string, opts)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "filetree"
|
|
2
|
+
|
|
3
|
+
require_relative './version'
|
|
4
|
+
|
|
5
|
+
module Rsense
|
|
6
|
+
module Server
|
|
7
|
+
module PathInfo
|
|
8
|
+
|
|
9
|
+
RSENSE_SERVER_HOME = FileTree.new(File.dirname(__FILE__)).expand_path.ancestors[2]
|
|
10
|
+
|
|
11
|
+
def self.bin_path
|
|
12
|
+
RSENSE_SERVER_HOME.join("bin/_rsense.rb")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Rsense
|
|
2
|
+
module Server
|
|
3
|
+
class Project
|
|
4
|
+
attr_accessor :name, :path, :graph, :runtime, :load_path, :gem_path, :loaded, :dependencies, :stubs
|
|
5
|
+
|
|
6
|
+
def initialize(name, path)
|
|
7
|
+
@name = name
|
|
8
|
+
@path = path
|
|
9
|
+
@graph = Rsense::Typing::Graph.new
|
|
10
|
+
@runtime = @graph.getRuntime()
|
|
11
|
+
@stubs = Dir.glob(Rsense::BUILTIN.join("**/*.rb"))
|
|
12
|
+
@load_path = Rsense::Server::LoadPath.paths
|
|
13
|
+
@gem_path = Rsense::Server::GemPath.paths
|
|
14
|
+
@loaded = []
|
|
15
|
+
@dependencies = Rsense::Server::LoadPath.dependencies(@path)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def loaded?(feature)
|
|
19
|
+
@loaded.include?(feature)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
require "jruby-parser"
|
|
3
|
+
require "rsense-core"
|
|
4
|
+
require "rsense/server/version"
|
|
5
|
+
|
|
6
|
+
require_relative "server/project"
|
|
7
|
+
require_relative "server/parser"
|
|
8
|
+
require_relative "server/command"
|
|
9
|
+
require_relative "server/options"
|
|
10
|
+
require_relative "server/gem_path"
|
|
11
|
+
require_relative "server/load_path"
|
|
12
|
+
require_relative "server/code"
|
|
13
|
+
|
|
14
|
+
module Rsense
|
|
15
|
+
module Server
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'rsense/server/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "rsense-server"
|
|
8
|
+
spec.version = Rsense::Server::VERSION
|
|
9
|
+
spec.authors = ["Eric West", "Tomohiro Matsuyama"]
|
|
10
|
+
spec.email = ["esw9999@gmail.com", "tomo@cx4a.org"]
|
|
11
|
+
spec.summary = %q{RSense knows your code.}
|
|
12
|
+
spec.description = %q{rsense-server is the communications bridge between the user (or editor plugins the user is using) and the rsense library written in java.}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "GPL"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib", "vendor/gems/puma-2.8.2-java/lib/"]
|
|
20
|
+
|
|
21
|
+
spec.add_dependency "rsense-core", "~> 0.5.1"
|
|
22
|
+
spec.add_dependency "spoon", "~> 0.0.4"
|
|
23
|
+
spec.add_dependency "jruby-jars", "~> 1.7.4"
|
|
24
|
+
spec.add_dependency "jruby-parser", "~> 0.5.4"
|
|
25
|
+
spec.add_dependency "filetree", "~> 1.0.0"
|
|
26
|
+
spec.add_dependency "bundler", "~> 1.6"
|
|
27
|
+
spec.add_dependency "sinatra"
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency 'guard'
|
|
30
|
+
spec.add_development_dependency 'guard-minitest'
|
|
31
|
+
spec.add_development_dependency 'minitest-reporters'
|
|
32
|
+
spec.add_development_dependency 'minitest'
|
|
33
|
+
spec.add_development_dependency 'pry'
|
|
34
|
+
spec.add_development_dependency "rake"
|
|
35
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"command": "find_definition",
|
|
3
|
+
"project": "~/code/rsense/rsense",
|
|
4
|
+
"file": "~/code/rsense/rsense/lib/rsense.rb",
|
|
5
|
+
"code": "module TestStuff\n class TestThings\n def junk\n 'junk'\n end\n end\nend\n\nTestStuff::TestThings",
|
|
6
|
+
"location": {
|
|
7
|
+
"row": 9,
|
|
8
|
+
"column": 22
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Eric West
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Sample
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'sample'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install sample
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/sample/fork )
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create a new Pull Request
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'sample/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "sample"
|
|
8
|
+
spec.version = Sample::VERSION
|
|
9
|
+
spec.authors = ["Eric West"]
|
|
10
|
+
spec.email = ["eric.west@lonelyplanet.com"]
|
|
11
|
+
spec.summary = %q{TODO: Write a short summary. Required.}
|
|
12
|
+
spec.description = %q{TODO: Write a longer description. Optional.}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"command": "code_completion",
|
|
3
|
+
"project": "spec/fixtures/test_gem",
|
|
4
|
+
"file": "spec/fixtures/test_gem/lib/sample.rb",
|
|
5
|
+
"code": "require \"sample/version\"\n\nmodule Sample\n attr_accessor :simple\n\n def initialize\n @simple = \"simple\"\n end\n\n def another\n \"another\"\n end\nend\n\nsample = Sample.new\nsample\n",
|
|
6
|
+
"location": {
|
|
7
|
+
"row": 16,
|
|
8
|
+
"column": 7
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
require "json"
|
|
3
|
+
require_relative "../../spec_helper"
|
|
4
|
+
|
|
5
|
+
describe Rsense::Server::Code do
|
|
6
|
+
describe "type inference" do
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@json_path = Pathname.new("spec/fixtures/sample.json")
|
|
10
|
+
@json = JSON.parse(@json_path.read)
|
|
11
|
+
@code = Rsense::Server::Code.new(@json["code"])
|
|
12
|
+
@location = @json["location"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "has an array of lines" do
|
|
16
|
+
@code.lines.size.must_equal(4)
|
|
17
|
+
@code.lines.last.must_match(/hello/)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "injects the type inference marker" do
|
|
21
|
+
@code.inject_inference_marker(@location).must_match(/testarg\.__rsense_type_inference__/)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "does not duplicate the dot accessor" do
|
|
25
|
+
code = Rsense::Server::Code.new("def check(testar)\n testar.\nend\ncheck('hello')")
|
|
26
|
+
code.inject_inference_marker(@location).wont_match(/testar\.\.__rsense_type_inference__/)
|
|
27
|
+
code.inject_inference_marker(@location).must_match(/testar\.__rsense_type_inference__/)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "find definition" do
|
|
32
|
+
before do
|
|
33
|
+
@json_path = Pathname.new("spec/fixtures/find_def_sample.json")
|
|
34
|
+
@json = JSON.parse(@json_path.read)
|
|
35
|
+
@code = Rsense::Server::Code.new(@json["code"])
|
|
36
|
+
@location = @json["location"]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "injects the find definition marker" do
|
|
40
|
+
marker = "#{Rsense::Server::Code::FIND_DEFINITION_METHOD_NAME_PREFIX}0"
|
|
41
|
+
@code.inject_definition_marker(marker, @location).must_match(/__rsense_find_definition__0TestThings/)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require_relative "../../../spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Rsense::Server::Command::SpecialMeth do
|
|
4
|
+
before do
|
|
5
|
+
@spec_meth = Rsense::Server::Command::SpecialMeth.new() do |runtime, receivers, args, blcck, result|
|
|
6
|
+
{ runtime: runtime,
|
|
7
|
+
receivers: receivers,
|
|
8
|
+
args: args,
|
|
9
|
+
blcck: blcck,
|
|
10
|
+
result: result
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "calls block with args" do
|
|
16
|
+
meth_hash = @spec_meth.call("run", "rec", "args", "blcck", "result")
|
|
17
|
+
meth_hash[:runtime].must_match(/run/)
|
|
18
|
+
meth_hash[:receivers].must_match(/rec/)
|
|
19
|
+
meth_hash[:args].must_match(/args/)
|
|
20
|
+
meth_hash[:blcck].must_match(/blcck/)
|
|
21
|
+
meth_hash[:result].must_match(/result/)
|
|
22
|
+
end
|
|
23
|
+
end
|