solargraph 0.44.1 → 0.44.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
  SHA256:
3
- metadata.gz: 346926f891270e103d6c7170fe5897587c1d5da45ea33b2a7f4238914b38b236
4
- data.tar.gz: 451b09bf70dc9d760ebfdeb726821e6e653f196bd867da8c7638888803e33a72
3
+ metadata.gz: 8fd55900ebfdb84f10fa5ba2cb7e5fcc6dc7af0e51efe6a5d230ebaf497ec75c
4
+ data.tar.gz: 859e3d6738c17b1fc9241dbc4ed9e7f4fa117556bb7767915de0178fc2a50721
5
5
  SHA512:
6
- metadata.gz: 624d1de49ef2762477d7a413adf282a058143a71689ea8cdfcc91177db94c765b997fca00fefd8d0d4915e44e6cd4ae1867297671611ba6d119d610116c5b80a
7
- data.tar.gz: 9f146a371e075407cb8be7b96de08ff24583cf18eb1a29310c1a711c1bd347715d07b0ff6603e9a98b71be7406148e17c907abdcf3bd1a2aba58bd5aeff14685
6
+ metadata.gz: fb53ed887a2d25be28655486de35cb87deac7a604eae688bc20be8c34a696dc86d9dbcf6d069f908316078d653e06f4f00154e23eae411876a8f5cd191dfa51d
7
+ data.tar.gz: f7e65200040c8a2bfd7f73e4ad7aa718dc7378fcb99850802fcd2b7ab212b59cf6ae215e21dcd7f1158291551ab211bc836113e9c06d389f6c17fb69de27457f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.44.2 - November 23, 2021
2
+ - Scope local variables in class_eval blocks (#503)
3
+ - Fix invalid UTF-8 in node comments (#504)
4
+
1
5
  ## 0.44.1 - November 18, 2021
2
6
  - Chain nil safety navigation operator (#420)
3
7
  - Update closure and context for class_eval receiver (#487)
@@ -48,10 +48,16 @@ module Solargraph
48
48
  end
49
49
 
50
50
  def references source, name
51
+ if name.end_with?("=")
52
+ reg = /#{Regexp.escape name[0..-2]}\s*=/
53
+ extract_offset = ->(code, offset) { reg.match(code, offset).offset(0) }
54
+ else
55
+ extract_offset = ->(code, offset) { [soff = code.index(name, offset), soff + name.length] }
56
+ end
51
57
  inner_node_references(name, source.node).map do |n|
52
- offset = Position.to_offset(source.code, NodeMethods.get_node_start_position(n))
53
- soff = source.code.index(name, offset)
54
- eoff = soff + name.length
58
+ rng = Range.from_node(n)
59
+ offset = Position.to_offset(source.code, rng.start)
60
+ soff, eoff = extract_offset[source.code, offset]
55
61
  Location.new(
56
62
  source.filename,
57
63
  Range.new(
@@ -8,17 +8,24 @@ module Solargraph
8
8
  include Legacy::NodeMethods
9
9
 
10
10
  def process
11
- if other_class_eval?
12
- other_class = Solargraph::Pin::Namespace.new(
11
+ location = get_node_location(node)
12
+ parent = if other_class_eval?
13
+ Solargraph::Pin::Namespace.new(
14
+ location: location,
13
15
  type: :class,
14
16
  name: unpack_name(node.children[0].children[0])
15
17
  )
16
- make_block_in other_class.context
17
- process_children region.update(closure: other_class)
18
18
  else
19
- make_block_in nil
20
- process_children region.update(closure: pins.last)
19
+ region.closure
21
20
  end
21
+ pins.push Solargraph::Pin::Block.new(
22
+ location: location,
23
+ closure: parent,
24
+ receiver: node.children[0],
25
+ comments: comments_for(node),
26
+ scope: region.scope || region.closure.context.scope
27
+ )
28
+ process_children region.update(closure: pins.last)
22
29
  end
23
30
 
24
31
  private
@@ -28,17 +35,6 @@ module Solargraph
28
35
  node.children[0].children[1] == :class_eval &&
29
36
  [:cbase, :const].include?(node.children[0].children[0]&.type)
30
37
  end
31
-
32
- def make_block_in context
33
- pins.push Solargraph::Pin::Block.new(
34
- location: get_node_location(node),
35
- context: context,
36
- closure: region.closure,
37
- receiver: node.children[0],
38
- comments: comments_for(node),
39
- scope: region.scope || region.closure.context.scope
40
- )
41
- end
42
38
  end
43
39
  end
44
40
  end
@@ -8,17 +8,24 @@ module Solargraph
8
8
  include NodeMethods
9
9
 
10
10
  def process
11
- if other_class_eval?
12
- other_class = Solargraph::Pin::Namespace.new(
11
+ location = get_node_location(node)
12
+ parent = if other_class_eval?
13
+ Solargraph::Pin::Namespace.new(
14
+ location: location,
13
15
  type: :class,
14
16
  name: unpack_name(node.children[0].children[0])
15
17
  )
16
- make_block_in other_class.context
17
- process_children region.update(closure: other_class)
18
18
  else
19
- make_block_in nil
20
- process_children region.update(closure: pins.last)
19
+ region.closure
21
20
  end
21
+ pins.push Solargraph::Pin::Block.new(
22
+ location: location,
23
+ closure: parent,
24
+ receiver: node.children[0],
25
+ comments: comments_for(node),
26
+ scope: region.scope || region.closure.context.scope
27
+ )
28
+ process_children region.update(closure: pins.last)
22
29
  end
23
30
 
24
31
  private
@@ -28,17 +35,6 @@ module Solargraph
28
35
  node.children[0].children[1] == :class_eval &&
29
36
  [:COLON2, :CONST].include?(node.children[0].children[0].type)
30
37
  end
31
-
32
- def make_block_in context
33
- pins.push Solargraph::Pin::Block.new(
34
- location: get_node_location(node),
35
- context: context,
36
- closure: region.closure,
37
- receiver: node.children[0],
38
- comments: comments_for(node),
39
- scope: region.scope || region.closure.context.scope
40
- )
41
- end
42
38
  end
43
39
  end
44
40
  end
@@ -41,7 +41,7 @@ module Solargraph
41
41
  end
42
42
 
43
43
  def match_named_closure needle, haystack
44
- return true if needle == haystack
44
+ return true if needle == haystack || haystack.is_a?(Pin::Block)
45
45
  cursor = haystack
46
46
  until cursor.nil?
47
47
  return true if needle.path == cursor.path
@@ -9,8 +9,8 @@ module Solargraph
9
9
  # @return [::Symbol] :class or :module
10
10
  attr_reader :type
11
11
 
12
- # @param type [Symbol] :class or :module
13
- # @param visibility [Symbol] :public or :private
12
+ # @param type [::Symbol] :class or :module
13
+ # @param visibility [::Symbol] :public or :private
14
14
  # @param gates [Array<String>]
15
15
  def initialize type: :class, visibility: :public, gates: [''], **splat
16
16
  # super(location, namespace, name, comments)
@@ -360,7 +360,7 @@ module Solargraph
360
360
  skip = nil
361
361
  comments.lines.each { |l|
362
362
  # Trim the comment and minimum leading whitespace
363
- p = l.gsub(/^#+/, '')
363
+ p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
364
364
  if p.strip.empty?
365
365
  next unless started
366
366
  ctxt.concat p
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.44.1'
4
+ VERSION = '0.44.2'
5
5
  end
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.44.1
4
+ version: 0.44.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-18 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport