prism_ext 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/prism_ext/version.rb +1 -1
- data/lib/prism_ext.rb +31 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 695e9d8152060370e01e3f95624c4008015551a06ccd12c283e85e7a1bb59f11
|
4
|
+
data.tar.gz: a94e3ff7e5e9befb6500f44dc6b25b9c360e28f1356b6e17532842ffa58a7cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04ec3cb586628e36ab5ec8ff22e9d8f20e5e9d17b2fae2291bb921fb81e679fa7ba28b3984d4a7064c22025d9bc93bf3665f0d248fb57cb15cbe60894e5b817a
|
7
|
+
data.tar.gz: c5a4534721f7a4d36737f77dcf901c0db0d90506bb94ee30dae9b247b89ce1a73303baa69428bc1a14ef15e10e2e88a0a8d3335adfa404bac4ca9784dd08b676
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/prism_ext/version.rb
CHANGED
data/lib/prism_ext.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "prism_ext/version"
|
4
|
+
|
4
5
|
require 'prism'
|
5
6
|
|
6
7
|
module PrismExt
|
@@ -9,7 +10,37 @@ module PrismExt
|
|
9
10
|
end
|
10
11
|
|
11
12
|
module Prism
|
13
|
+
class << self
|
14
|
+
alias_method :original_parse, :parse
|
15
|
+
|
16
|
+
def parse(source)
|
17
|
+
result = original_parse(source)
|
18
|
+
result.value.set_parent_node
|
19
|
+
result
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
class Node
|
24
|
+
attr_accessor :parent_node
|
25
|
+
|
26
|
+
def set_parent_node
|
27
|
+
self.child_nodes.each do |child_node|
|
28
|
+
if child_node.is_a?(Array)
|
29
|
+
child_node.each do |child_child_node|
|
30
|
+
next unless child_child_node.is_a?(Node)
|
31
|
+
|
32
|
+
child_child_node.parent_node = self
|
33
|
+
child_child_node.set_parent_node
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
next unless child_node.is_a?(Node)
|
38
|
+
|
39
|
+
child_node.parent_node = self
|
40
|
+
child_node.set_parent_node
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
13
44
|
def source
|
14
45
|
location.instance_variable_get(:@source).source
|
15
46
|
end
|