rsense-server 0.5.0 → 0.5.2

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: 8d67d9c7640d8e06647ff1f5e708b5a73a1aa28b
4
- data.tar.gz: 186fd888eefebaad271af5b2254ffd1e44dcf790
3
+ metadata.gz: 59a7e403afc05e2f67e50e7d33c8d526a7a61159
4
+ data.tar.gz: 8f0a7e59751031424ffb131f92502da089aa79da
5
5
  SHA512:
6
- metadata.gz: d06bfae8ea880c507de82e9baeb0d15251bed35c65e0e46709bf1775aea2a3258d670e109ac437bbb010cc5b7768081c0375be57022b5380f7b6145767b9021f
7
- data.tar.gz: 11a44d3575f2eb25907bdb76817434f2676fed08996c14d5dd61ceb790ed87e590d0ef638b3e72ff09ee96b596764e6280ee29a9095ad03d175ee5d2bf9178e5
6
+ metadata.gz: edff3e46860b8f24bc07895f106a34535299b10c366409bc7b89e51ef57fffe0f462233f4dae6d4e923e5677eff0b79a19684fcfcd58f2297e552a3f3ca561ad
7
+ data.tar.gz: 4017afb091033435c0a1f915af0fc2249310bcc009155fc67efe1ed07e00d5f2d4ccb98b75f65a5bb194d88fe63f795631231701afc4c93d9ed61bd9269af37b
data/bin/_rsense.rb CHANGED
@@ -45,6 +45,12 @@ end
45
45
 
46
46
  PORT = port(options)
47
47
 
48
+ class ProjectManager
49
+ attr_accessor :roptions, :rcommand, :rproject
50
+ end
51
+
52
+ PROJMAN = ProjectManager.new
53
+
48
54
  require "puma"
49
55
  require "sinatra"
50
56
  require "json"
@@ -56,52 +62,71 @@ class RsenseApp < Sinatra::Base
56
62
  set :port, PORT
57
63
 
58
64
  def setup(jsondata)
59
- if @roptions && @roptions.project_path =~ /#{jsondata["project"]}/
65
+ if PROJMAN.roptions && PROJMAN.roptions.project_path.to_s =~ /#{jsondata["project"]}/
60
66
  changed = check_options(jsondata)
61
- @rcommand.options = @roptions
67
+ return if changed && changed.empty?
68
+ PROJMAN.rcommand.options = PROJMAN.roptions
62
69
  else
63
- @roptions = Rsense::Server::Options.new(jsondata)
64
- @rcommand = Rsense::Server::Command::Command.new(@roptions)
70
+ PROJMAN.roptions = Rsense::Server::Options.new(jsondata)
71
+ PROJMAN.rcommand = Rsense::Server::Command::Command.new(PROJMAN.roptions)
65
72
  end
66
73
  end
67
74
 
68
75
  def check_options(data)
69
76
  changed = []
70
77
  data.each do |k, v|
71
- unless @roptions.send k.to_sym == v
72
- @roptions.__send__("#{k}=", v)
73
- changed << k
78
+ if PROJMAN.roptions.respond_to? k.to_sym
79
+ keyval = PROJMAN.roptions.send k.to_sym
80
+ unless keyval.to_s =~ /#{v}/
81
+ PROJMAN.roptions.__send__("#{k}=", v)
82
+ changed << k
83
+ end
74
84
  end
75
85
  end
76
86
  changed
77
87
  end
78
88
 
79
89
  def code_completion
80
- if @roptions.code
81
- candidates = @rcommand.code_completion(@roptions.file, @roptions.location, @roptions.code)
90
+ if PROJMAN.roptions.code
91
+ candidates = PROJMAN.rcommand.code_completion(PROJMAN.roptions.file, PROJMAN.roptions.location, PROJMAN.roptions.code)
82
92
  else
83
- candidates = @rcommand.code_completion(@roptions.file, @roptions.location)
93
+ candidates = PROJMAN.rcommand.code_completion(PROJMAN.roptions.file, PROJMAN.roptions.location)
84
94
  end
95
+ PROJMAN.rcommand.errors.each { |e| puts e }
85
96
  completions = candidates.map do |c|
86
- {c.completion => {
97
+ {
98
+ name: c.completion,
87
99
  qualified_name: c.qualified_name,
88
100
  base_name: c.base_name,
89
101
  kind: c.kind.to_string
90
- }}
102
+ }
91
103
  end
92
104
  { :completions => completions }
93
105
  end
94
106
 
107
+ def add_deps
108
+ Thread.new do
109
+ if PROJMAN.rcommand.placeholders.first
110
+ proj, feat = PROJMAN.rcommand.placeholders.shift
111
+ PROJMAN.rcommand.rrequire(proj, feat, true, 0)
112
+ end
113
+ end
114
+ end
115
+
95
116
  post '/' do
117
+ @serving = true
96
118
  content_type :json
97
119
  jsontext = request.body.read
98
120
  if jsontext
99
121
  data = JSON.parse(jsontext)
100
122
  setup(data)
101
- __send__(data["command"]).to_json
123
+ retdata = __send__(data["command"]).to_json
102
124
  else
103
- "No JSON was sent"
125
+ retdata = "No JSON was sent"
104
126
  end
127
+ add_deps
128
+ @serving = false
129
+ retdata
105
130
  end
106
131
 
107
132
  end
@@ -14,8 +14,11 @@ module Rsense
14
14
  column = location["column"] - 1
15
15
  lines = @lines.clone
16
16
  line = lines[row]
17
+ return lines.join("\n") unless line && line.length >= column - 1 && column > 1
17
18
  if line.slice(column - 1).end_with?(".")
18
19
  line.insert(column, TYPE_INFERENCE_METHOD_NAME)
20
+ elsif line.slice(column - 2..column - 1).end_with?("::")
21
+ line.insert(column, TYPE_INFERENCE_METHOD_NAME)
19
22
  else
20
23
  line.insert(column, ".#{TYPE_INFERENCE_METHOD_NAME}")
21
24
  end
@@ -1,9 +1,13 @@
1
1
  require "pathname"
2
+ require "pry"
2
3
  require "rsense-core"
3
4
  require_relative "./listeners/find_definition_event_listener"
4
5
  require_relative "./listeners/where_event_listener"
5
6
  require_relative "./command/special_meth"
6
7
  require_relative "./command/type_inference_method"
8
+ require_relative "./command/native_attr_method"
9
+ require_relative "./command/alias_native_method"
10
+ require_relative "./command/rsense_method"
7
11
 
8
12
  module Rsense
9
13
  module Server
@@ -15,6 +19,11 @@ module Rsense
15
19
  @feature = nil
16
20
  @loadPathLevel = 0
17
21
  end
22
+
23
+ def clean_typeSet
24
+ @typeSet = nil
25
+ @typeSet = Java::org.cx4a.rsense.typing::TypeSet.new
26
+ end
18
27
  }
19
28
  module Command
20
29
  TYPE_INFERENCE_METHOD_NAME = Rsense::CodeAssist::TYPE_INFERENCE_METHOD_NAME
@@ -33,34 +42,53 @@ class Rsense::Server::Command::Command
33
42
  :kind
34
43
  )
35
44
 
36
- attr_accessor :context, :options, :parser, :projects, :sandbox, :definitionFinder, :whereListener, :type_inference_method, :require_method, :require_next_method, :result, :graph
45
+ attr_accessor :context, :options, :parser, :projects, :sandbox, :definitionFinder, :whereListener, :type_inference_method, :require_method, :require_next_method, :result, :graph, :project, :errors, :placeholders, :require_relative_method, :ast
37
46
 
38
47
  def initialize(options)
39
48
  @context = Rsense::Server::Context.new
49
+ @context.loadPathLevel = 0
40
50
  @options = options
51
+ @errors = []
52
+ @placeholders = []
41
53
 
42
54
  @type_inference_method = Rsense::Server::Command::TypeInferenceMethod.new()
43
- @type_inference_method.context = @context
44
55
 
45
56
  @require_method = Rsense::Server::Command::SpecialMeth.new() do |runtime, receivers, args, blcck, result|
46
57
  if args
47
58
  feature = Java::org.cx4a.rsense.typing.vertex::Vertex.getString(args[0])
48
59
  if feature
49
- rrequire(@context.project, feature, "UTF-8")
60
+ rrequire(@context.project, feature, false, @context.loadPathLevel + 1)
61
+ end
62
+ end
63
+ end
64
+
65
+ @require_relative_method = Rsense::Server::Command::SpecialMeth.new() do |runtime, receivers, args, blcck, result|
66
+ if args
67
+ feature = Java::org.cx4a.rsense.typing.vertex::Vertex.getString(args[0])
68
+ if feature
69
+ files = Dir.glob(Pathname.new(args.first.node.position.file).dirname.join("#{feature}*"))
70
+ files.each do |f|
71
+ rload(project, f, "UTF-8", false)
72
+ end
50
73
  end
51
74
  end
52
75
  end
53
76
 
54
77
  @require_next_method = Rsense::Server::Command::SpecialMeth.new() do |runtime, receivers, args, blcck, result|
55
78
  if @context.feature
56
- rrequire(@context.project, @context.feature, "UTF-8", @context.loadPathLevel + 1)
79
+ rrequire(@context.project, @context.feature, false, @context.loadPathLevel + 1)
57
80
  end
58
81
  end
59
82
 
83
+ @native_attr_method = Rsense::Server::Command::NativeAttrMethod.new()
84
+
85
+ @alias_native_method = Rsense::Server::Command::AliasNativeMethod.new()
86
+
60
87
  clear()
61
88
  end
62
89
 
63
90
  def rload(project, file, encoding, prep)
91
+ file = Pathname.new(file)
64
92
  return LoadResult.alreadyLoaded() if project.loaded?(file)
65
93
  return if file.extname =~ /(\.so|\.dylib|\.dll|\.java|\.class|\.c$|\.h$|\.m$|\.js|\.html|\.css)/
66
94
  project.loaded << file
@@ -72,31 +100,53 @@ class Rsense::Server::Command::Command
72
100
  @context.main = false
73
101
  end
74
102
 
75
- ast = @parser.parse_string(file.read, file.to_s)
76
- project.graph.load(ast)
77
- result = LoadResult.new
78
- result.setAST(ast)
79
- result
103
+ begin
104
+ @ast = @parser.parse_string(file.read, file.to_s)
105
+ project.graph.load(@ast)
106
+ result = LoadResult.new
107
+ result.setAST(@ast)
108
+ result
109
+ rescue Java::OrgJrubyparserLexer::SyntaxException => e
110
+ @errors << e
111
+ end
80
112
  end
81
113
 
82
- def rrequire(project, feature, encoding, loadPathLevel=0)
83
- return LoadResult.alreadyLoaded() unless project.loaded?(feature)
84
- project.loaded << feature
114
+ def rrequire(project, feature, background, loadPathLevel=0)
115
+ puts feature
116
+ encoding = "UTF-8"
85
117
 
86
- stubs = stubs_matches(project, feature)
118
+ lplevel = @context.loadPathLevel
119
+ @context.loadPathLevel = loadPathLevel
120
+ if lplevel > 1 && background == false
121
+ return @placeholders << [project, feature]
122
+ end
123
+ return LoadResult.alreadyLoaded() if project.loaded?(feature)
124
+
125
+ if PROJMAN && PROJMAN.roptions && PROJMAN.roptions.project_path
126
+ project_matches = Dir.glob(Pathname.new(PROJMAN.roptions.project_path).join("**/#{feature}*"))
127
+ if project_matches
128
+ project_matches.each do |p|
129
+ return rload(project, p, "UTF-8", false)
130
+ end
131
+ end
132
+ end
133
+
134
+ stubs = stub_matches(project, feature)
87
135
  stubs.each do |stub|
88
- rload(project, Pathname.new(stub), encoding, false)
136
+ return rload(project, Pathname.new(stub), encoding, false)
89
137
  end
90
138
 
91
139
  lpmatches = load_path_matches(project, feature)
92
140
  lpmatches.each do |lp|
93
- rload(project, lp, encoding, false)
141
+ return rload(project, lp, encoding, false)
94
142
  end
95
143
 
96
- dependencies = project.dependencies
97
- dpmatches = dependency_matches(dependencies, feature)
98
- dpmatches.each do |dp|
99
- rload(project, dp, encoding, false)
144
+ unless lpmatches
145
+ dependencies = project.dependencies
146
+ dpmatches = dependency_matches(dependencies, feature)
147
+ dpmatches.each do |dp|
148
+ rload(project, dp, encoding, false)
149
+ end
100
150
  end
101
151
 
102
152
  unless lpmatches || dpmatches
@@ -108,6 +158,7 @@ class Rsense::Server::Command::Command
108
158
  rload(project, cp, encoding, false)
109
159
  end
110
160
  end
161
+ @context.loadPathLevel = lplevel
111
162
  end
112
163
 
113
164
  def load_builtin(project)
@@ -130,15 +181,15 @@ class Rsense::Server::Command::Command
130
181
  def dependency_matches(dependencies, feature)
131
182
  dmatch = dependencies.select { |d| d.name =~ /#{feature}/ }
132
183
  if dmatch
133
- dmatch.map { |dm| Pathname.new(dm.path.first) }
184
+ dmatch.map { |dm| Pathname.new(dm.path.first) unless dm.path.first == nil }.compact
134
185
  end
135
186
  end
136
187
 
137
188
  def load_path_matches(project, feature)
138
189
  load_path = project.load_path
139
- load_path.map do |lp|
190
+ load_path.compact.map do |lp|
140
191
  Dir.glob(Pathname.new(lp).join("**/*#{feature}*"))
141
- end.flatten.compact
192
+ end.flatten.compact.reject {|f| File.directory?(f) }
142
193
  end
143
194
 
144
195
  def deep_check(gem_path, dep_paths, feature)
@@ -153,17 +204,23 @@ class Rsense::Server::Command::Command
153
204
  end
154
205
 
155
206
  def code_completion(file, location, code_str="")
207
+ prepare(@project)
156
208
  if code_str.empty?
157
209
  code = Rsense::Server::Code.new(Pathname.new(file).read)
158
210
  else
159
211
  code = Rsense::Server::Code.new(code_str)
160
- puts code
161
212
  end
162
- source = code.inject_inference_marker(location)
163
- ast = @parser.parse_string(source, file.to_s)
164
- @project.graph.load(ast)
165
- result = Java::org.cx4a.rsense::CodeCompletionResult.new
166
- result.setAST(ast)
213
+
214
+ begin
215
+ source = code.inject_inference_marker(location)
216
+ @ast = @parser.parse_string(source, file.to_s)
217
+ @project.graph.load(@ast)
218
+ result = Java::org.cx4a.rsense::CodeCompletionResult.new
219
+ result.setAST(@ast)
220
+ rescue Java::OrgJrubyparserLexer::SyntaxException => e
221
+ @errors << e
222
+ end
223
+
167
224
  candidates = []
168
225
  @receivers = []
169
226
  @context.typeSet.each do |receiver|
@@ -208,9 +265,13 @@ class Rsense::Server::Command::Command
208
265
  @context.main = true
209
266
  @type_inference_method.context = @context
210
267
  @graph = project.graph
268
+ @native_attr_method.graph = graph
211
269
  @graph.addSpecialMethod(Rsense::Server::Command::TYPE_INFERENCE_METHOD_NAME, @type_inference_method)
212
270
  @graph.addSpecialMethod("require", @require_method)
213
271
  @graph.addSpecialMethod("require_next", @require_next_method)
272
+ @graph.addSpecialMethod("require_relative", @require_relative_method)
273
+ @graph.addSpecialMethod("native_accessor", @native_attr_method)
274
+ @graph.addSpecialMethod("alias_native", @alias_native_method)
214
275
  load_builtin(project)
215
276
  end
216
277
 
@@ -233,7 +294,6 @@ class Rsense::Server::Command::Command
233
294
  end
234
295
  file = @options.project_path
235
296
  @project = Rsense::Server::Project.new(name, file)
236
- prepare(@project)
237
297
  end
238
298
 
239
299
  end
@@ -0,0 +1,42 @@
1
+ module Rsense
2
+ module Server
3
+ module Command
4
+
5
+ end
6
+ end
7
+ end
8
+
9
+ class Rsense::Server::Command::AliasNativeMethod < Java::org.cx4a.rsense.typing.runtime::SpecialMethod
10
+ attr_accessor :context
11
+
12
+ def initialize
13
+ super
14
+ end
15
+
16
+ def call(runtime, receivers, args, blcck, result)
17
+ callNextMethod = true
18
+ if args
19
+ receivers.each do |receiver|
20
+ callNextMethod = false
21
+ new_name = Java::org.cx4a.rsense.typing.vertex::Vertex.getStringOrSymbol(args[0])
22
+ if args.size > 1
23
+ old_name = Java::org.cx4a.rsense.typing.vertex::Vertex.getStringOrSymbol(args[1])
24
+ end
25
+ rsense_module = receiver
26
+ visibility = Java::org.cx4a.rsense.ruby::Visibility::PUBLIC
27
+ if old_name && new_name
28
+ rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation = Rsense::Server::Command::RsenseMethod.make_method(rsense_module, old_name, visibility, args.first.node.parent)
29
+ rsense_method = Rsense::Server::Command::RsenseMethod.new(rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation)
30
+ rsense_module.addMethod(old_name, rsense_method)
31
+ rsense_module.addMethod(new_name, Java::org.cx4a.rsense.typing.runtime::AliasMethod.new(new_name, rsense_method))
32
+ else
33
+ rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation = Rsense::Server::Command::RsenseMethod.make_method(rsense_module, new_name, visibility, args.first.node.closest_module)
34
+ rsense_method = Rsense::Server::Command::RsenseMethod.new(rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation)
35
+ rsense_module.addMethod(new_name, rsense_method)
36
+ end
37
+ end
38
+ end
39
+ result.setCallNextMethod(callNextMethod)
40
+ end
41
+
42
+ end
@@ -0,0 +1,20 @@
1
+ module Rsense
2
+ module Server
3
+ module Command
4
+
5
+ end
6
+ end
7
+ end
8
+
9
+ class Rsense::Server::Command::NativeAttrMethod < Java::org.cx4a.rsense.typing.runtime::SpecialMethod
10
+ attr_accessor :context, :graph
11
+
12
+ def initialize
13
+ super
14
+ end
15
+
16
+ def call(runtime, receivers, args, blcck, result)
17
+ Java::org.cx4a.rsense.typing.runtime::RuntimeHelper.defineAttrs(@graph, receivers, args, true, true)
18
+ end
19
+
20
+ end
@@ -0,0 +1,59 @@
1
+ require "jruby-parser"
2
+ require "pry"
3
+
4
+ module Rsense
5
+ module Server
6
+ module Command
7
+ class RsenseMethod < Java::org.cx4a.rsense.typing.runtime::DefaultMethod
8
+ attr_accessor :cbase, :name, :body_node, :args_node, :visibility, :location, :node, :parent
9
+
10
+ def initialize(cbase, name, bodyNode, argsNode, visibility, location)
11
+ super(cbase, name, bodyNode, argsNode, visibility, location)
12
+ end
13
+
14
+ def self.make_method(cbase, name, visibility, parent)
15
+ node = self.make_node(name, parent)
16
+ loc = Java::org.cx4a.rsense.util::SourceLocation.of(node)
17
+ [cbase, name, node.body_node, node.args_node, visibility, loc]
18
+ end
19
+
20
+ def self.make_node(name, parent)
21
+ self.generate_node(name, parent)
22
+ end
23
+
24
+ def self.generate_method_body(name)
25
+ %Q{
26
+ def #{name}(*args)
27
+ if block_given?
28
+ yield args
29
+ else
30
+ args
31
+ end
32
+ end
33
+ }
34
+ end
35
+
36
+ def self.generate_node(name, parent)
37
+ code = self.generate_method_body(name)
38
+ root = JRubyParser.parse(code)
39
+ node = root.find_node(:defn)
40
+ self.insert_into_parent(node, parent)
41
+ end
42
+
43
+ def self.insert_into_parent(node, parent)
44
+ parent = parent
45
+ parent.insert_node(node)
46
+ inserted_node = parent.find_all.select {|n| n == node}.first
47
+ if inserted_node
48
+ inserted_node
49
+ else
50
+ node
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+
@@ -1,4 +1,5 @@
1
1
  require "pathname"
2
+ require "bundler"
2
3
 
3
4
  module Rsense
4
5
  module Server
@@ -18,8 +19,11 @@ module Rsense
18
19
  def dependencies(project)
19
20
  @gemfile = find_gemfile(project)
20
21
  if @gemfile
22
+ start_dir = Dir.pwd
23
+ Dir.chdir(@gemfile.dirname)
21
24
  lockfile = Bundler::LockfileParser.new(Bundler.read_file(@gemfile))
22
25
  gem_info(lockfile)
26
+ Dir.chdir(start_dir)
23
27
  end
24
28
  end
25
29
 
@@ -46,15 +50,17 @@ module Rsense
46
50
  find_paths(name.chop)
47
51
  end
48
52
 
49
- def find_gemfile(project)
53
+ def find_gemfile(project, level=0)
54
+ level = level + 1
50
55
  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)
56
+ lockfile = pth.join("Gemfile.lock")
57
+ if lockfile.exist?
58
+ return lockfile
59
+ else
60
+ unless level > 6
61
+ lockfile = find_gemfile(pth.parent, level)
55
62
  end
56
63
  end
57
- lockfile
58
64
  end
59
65
 
60
66
  end
@@ -23,6 +23,10 @@ module Rsense
23
23
  end
24
24
  end
25
25
 
26
+ def project
27
+ @project_path
28
+ end
29
+
26
30
  def project=(path)
27
31
  @project_path = Pathname.new(path).expand_path
28
32
  end
@@ -10,6 +10,9 @@ module Rsense
10
10
  @runtime = @graph.getRuntime()
11
11
  @stubs = Dir.glob(Rsense::BUILTIN.join("**/*.rb"))
12
12
  @load_path = Rsense::Server::LoadPath.paths
13
+ unless @path == "."
14
+ @load_path << Pathname.new(@path)
15
+ end
13
16
  @gem_path = Rsense::Server::GemPath.paths
14
17
  @loaded = []
15
18
  @dependencies = Rsense::Server::LoadPath.dependencies(@path)
@@ -1,5 +1,5 @@
1
1
  module Rsense
2
2
  module Server
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib", "vendor/gems/puma-2.8.2-java/lib/"]
20
20
 
21
- spec.add_dependency "rsense-core", "~> 0.5.1"
21
+ spec.add_dependency "rsense-core"
22
22
  spec.add_dependency "spoon", "~> 0.0.4"
23
23
  spec.add_dependency "jruby-jars", "~> 1.7.4"
24
24
  spec.add_dependency "jruby-parser", "~> 0.5.4"
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'minitest'
33
33
  spec.add_development_dependency 'pry'
34
34
  spec.add_development_dependency "rake"
35
+ spec.add_development_dependency "awesome_print"
35
36
  end
@@ -1,16 +1,18 @@
1
1
  require "sample/version"
2
2
 
3
- class Sample
4
- attr_accessor :simple
3
+ module Sample
4
+ class Sample
5
+ attr_accessor :simple
5
6
 
6
- def initialize
7
- @simple = "simple"
8
- end
7
+ def initialize
8
+ @simple = "simple"
9
+ end
9
10
 
10
- def another
11
- "another"
11
+ def another
12
+ "another"
13
+ end
12
14
  end
13
15
  end
14
16
 
15
- sample = Sample.new
17
+ sample = Sample::Sample.new
16
18
  sample
@@ -2,9 +2,9 @@
2
2
  "command": "code_completion",
3
3
  "project": "spec/fixtures/test_gem",
4
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",
5
+ "code": "require \"sample/version\"\n\nmodule Sample\n class Sample\n attr_accessor :simple\n\n def initialize\n @simple = \"simple\"\n end\n\n def another\n \"another\"\n end\n end\nend\n\nsample = Sample::Sample.new\nsample",
6
6
  "location": {
7
- "row": 16,
7
+ "row": 18,
8
8
  "column": 7
9
9
  }
10
10
  }
@@ -0,0 +1,28 @@
1
+ require_relative "./spec_helper"
2
+ require "pathname"
3
+ require "json"
4
+
5
+ describe "completions" do
6
+
7
+ class TestMockscript
8
+ attr_accessor :json_path, :json, :options, :command, :name, :file, :project
9
+
10
+ def initialize
11
+ @json_path = Pathname.new("spec/fixtures/test_gem/test.json").expand_path
12
+ @json = JSON.parse(@json_path.read)
13
+ @options = Rsense::Server::Options.new(@json)
14
+ @command = Rsense::Server::Command::Command.new(@options)
15
+ end
16
+
17
+ def code_complete
18
+ @command.code_completion(@options.file, @options.location)
19
+ end
20
+ end
21
+
22
+ it "returns completions" do
23
+ @script = TestMockscript.new
24
+ compls = @script.code_complete
25
+ compls.size.must_equal(51)
26
+ end
27
+
28
+ end
@@ -3,6 +3,12 @@ require "json"
3
3
  require_relative "../../spec_helper.rb"
4
4
 
5
5
  describe Rsense::Server::Command::Command do
6
+ class ProjectManager
7
+ attr_accessor :roptions, :rcommand, :rproject
8
+ end
9
+
10
+ PROJMAN = ProjectManager.new
11
+
6
12
  before do
7
13
  @json_path = Pathname.new("spec/fixtures/sample.json")
8
14
  @json = JSON.parse(@json_path.read)
@@ -75,34 +81,4 @@ describe Rsense::Server::Command::Command do
75
81
  end
76
82
  end
77
83
 
78
- describe "completions" do
79
- require 'json'
80
-
81
- class Testscript
82
- attr_accessor :json_path, :json, :options, :command, :name, :file, :project
83
-
84
- def initialize
85
- @json_path = Pathname.new("spec/fixtures/test_gem/test.json").expand_path
86
- @json = JSON.parse(@json_path.read)
87
- @options = Rsense::Server::Options.new(@json)
88
- @command = Rsense::Server::Command::Command.new(@options)
89
- @name = "sample"
90
- @file = @options.project_path
91
- @project = Rsense::Server::Project.new(@name, @file)
92
- end
93
-
94
- def code_complete
95
- @command.code_completion(@options.file, @options.location)
96
- end
97
- end
98
-
99
- before do
100
- @test = Testscript.new
101
- end
102
-
103
- it "returns completions" do
104
- @test.code_complete.size.must_equal(51)
105
- end
106
-
107
- end
108
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsense-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric West
@@ -9,20 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-09 00:00:00.000000000 Z
12
+ date: 2014-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rsense-core
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.5.1
20
+ version: '0'
21
21
  requirement: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - ~>
23
+ - - '>='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.5.1
25
+ version: '0'
26
26
  prerelease: false
27
27
  type: :runtime
28
28
  - !ruby/object:Gem::Dependency
@@ -193,6 +193,20 @@ dependencies:
193
193
  version: '0'
194
194
  prerelease: false
195
195
  type: :development
196
+ - !ruby/object:Gem::Dependency
197
+ name: awesome_print
198
+ version_requirements: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - '>='
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ prerelease: false
209
+ type: :development
196
210
  description: rsense-server is the communications bridge between the user (or editor plugins the user is using) and the rsense library written in java.
197
211
  email:
198
212
  - esw9999@gmail.com
@@ -213,7 +227,10 @@ files:
213
227
  - lib/rsense/server.rb
214
228
  - lib/rsense/server/code.rb
215
229
  - lib/rsense/server/command.rb
230
+ - lib/rsense/server/command/alias_native_method.rb
216
231
  - lib/rsense/server/command/completion_result.rb
232
+ - lib/rsense/server/command/native_attr_method.rb
233
+ - lib/rsense/server/command/rsense_method.rb
217
234
  - lib/rsense/server/command/special_meth.rb
218
235
  - lib/rsense/server/command/type_inference_method.rb
219
236
  - lib/rsense/server/config.rb
@@ -240,6 +257,7 @@ files:
240
257
  - spec/fixtures/test_gem/lib/sample/version.rb
241
258
  - spec/fixtures/test_gem/sample.gemspec
242
259
  - spec/fixtures/test_gem/test.json
260
+ - spec/integration_spec.rb
243
261
  - spec/rsense/server/code_spec.rb
244
262
  - spec/rsense/server/command/special_meth_spec.rb
245
263
  - spec/rsense/server/command_spec.rb
@@ -376,6 +394,7 @@ test_files:
376
394
  - spec/fixtures/test_gem/lib/sample/version.rb
377
395
  - spec/fixtures/test_gem/sample.gemspec
378
396
  - spec/fixtures/test_gem/test.json
397
+ - spec/integration_spec.rb
379
398
  - spec/rsense/server/code_spec.rb
380
399
  - spec/rsense/server/command/special_meth_spec.rb
381
400
  - spec/rsense/server/command_spec.rb