solargraph 0.8.2 → 0.8.3

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: e47975025923e6fefaa775875a539c14a8ce263b
4
- data.tar.gz: 253ceb89deba6b4a3e63a7861a167c7bd24e64eb
3
+ metadata.gz: e52db6d5b84e35fa182015ad0178c8fde5433534
4
+ data.tar.gz: 4cb0dbfa89392f8fb4b9b04b506114d1b975fcb9
5
5
  SHA512:
6
- metadata.gz: b563880f6b352616b38c1accb2d0f07b189e23b25cbcc816c54bf1a3acae1b1e130b0f7f565110008bb4561234ff423bbb553843ffef1aba958164e61dd161a7
7
- data.tar.gz: c6dbd8e28a73bf8ce205508b87146d6a189b8c216d42a2c72f1c5ce8d32796fb57a52f967278e36a07f89e8f5e3fa108ee6a0cbd048e8df858b9c032347ba19e
6
+ metadata.gz: 9f4d6d1f77fb88afb992b1a32eb12e017f74a310e090c0b275d4f5d6546313455c7e5d9230322007d1e15acc9686bc88f744e3cb18512b2ba6be5d356adb147e
7
+ data.tar.gz: 74cd777945f475843b629de0613cd10949b9aed887a30f5a1423825bac943df4c4491f9caf98b8d3f231df12f22a4e09cb6c62836cc5047003a4a665a2f5a8fd
@@ -10,7 +10,7 @@ module Solargraph
10
10
  'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
11
11
  'elsif', 'end', 'ensure', 'false', 'for', 'if', 'in', 'module', 'next',
12
12
  'nil', 'not', 'or', 'redo', 'rescue', 'retry', 'return', 'self', 'super',
13
- 'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield',
13
+ 'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
14
14
  ]
15
15
 
16
16
  MAPPABLE_METHODS = [
@@ -97,6 +97,7 @@ module Solargraph
97
97
  @file_comments[filename][node.loc]
98
98
  end
99
99
 
100
+
100
101
  def self.get_keywords
101
102
  result = []
102
103
  keywords = KEYWORDS + ['attr_reader', 'attr_writer', 'attr_accessor', 'private', 'public', 'protected']
@@ -510,14 +511,16 @@ module Solargraph
510
511
  docstring = get_comment_for(c)
511
512
  label = "#{c.children[1]}"
512
513
  args = get_method_args(c)
513
- meths.push Suggestion.new(label, insert: c.children[1].to_s.gsub(/=/, ' = '), kind: Suggestion::METHOD, detail: 'Method', documentation: docstring, arguments: args) if c.children[1].to_s[0].match(/[a-z_]/i) and c.children[1] != :def
514
+ if (c.children[1].to_s[0].match(/[a-z_]/i) and c.children[1] != :def)
515
+ meths.push Suggestion.new(label, insert: c.children[1].to_s.gsub(/=/, ' = '), kind: Suggestion::METHOD, detail: 'Method', documentation: docstring, arguments: args)
516
+ end
514
517
  elsif c.type == :send and c.children[1] == :include
515
518
  # TODO: This might not be right. Should we be getting singleton methods
516
519
  # from an include, or only from an extend?
517
520
  i = unpack_name(c.children[2])
518
- meths += inner_get_methods(i, root, skip) unless i == 'Kernel'
521
+ meths.concat inner_get_methods(i, root, skip) unless i == 'Kernel'
519
522
  else
520
- meths += inner_get_methods_from_node(c, root, skip)
523
+ meths.concat inner_get_methods_from_node(c, root, skip)
521
524
  end
522
525
  end
523
526
  }
@@ -554,16 +557,16 @@ module Solargraph
554
557
  meths.push Suggestion.new(label, insert: c.children[0].to_s.gsub(/=/, ' = '), kind: Suggestion::METHOD, documentation: cmnt, detail: fqns, arguments: args) if c.children[0].to_s[0].match(/[a-z]/i)
555
558
  elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :attr_reader
556
559
  c.children[2..-1].each { |x|
557
- meths.push Suggestion.new(x.children[0], kind: Suggestion::METHOD) if x.type == :sym
560
+ meths.push Suggestion.new(x.children[0], kind: Suggestion::FIELD) if x.type == :sym
558
561
  }
559
562
  elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :attr_writer
560
563
  c.children[2..-1].each { |x|
561
- meths.push Suggestion.new("#{x.children[0]}=", kind: Suggestion::METHOD) if x.type == :sym
564
+ meths.push Suggestion.new("#{x.children[0]}=", kind: Suggestion::FIELD) if x.type == :sym
562
565
  }
563
566
  elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :attr_accessor
564
567
  c.children[2..-1].each { |x|
565
- meths.push Suggestion.new(x.children[0], kind: Suggestion::METHOD) if x.type == :sym
566
- meths.push Suggestion.new("#{x.children[0]}=", kind: Suggestion::METHOD) if x.type == :sym
568
+ meths.push Suggestion.new(x.children[0], kind: Suggestion::FIELD) if x.type == :sym
569
+ meths.push Suggestion.new("#{x.children[0]}=", kind: Suggestion::FIELD) if x.type == :sym
567
570
  }
568
571
  end
569
572
  end
@@ -589,7 +592,7 @@ module Solargraph
589
592
  false
590
593
  end
591
594
  end
592
-
595
+
593
596
  def reduce node, comment_hash
594
597
  return node unless node.kind_of?(AST::Node)
595
598
  mappable = get_mappable_nodes(node.children, comment_hash)
@@ -680,7 +683,7 @@ module Solargraph
680
683
  cursor = cursor[t.to_s]
681
684
  }
682
685
  end
683
-
686
+
684
687
  def map_namespaces node, tree = []
685
688
  if node.kind_of?(AST::Node)
686
689
  if node.type == :class or node.type == :module
@@ -698,6 +701,6 @@ module Solargraph
698
701
  map_namespaces c, tree
699
702
  }
700
703
  end
701
- end
704
+ end
702
705
  end
703
706
  end
@@ -181,7 +181,7 @@ module Solargraph
181
181
  end
182
182
 
183
183
  def suggest_at index, filtered: false, with_snippets: false
184
- return [] if string_at?(index)
184
+ return [] if string_at?(index) or string_at?(index - 1)
185
185
  result = []
186
186
  phrase = phrase_at(index)
187
187
  signature = get_signature_at(index)
@@ -213,7 +213,7 @@ module Solargraph
213
213
  ns = parts[0..-2].join('::') + '::' + parts.last[0..parts.last.index('.')-1]
214
214
  result = api_map.get_methods(ns)
215
215
  else
216
- result = api_map.namespaces_in(ns)
216
+ result = api_map.namespaces_in(ns, namespace)
217
217
  end
218
218
  else
219
219
  current_namespace = namespace_at(index)
@@ -223,7 +223,7 @@ module Solargraph
223
223
  result += ApiMap.get_keywords
224
224
  while parts.length > 0
225
225
  ns = parts.join('::')
226
- result += api_map.namespaces_in(ns)
226
+ result += api_map.namespaces_in(ns, namespace)
227
227
  parts.pop
228
228
  end
229
229
  result += api_map.namespaces_in('')
@@ -301,6 +301,7 @@ module Solargraph
301
301
  parts = signature.split('.')
302
302
  ns_here = namespace_from(node)
303
303
  start = parts[0]
304
+ return nil if start.nil?
304
305
  remainder = parts[1..-1]
305
306
  scope = :instance
306
307
  var = find_local_variable_node(start, node)
@@ -460,7 +461,7 @@ module Solargraph
460
461
  args = node.children[1]
461
462
  args.children.each do |arg|
462
463
  name = arg.children[0].to_s
463
- result.push Suggestion.new(name, kind: Suggestion::VARIABLE, insert: name)
464
+ result.push Suggestion.new(name, kind: Suggestion::PROPERTY, insert: name)
464
465
  end
465
466
  result
466
467
  end
@@ -8,6 +8,8 @@ module Solargraph
8
8
  MODULE = 'Module'
9
9
  METHOD = 'Method'
10
10
  VARIABLE = 'Variable'
11
+ PROPERTY = 'Property'
12
+ FIELD = 'Field'
11
13
  SNIPPET = 'Snippet'
12
14
 
13
15
  attr_reader :label, :kind, :insert, :detail, :documentation, :code_object, :location, :arguments
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.3'
3
3
  end
@@ -148,7 +148,8 @@ module Solargraph
148
148
  n = m.to_s.split(/[\.#]/).last.gsub(/=/, ' = ')
149
149
  label = "#{n}"
150
150
  args = get_method_args(m)
151
- meths.push Suggestion.new(label, insert: "#{n.gsub(/=/, ' = ')}", kind: Suggestion::METHOD, documentation: m.docstring, code_object: m, detail: "#{ns}", location: "#{m.file}:#{m.line}", arguments: args)
151
+ kind = (m.is_attribute? ? Suggestion::FIELD : Suggestion::METHOD)
152
+ meths.push Suggestion.new(label, insert: "#{n.gsub(/=/, ' = ')}", kind: kind, documentation: m.docstring, code_object: m, detail: "#{ns}", location: "#{m.file}:#{m.line}", arguments: args)
152
153
  }
153
154
  # Collect superclass methods
154
155
  if ns.kind_of?(YARD::CodeObjects::ClassObject) and !ns.superclass.nil?
@@ -191,7 +192,8 @@ module Solargraph
191
192
  if n.to_s.match(/^[a-z]/i) and (namespace == 'Kernel' or !m.to_s.start_with?('Kernel#')) and !m.docstring.to_s.include?(':nodoc:')
192
193
  label = "#{n}"
193
194
  args = get_method_args(m)
194
- meths.push Suggestion.new(label, insert: "#{n.gsub(/=/, ' = ')}", kind: Suggestion::METHOD, documentation: m.docstring, code_object: m, detail: m.namespace, location: "#{m.file}:#{m.line}", arguments: args)
195
+ kind = (m.is_attribute? ? Suggestion::FIELD : Suggestion::METHOD)
196
+ meths.push Suggestion.new(label, insert: "#{n.gsub(/=/, ' = ')}", kind: kind, documentation: m.docstring, code_object: m, detail: m.namespace, location: "#{m.file}:#{m.line}", arguments: args)
195
197
  end
196
198
  }
197
199
  if ns.kind_of?(YARD::CodeObjects::ClassObject) and namespace != 'Object'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-03 00:00:00.000000000 Z
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser