solargraph 0.44.1 → 0.44.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/solargraph/parser/legacy/class_methods.rb +9 -3
- data/lib/solargraph/parser/legacy/node_processors/block_node.rb +13 -17
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +13 -17
- data/lib/solargraph/pin/local_variable.rb +1 -1
- data/lib/solargraph/pin/namespace.rb +2 -2
- data/lib/solargraph/source.rb +1 -1
- data/lib/solargraph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fd55900ebfdb84f10fa5ba2cb7e5fcc6dc7af0e51efe6a5d230ebaf497ec75c
|
4
|
+
data.tar.gz: 859e3d6738c17b1fc9241dbc4ed9e7f4fa117556bb7767915de0178fc2a50721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
53
|
-
|
54
|
-
eoff =
|
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
|
-
|
12
|
-
|
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
|
-
|
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
|
-
|
12
|
-
|
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
|
-
|
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)
|
data/lib/solargraph/source.rb
CHANGED
@@ -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
|
data/lib/solargraph/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|