node_query 1.15.0 → 1.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/node_query/adapter/prism.rb +21 -3
- data/lib/node_query/adapter/syntax_tree.rb +2 -9
- data/lib/node_query/version.rb +1 -1
- data/lib/node_query.rb +2 -0
- 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: 9b7a968afbfc580614cb1647fd59933e29ca42a51f16bd94d83bfdd2ff6d76f3
|
4
|
+
data.tar.gz: a58361e9a486604fd35e5645528ddb3ad1bf49f314ed704e57954678dfac9d78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2468e0e6e5fc5b2fe8d9f93e9169394552991a6813af79428d14d6740b206a4f8e4b1eb37c8b7bbea826daf96157bd571d57ac0afdb302b0271ea2be8ffe088c
|
7
|
+
data.tar.gz: feecda8504d3b2477a3152b2993cd8b18a301d9f2e07f09e523b2a4cbed8791369ddffcf3c727dd5b059b34cf52aeec83b507451d14c9f4129aef177552022aa
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,7 +9,7 @@ class NodeQuery::PrismAdapter
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_node_type(node)
|
12
|
-
node.
|
12
|
+
node.type
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_source(node)
|
@@ -17,11 +17,29 @@ class NodeQuery::PrismAdapter
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get_children(node)
|
20
|
-
|
20
|
+
keys = []
|
21
|
+
children = []
|
22
|
+
node.deconstruct_keys([]).each do |key, value|
|
23
|
+
next if [:flags, :location].include?(key)
|
24
|
+
|
25
|
+
if key.to_s.end_with?('_loc')
|
26
|
+
new_key = key.to_s[0..-5]
|
27
|
+
unless keys.include?(new_key)
|
28
|
+
keys << new_key
|
29
|
+
children << node.send(new_key)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
unless keys.include?(key.to_s)
|
33
|
+
keys << key.to_s
|
34
|
+
children << value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
children
|
21
39
|
end
|
22
40
|
|
23
41
|
def get_siblings(node)
|
24
|
-
child_nodes = node.parent_node
|
42
|
+
child_nodes = get_children(node.parent_node)
|
25
43
|
if child_nodes.is_a?(Array) && child_nodes.size == 1 && child_nodes.first.is_a?(Array)
|
26
44
|
index = child_nodes.first.index(node)
|
27
45
|
return child_nodes.first[index + 1...]
|
@@ -3,14 +3,6 @@
|
|
3
3
|
require 'syntax_tree'
|
4
4
|
require 'syntax_tree_ext'
|
5
5
|
|
6
|
-
if RUBY_VERSION.to_i < 3
|
7
|
-
class Hash
|
8
|
-
def except(*keys)
|
9
|
-
self.reject { |k, _| keys.include?(k) }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
6
|
class NodeQuery::SyntaxTreeAdapter
|
15
7
|
def is_node?(node)
|
16
8
|
node.is_a?(SyntaxTree::Node)
|
@@ -25,7 +17,8 @@ class NodeQuery::SyntaxTreeAdapter
|
|
25
17
|
end
|
26
18
|
|
27
19
|
def get_children(node)
|
28
|
-
node.deconstruct_keys([]).
|
20
|
+
node.deconstruct_keys([]).filter { |key, _value| ![:location, :comments].include?(key) }
|
21
|
+
.values
|
29
22
|
end
|
30
23
|
|
31
24
|
def get_siblings(node)
|
data/lib/node_query/version.rb
CHANGED
data/lib/node_query.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: node_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ast node query language
|
14
14
|
email:
|