solargraph 0.31.2 → 0.31.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/solargraph/api_map.rb +1 -1
  3. data/lib/solargraph/complex_type.rb +7 -0
  4. data/lib/solargraph/language_server/host.rb +16 -19
  5. data/lib/solargraph/language_server/host/dispatch.rb +4 -3
  6. data/lib/solargraph/language_server/host/sources.rb +3 -3
  7. data/lib/solargraph/language_server/message/text_document/completion.rb +2 -3
  8. data/lib/solargraph/language_server/message/text_document/definition.rb +1 -6
  9. data/lib/solargraph/language_server/message/text_document/hover.rb +1 -2
  10. data/lib/solargraph/language_server/message/text_document/references.rb +1 -1
  11. data/lib/solargraph/language_server/message/text_document/rename.rb +1 -1
  12. data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -2
  13. data/lib/solargraph/language_server/uri_helpers.rb +1 -1
  14. data/lib/solargraph/pin/base.rb +1 -1
  15. data/lib/solargraph/pin/base_method.rb +1 -6
  16. data/lib/solargraph/pin/base_variable.rb +2 -2
  17. data/lib/solargraph/pin/block_parameter.rb +2 -2
  18. data/lib/solargraph/pin/method.rb +3 -3
  19. data/lib/solargraph/pin/method_parameter.rb +1 -1
  20. data/lib/solargraph/pin/namespace.rb +2 -2
  21. data/lib/solargraph/pin/yard_pin/method.rb +1 -1
  22. data/lib/solargraph/source.rb +1 -0
  23. data/lib/solargraph/source/chain/call.rb +2 -6
  24. data/lib/solargraph/source/chain/literal.rb +1 -1
  25. data/lib/solargraph/source_map/clip.rb +7 -5
  26. data/lib/solargraph/source_map/mapper.rb +19 -11
  27. data/lib/solargraph/source_map/node_processor/def_node.rb +1 -1
  28. data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +1 -1
  29. data/lib/solargraph/version.rb +1 -1
  30. data/yardoc/2.2.2.tar.gz +0 -0
  31. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad024bb9d47484f46c548f061033e61bae31c8108f8c22a1910d6ec9daebc172
4
- data.tar.gz: 18235c0ac8d50fcf1cbce67e8545d9f92e5c7363c9b7a9b22ce6894afbc0b4ee
3
+ metadata.gz: a18d1986bcaf5c2f39fb6f7adf604a2275382a87eaa7d292d0a48ee4d65bf40e
4
+ data.tar.gz: 8bd096eb42b1b573b1433b6fa1bad9adbbda95c24cde405422a489f69ead949c
5
5
  SHA512:
6
- metadata.gz: d3479bfd3f3ac8e55ac40f9edbd304e7ade94618c316327cdca6bc3f06dcded61e6cec6d8f4388052e436aa96abe95c46db3572bd09bf9296ea3821a4f0192fc
7
- data.tar.gz: 3c49842db66464930b789325e10dac77b9fa35131a44b587a32ac8d3293b99ce89a498d716693663dd2c511be254dffe8316168bd824a301b5b4fd0bea7d5bf5
6
+ metadata.gz: 3b0c25b798781b5ff29c16d1728e1b03108a8bbcc55cc20d407fd6b1e4f16fe0e45d1f730b1de6c6ba1cc661091cd0f4e8e993186cca721e68d9e341ec2f12ed
7
+ data.tar.gz: e711f3d5b03207e7a6bff18fa68768ae3d9d8efc6a54e2225d25b4f37033bcbba916c60ce3a379e4d2e1fe20d1c03cad294fc3cfe3411f6568c13bbe4681c52e
@@ -524,7 +524,7 @@ module Solargraph
524
524
  end
525
525
  end
526
526
  store.domains(fqns).each do |d|
527
- dt = ComplexType.parse(d)
527
+ dt = ComplexType.try_parse(d)
528
528
  result.concat inner_get_methods(dt.namespace, dt.scope, [:public], deep, skip)
529
529
  end
530
530
  end
@@ -133,6 +133,13 @@ module Solargraph
133
133
  @cache[strings] = result unless partial
134
134
  result
135
135
  end
136
+
137
+ def try_parse *strings
138
+ parse *strings
139
+ rescue ComplexTypeError => e
140
+ Solargraph.logger.info "Error parsing complex type: #{e.message}"
141
+ ComplexType::UNDEFINED
142
+ end
136
143
  end
137
144
 
138
145
  VOID = ComplexType.parse('void')
@@ -459,41 +459,41 @@ module Solargraph
459
459
  library.read_text(filename)
460
460
  end
461
461
 
462
- # @param filename [String]
462
+ # @param uri [String]
463
463
  # @param line [Integer]
464
464
  # @param column [Integer]
465
465
  # @return [Solargraph::ApiMap::Completion]
466
- def completions_at filename, line, column
467
- library = library_for(file_to_uri(filename))
468
- library.completions_at filename, line, column
466
+ def completions_at uri, line, column
467
+ library = library_for(uri)
468
+ library.completions_at uri_to_file(uri), line, column
469
469
  end
470
470
 
471
- # @param filename [String]
471
+ # @param uri [String]
472
472
  # @param line [Integer]
473
473
  # @param column [Integer]
474
474
  # @return [Array<Solargraph::Pin::Base>]
475
- def definitions_at filename, line, column
476
- library = library_for(file_to_uri(filename))
477
- library.definitions_at(filename, line, column)
475
+ def definitions_at uri, line, column
476
+ library = library_for(uri)
477
+ library.definitions_at(uri_to_file(uri), line, column)
478
478
  end
479
479
 
480
- # @param filename [String]
480
+ # @param uri [String]
481
481
  # @param line [Integer]
482
482
  # @param column [Integer]
483
483
  # @return [Array<Solargraph::Pin::Base>]
484
- def signatures_at filename, line, column
485
- library = library_for(file_to_uri(filename))
486
- library.signatures_at(filename, line, column)
484
+ def signatures_at uri, line, column
485
+ library = library_for(uri)
486
+ library.signatures_at(uri_to_file(uri), line, column)
487
487
  end
488
488
 
489
- # @param filename [String]
489
+ # @param uri [String]
490
490
  # @param line [Integer]
491
491
  # @param column [Integer]
492
492
  # @param strip [Boolean] Strip special characters from variable names
493
493
  # @return [Array<Solargraph::Range>]
494
- def references_from filename, line, column, strip: true
495
- library = library_for(file_to_uri(filename))
496
- library.references_from(filename, line, column, strip: strip)
494
+ def references_from uri, line, column, strip: true
495
+ library = library_for(uri)
496
+ library.references_from(uri_to_file(uri), line, column, strip: strip)
497
497
  end
498
498
 
499
499
  # @param query [String]
@@ -586,9 +586,6 @@ module Solargraph
586
586
  # @param uri [String]
587
587
  # @return [Array<Range>]
588
588
  def folding_ranges uri
589
- # library = library_for(uri)
590
- # file = uri_to_file(uri)
591
- # library.folding_ranges(file)
592
589
  sources.find(uri).folding_ranges
593
590
  end
594
591
 
@@ -21,9 +21,10 @@ module Solargraph
21
21
  # The Sources observer callback that merges a source into the host's
22
22
  # libraries when it gets updated.
23
23
  #
24
- # @param src [Source]
24
+ # @param uri [String]
25
25
  # @return [void]
26
- def update_libraries src
26
+ def update_libraries uri
27
+ src = sources.find(uri)
27
28
  # @todo This module should not call cataloger and diagnoser
28
29
  libraries.each do |lib|
29
30
  if lib.contain?(src.filename) || lib.open?(src.filename)
@@ -31,7 +32,7 @@ module Solargraph
31
32
  cataloger.ping(lib)
32
33
  end
33
34
  end
34
- diagnoser.schedule file_to_uri(src.filename) if src.synchronized?
35
+ diagnoser.schedule uri if src.synchronized?
35
36
  end
36
37
 
37
38
  # Find the best libary match for the given URI.
@@ -38,7 +38,7 @@ module Solargraph
38
38
  nxt = open_source_hash[uri].finish_synchronize
39
39
  open_source_hash[uri] = nxt
40
40
  changed
41
- notify_observers open_source_hash[uri]
41
+ notify_observers uri
42
42
  end
43
43
  end
44
44
 
@@ -70,7 +70,7 @@ module Solargraph
70
70
  src = find(uri)
71
71
  mutex.synchronize { open_source_hash[uri] = src.synchronize(updater) }
72
72
  changed
73
- notify_observers open_source_hash[uri]
73
+ notify_observers uri
74
74
  end
75
75
 
76
76
  # @param uri [String]
@@ -81,7 +81,7 @@ module Solargraph
81
81
  mutex.synchronize { open_source_hash[uri] = src.start_synchronize(updater) }
82
82
  mutex.synchronize { queue.push uri }
83
83
  changed
84
- notify_observers open_source_hash[uri]
84
+ notify_observers uri
85
85
  end
86
86
 
87
87
  # Find the source with the given URI.
@@ -4,11 +4,10 @@ module Solargraph
4
4
  module TextDocument
5
5
  class Completion < Base
6
6
  def process
7
- filename = uri_to_file(params['textDocument']['uri'])
8
7
  line = params['position']['line']
9
8
  col = params['position']['character']
10
9
  begin
11
- completion = host.completions_at(filename, line, col)
10
+ completion = host.completions_at(params['textDocument']['uri'], line, col)
12
11
  if host.cancel?(id)
13
12
  return set_result(empty_result) if host.cancel?(id)
14
13
  end
@@ -32,7 +31,7 @@ module Solargraph
32
31
  items: items
33
32
  )
34
33
  rescue InvalidOffsetError => e
35
- Logging.logger.info "Completion ignored invalid offset: #{filename}, line #{line}, character #{col}"
34
+ Logging.logger.info "Completion ignored invalid offset: #{params['textDocument']['uri']}, line #{line}, character #{col}"
36
35
  set_result empty_result
37
36
  end
38
37
  end
@@ -3,14 +3,9 @@ require 'uri'
3
3
  module Solargraph::LanguageServer::Message::TextDocument
4
4
  class Definition < Base
5
5
  def process
6
- # source = host.read(params['textDocument']['uri'])
7
- # code_map = Solargraph::CodeMap.from_source(source, host.api_map)
8
- # offset = code_map.get_offset(params['position']['line'], params['position']['character'])
9
- # suggestions = code_map.define_symbol_at(offset)
10
- filename = uri_to_file(params['textDocument']['uri'])
11
6
  line = params['position']['line']
12
7
  col = params['position']['character']
13
- suggestions = host.definitions_at(filename, line, col)
8
+ suggestions = host.definitions_at(params['textDocument']['uri'], line, col)
14
9
  locations = suggestions.reject{|pin| pin.location.nil?}.map do |pin|
15
10
  {
16
11
  uri: file_to_uri(pin.location.filename),
@@ -4,11 +4,10 @@ require 'htmlentities'
4
4
  module Solargraph::LanguageServer::Message::TextDocument
5
5
  class Hover < Base
6
6
  def process
7
- filename = uri_to_file(params['textDocument']['uri'])
8
7
  line = params['position']['line']
9
8
  col = params['position']['character']
10
9
  contents = []
11
- suggestions = host.definitions_at(filename, line, col)
10
+ suggestions = host.definitions_at(params['textDocument']['uri'], line, col)
12
11
  last_link = nil
13
12
  suggestions.each do |pin|
14
13
  parts = []
@@ -1,7 +1,7 @@
1
1
  module Solargraph::LanguageServer::Message::TextDocument
2
2
  class References < Base
3
3
  def process
4
- locs = host.references_from(uri_to_file(params['textDocument']['uri']), params['position']['line'], params['position']['character'])
4
+ locs = host.references_from(params['textDocument']['uri'], params['position']['line'], params['position']['character'])
5
5
  result = locs.map do |loc|
6
6
  {
7
7
  uri: file_to_uri(loc.filename),
@@ -1,7 +1,7 @@
1
1
  module Solargraph::LanguageServer::Message::TextDocument
2
2
  class Rename < Base
3
3
  def process
4
- locs = host.references_from(uri_to_file(params['textDocument']['uri']), params['position']['line'], params['position']['character'], strip: true)
4
+ locs = host.references_from(params['textDocument']['uri'], params['position']['line'], params['position']['character'], strip: true)
5
5
  changes = {}
6
6
  locs.each do |loc|
7
7
  uri = file_to_uri(loc.filename)
@@ -4,10 +4,9 @@ module Solargraph
4
4
  module TextDocument
5
5
  class SignatureHelp < TextDocument::Base
6
6
  def process
7
- filename = uri_to_file(params['textDocument']['uri'])
8
7
  line = params['position']['line']
9
8
  col = params['position']['character']
10
- suggestions = host.signatures_at(filename, line, col)
9
+ suggestions = host.signatures_at(params['textDocument']['uri'], line, col)
11
10
  info = suggestions.map(&:signature_help)
12
11
  set_result({
13
12
  signatures: info
@@ -18,7 +18,7 @@ module Solargraph
18
18
  # @param file [String]
19
19
  # @return [String]
20
20
  def file_to_uri file
21
- "file://#{URI.encode(file.gsub(/^([a-z]\:)/i, '/\1')).gsub(/\:/, '%3A')}"
21
+ "file://#{URI.encode(file.gsub(/^([a-z]\:)/i, '/\1'))}"
22
22
  end
23
23
  end
24
24
  end
@@ -67,7 +67,7 @@ module Solargraph
67
67
 
68
68
  # @return [ComplexType]
69
69
  def context
70
- @context ||= ComplexType.parse(namespace || '')
70
+ @context ||= ComplexType.try_parse(namespace || '')
71
71
  end
72
72
 
73
73
  # Pin equality is determined using the #nearly? method and also
@@ -31,12 +31,7 @@ module Solargraph
31
31
  tag = ol.tag(:return) unless ol.nil?
32
32
  end
33
33
  return ComplexType::UNDEFINED if tag.nil? or tag.types.nil? or tag.types.empty?
34
- begin
35
- ComplexType.parse *tag.types
36
- rescue Solargraph::ComplexTypeError => e
37
- Solargraph::Logging.logger.warn e.message
38
- ComplexType::UNDEFINED
39
- end
34
+ ComplexType.try_parse *tag.types
40
35
  end
41
36
 
42
37
  # @param [ApiMap]
@@ -63,8 +63,8 @@ module Solargraph
63
63
 
64
64
  def generate_complex_type
65
65
  tag = docstring.tag(:type)
66
- return ComplexType.parse(*tag.types) unless tag.nil? || tag.types.nil? || tag.types.empty?
67
- return ComplexType.parse(@literal) unless @literal.nil?
66
+ return ComplexType.try_parse(*tag.types) unless tag.nil? || tag.types.nil? || tag.types.empty?
67
+ return ComplexType.try_parse(@literal) unless @literal.nil?
68
68
  ComplexType.new
69
69
  end
70
70
  end
@@ -61,7 +61,7 @@ module Solargraph
61
61
  if found.nil? and !index.nil?
62
62
  found = params[index] if params[index] && (params[index].name.nil? || params[index].name.empty?)
63
63
  end
64
- @return_complex_type = ComplexType.parse(*found.types) unless found.nil? or found.types.nil?
64
+ @return_complex_type = ComplexType.try_parse(*found.types) unless found.nil? or found.types.nil?
65
65
  end
66
66
  super
67
67
  @return_complex_type
@@ -88,7 +88,7 @@ module Solargraph
88
88
  else
89
89
  yps = meth.docstring.tags(:yieldparam)
90
90
  unless yps[index].nil? or yps[index].types.nil? or yps[index].types.empty?
91
- return ComplexType.parse(yps[index].types.first).qualify(api_map, meth.context.namespace)
91
+ return ComplexType.try_parse(yps[index].types.first).qualify(api_map, meth.context.namespace)
92
92
  end
93
93
  end
94
94
  end
@@ -34,9 +34,9 @@ module Solargraph
34
34
  @context ||= begin
35
35
  if scope == :class
36
36
  # @todo Determine whether the namespace is a class or a module
37
- ComplexType.parse("Class<#{namespace}>")
37
+ ComplexType.try_parse("Class<#{namespace}>")
38
38
  else
39
- ComplexType.parse(namespace)
39
+ ComplexType.try_parse(namespace)
40
40
  end
41
41
  end
42
42
  end
@@ -119,7 +119,7 @@ module Solargraph
119
119
  result.push type unless type.undefined?
120
120
  end
121
121
  return ComplexType::UNDEFINED if result.empty?
122
- ComplexType.parse(*result.map(&:tag))
122
+ ComplexType.try_parse(*result.map(&:tag))
123
123
  end
124
124
  end
125
125
  end
@@ -14,7 +14,7 @@ module Solargraph
14
14
  if found.nil? and !index.nil?
15
15
  found = params[index] if params[index] && (params[index].name.nil? || params[index].name.empty?)
16
16
  end
17
- @return_complex_type = ComplexType.parse(*found.types) unless found.nil? or found.types.nil?
17
+ @return_complex_type = ComplexType.try_parse(*found.types) unless found.nil? or found.types.nil?
18
18
  end
19
19
  super
20
20
  @return_complex_type
@@ -18,7 +18,7 @@ module Solargraph
18
18
  end
19
19
 
20
20
  def context
21
- @context ||= ComplexType.parse("#{type.to_s.capitalize}<#{path}>")
21
+ @context ||= ComplexType.try_parse("#{type.to_s.capitalize}<#{path}>")
22
22
  end
23
23
 
24
24
  def scope
@@ -39,7 +39,7 @@ module Solargraph
39
39
  end
40
40
 
41
41
  def return_complex_type
42
- @return_complex_type ||= ComplexType.parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
42
+ @return_complex_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
43
43
  end
44
44
 
45
45
  def domains
@@ -10,7 +10,7 @@ module Solargraph
10
10
  end
11
11
 
12
12
  def return_complex_type
13
- @return_complex_type ||= Solargraph::ComplexType.parse(Solargraph::CoreFills::CUSTOM_RETURN_TYPES[path]) if Solargraph::CoreFills::CUSTOM_RETURN_TYPES.has_key?(path)
13
+ @return_complex_type ||= Solargraph::ComplexType.try_parse(Solargraph::CoreFills::CUSTOM_RETURN_TYPES[path]) if Solargraph::CoreFills::CUSTOM_RETURN_TYPES.has_key?(path)
14
14
  super
15
15
  end
16
16
 
@@ -123,6 +123,7 @@ module Solargraph
123
123
  src.comments = @comments
124
124
  src.error_ranges = error_ranges
125
125
  src.last_updater = updater
126
+ return src.finish_synchronize unless real_code.lines.length == @code.lines.length
126
127
  src
127
128
  end
128
129
 
@@ -32,11 +32,7 @@ module Solargraph
32
32
  # @param context [Solargraph::ComplexType]
33
33
  # @return [Pin::Method]
34
34
  def virtual_new_pin new_pin, context
35
- # pin = Pin::Method.new(new_pin.location, context.namespace, new_pin.name, '', :class, new_pin.visibility, new_pin.parameters)
36
- # @todo Smelly instance variable access.
37
- # pin.instance_variable_set(:@return_complex_type, ComplexType.parse(context.namespace))
38
- # pin
39
- Pin::ProxyType.anonymous(ComplexType.parse(context.namespace))
35
+ Pin::ProxyType.anonymous(ComplexType.try_parse(context.namespace))
40
36
  end
41
37
 
42
38
  def inferred_pins pins, api_map, context, locals
@@ -101,7 +97,7 @@ module Solargraph
101
97
  docstring = YARD::Docstring.parser.parse(txt).to_docstring
102
98
  tag = docstring.tag(:return)
103
99
  unless tag.nil? || tag.types.nil?
104
- return Pin::ProxyType.anonymous(ComplexType.parse(*tag.types))
100
+ return Pin::ProxyType.anonymous(ComplexType.try_parse(*tag.types))
105
101
  end
106
102
  Pin::ProxyType.new(nil, nil, nil, ComplexType::UNDEFINED)
107
103
  end
@@ -9,7 +9,7 @@ module Solargraph
9
9
  # @param type [String]
10
10
  def initialize type
11
11
  @type = type
12
- @complex_type = ComplexType.parse(type).first
12
+ @complex_type = ComplexType.try_parse(type).first
13
13
  end
14
14
 
15
15
  def resolve api_map, name_pin, locals
@@ -30,9 +30,9 @@ module Solargraph
30
30
  else
31
31
  full = cursor.chain.links.first.word
32
32
  if full.include?('::') && cursor.chain.links.length == 1
33
- type = ComplexType.parse(full.split('::')[0..-2].join('::'))
33
+ type = ComplexType.try_parse(full.split('::')[0..-2].join('::'))
34
34
  elsif cursor.chain.links.length > 1
35
- type = ComplexType.parse(full)
35
+ type = ComplexType.try_parse(full)
36
36
  else
37
37
  type = ComplexType::UNDEFINED
38
38
  end
@@ -78,8 +78,10 @@ module Solargraph
78
78
  #
79
79
  # @return [Array<Solargraph::Pin::Base>]
80
80
  def locals
81
+ loc_pos = context_pin.location.range.contain?(cursor.position) ? cursor.position : context_pin.location.range.ending
82
+ adj_pos = Position.new(loc_pos.line, (loc_pos.column.zero? ? 0 : loc_pos.column - 1))
81
83
  @locals ||= source_map.locals.select { |pin|
82
- pin.visible_from?(block, Position.new(cursor.position.line, (cursor.position.column.zero? ? 0 : cursor.position.column - 1)))
84
+ pin.visible_from?(block, adj_pos)
83
85
  }.reverse
84
86
  end
85
87
 
@@ -117,12 +119,12 @@ module Solargraph
117
119
  result = []
118
120
  ys = receiver_pin.docstring.tag(:yieldself)
119
121
  unless ys.nil? || ys.types.empty?
120
- ysct = ComplexType.parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
122
+ ysct = ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
121
123
  result.concat api_map.get_complex_type_methods(ysct, ysct.namespace, true)
122
124
  end
123
125
  ys = receiver_pin.docstring.tag(:yieldpublic)
124
126
  unless ys.nil? || ys.types.empty?
125
- ysct = ComplexType.parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
127
+ ysct = ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
126
128
  result.concat api_map.get_complex_type_methods(ysct, '', false)
127
129
  end
128
130
  result
@@ -59,27 +59,27 @@ module Solargraph
59
59
  @pins.select{|pin| pin.kind == Pin::NAMESPACE and pin.location.range.contain?(position)}.last
60
60
  end
61
61
 
62
- def process_comment position, comment
62
+ def process_comment source_position, comment_position, comment
63
63
  return unless comment =~ MACRO_REGEXP
64
64
  cmnt = remove_inline_comment_hashes(comment)
65
65
  parse = YARD::Docstring.parser.parse(cmnt)
66
- parse.directives.each { |d| process_directive(position, d) }
66
+ parse.directives.each { |d| process_directive(source_position, comment_position, d) }
67
67
  end
68
68
 
69
69
  # @param position [Position]
70
70
  # @param directive [YARD::Tags::Directive]
71
- def process_directive position, directive
71
+ def process_directive source_position, comment_position, directive
72
72
  docstring = YARD::Docstring.parser.parse(directive.tag.text).to_docstring
73
- location = Location.new(@filename, Range.new(position, position))
73
+ location = Location.new(@filename, Range.new(comment_position, comment_position))
74
74
  case directive.tag.tag_name
75
75
  when 'method'
76
- namespace = namespace_at(position)
76
+ namespace = namespace_at(source_position)
77
77
  gen_src = Solargraph::SourceMap.load_string("def #{directive.tag.name};end")
78
78
  gen_pin = gen_src.pins.select{ |p| p.kind == Pin::METHOD }.first
79
79
  return if gen_pin.nil?
80
80
  @pins.push Solargraph::Pin::Method.new(location, namespace.path, gen_pin.name, docstring.all, :instance, :public, gen_pin.parameters, nil)
81
81
  when 'attribute'
82
- namespace = namespace_at(position)
82
+ namespace = namespace_at(source_position)
83
83
  t = (directive.tag.types.nil? || directive.tag.types.empty?) ? nil : directive.tag.types.flatten.join('')
84
84
  if t.nil? || t.include?('r')
85
85
  # location, namespace, name, docstring, access
@@ -90,16 +90,16 @@ module Solargraph
90
90
  end
91
91
  when 'parse'
92
92
  # @todo Parse and map directive.tag.text
93
- ns = namespace_at(position)
93
+ ns = namespace_at(comment_position)
94
94
  region = Region.new(source: @source, namespace: ns.path)
95
95
  begin
96
- node = Solargraph::Source.parse(directive.tag.text, @filename, position.line)
96
+ node = Solargraph::Source.parse(directive.tag.text, @filename, comment_position.line)
97
97
  NodeProcessor.process(node, region, @pins)
98
98
  rescue Parser::SyntaxError => e
99
99
  # @todo Handle parser errors in !parse directives
100
100
  end
101
101
  when 'domain'
102
- namespace = namespace_at(position)
102
+ namespace = namespace_at(source_position)
103
103
  namespace.domains.concat directive.tag.types unless directive.tag.types.nil?
104
104
  end
105
105
  end
@@ -126,11 +126,19 @@ module Solargraph
126
126
  # @return [void]
127
127
  def process_comment_directives
128
128
  return unless @code =~ MACRO_REGEXP
129
+ used = []
129
130
  @source.associated_comments.each do |line, comments|
130
- pos = Position.new(line, @code.lines[line].chomp.length)
131
+ used.concat comments
132
+ src_pos = Position.new(line, @code.lines[line].chomp.length)
133
+ com_pos = Position.new(comments.first.loc.line, comments.first.loc.column)
131
134
  txt = comments.map(&:text).join("\n")
132
- process_comment(pos, txt)
135
+ process_comment(src_pos, com_pos, txt)
133
136
  end
137
+ left = @comments - used
138
+ return if left.empty?
139
+ txt = left.map(&:text).join("\n")
140
+ com_pos = Position.new(left.first.loc.line, left.first.loc.column)
141
+ process_comment(com_pos, com_pos, txt)
134
142
  end
135
143
  end
136
144
  end
@@ -7,7 +7,7 @@ module Solargraph
7
7
  if methpin.name == 'initialize' and methpin.scope == :instance
8
8
  pins.push Solargraph::Pin::Method.new(methpin.location, methpin.namespace, 'new', methpin.comments, :class, :public, methpin.parameters, nil)
9
9
  # @todo Smelly instance variable access.
10
- pins.last.instance_variable_set(:@return_complex_type, ComplexType.parse(methpin.namespace))
10
+ pins.last.instance_variable_set(:@return_complex_type, ComplexType.try_parse(methpin.namespace))
11
11
  pins.push Solargraph::Pin::Method.new(methpin.location, methpin.namespace, methpin.name, methpin.comments, methpin.scope, :private, methpin.parameters, methpin.node)
12
12
  elsif region.visibility == :module_function
13
13
  pins.push Solargraph::Pin::Method.new(methpin.location, methpin.namespace, methpin.name, methpin.comments, :class, :public, methpin.parameters, methpin.node)
@@ -7,7 +7,7 @@ module Solargraph
7
7
  named_path = named_path_pin(here)
8
8
  pins.push Solargraph::Pin::InstanceVariable.new(get_node_location(node), region.namespace,node.children[0].to_s, comments_for(node), node.children[1], infer_literal_node_type(node.children[1]), named_path.context)
9
9
  if region.visibility == :module_function and named_path.kind == Pin::METHOD
10
- other = ComplexType.parse("Module<#{named_path.context.namespace}>")
10
+ other = ComplexType.try_parse("Module<#{named_path.context.namespace}>")
11
11
  pins.push Solargraph::Pin::InstanceVariable.new(get_node_location(node), region.namespace,node.children[0].to_s, comments_for(node), node.children[1], infer_literal_node_type(node.children[1]), other)
12
12
  end
13
13
  process_children
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.31.2'
2
+ VERSION = '0.31.3'
3
3
  end
Binary file
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.31.2
4
+ version: 0.31.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: 2019-01-28 00:00:00.000000000 Z
11
+ date: 2019-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport