objc-dependency-tree-generator 0.1.1 → 0.1.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9823100e82dd479ef0369ea01c6af44d56a8436d
|
4
|
+
data.tar.gz: a7509d113c2a86dd69275197c7d4da30a702ce0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4ab14acc9f80042614181f534a72b43bc30b495aa881ba0c034c63ba8250294332302762d9d7172f280a0d3ae7a20533133c008a58164f17e3cb3887a74ae3
|
7
|
+
data.tar.gz: 5891dcab4930af269a8eb47c1ffa14fe006d772ae6da88994b503e2d7f7d6bbd9223070610ce57631f87d53018a1e14c84d5cb442c8ad951354650717497a762
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: objc-dependency-tree-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Taykalo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
-
dependencies:
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: swift-ast-dump-parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
13
27
|
description: |
|
14
28
|
Tool that allows to generate Objective-C and Swift dependency tree from object files
|
15
29
|
For usages examples run:
|
@@ -28,7 +42,6 @@ files:
|
|
28
42
|
- lib/objc_dependency_tree_generator.rb
|
29
43
|
- lib/sourcekitten/sourcekitten_dependencies_generator.rb
|
30
44
|
- lib/swift-ast-dump/swift_ast_dependencies_generator.rb
|
31
|
-
- lib/swift-ast-dump/swift_ast_parser.rb
|
32
45
|
- lib/swift/swift_dependencies_generator.rb
|
33
46
|
- lib/tree_serializer.rb
|
34
47
|
homepage: https://github.com/PaulTaykalo/objc-dependency-visualizer
|
@@ -1,218 +0,0 @@
|
|
1
|
-
module SwiftAST
|
2
|
-
autoload :StringScanner, 'strscan'
|
3
|
-
class Parser
|
4
|
-
def parse(string)
|
5
|
-
@scanner = StringScanner.new(string)
|
6
|
-
node = scan_children.first
|
7
|
-
node
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
def parse_build_log_output(string)
|
12
|
-
@scanner = StringScanner.new(string)
|
13
|
-
return unless @scanner.scan_until(/^\(source_file/)
|
14
|
-
|
15
|
-
@scanner.pos = @scanner.pos - 12
|
16
|
-
children = scan_children
|
17
|
-
|
18
|
-
return if children.empty?
|
19
|
-
Node.new("ast", [], children)
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
def scan_parameters
|
24
|
-
parameters = []
|
25
|
-
|
26
|
-
while true
|
27
|
-
@scanner.skip(/\s*/)
|
28
|
-
parameter = scan_parameter?
|
29
|
-
break unless parameter
|
30
|
-
parameters << parameter
|
31
|
-
end
|
32
|
-
|
33
|
-
parameters
|
34
|
-
end
|
35
|
-
|
36
|
-
def scan_parameters_from_types
|
37
|
-
first_param = @scanner.scan(/\d+:/)
|
38
|
-
return [] unless first_param
|
39
|
-
return [first_param] + scan_parameters
|
40
|
-
end
|
41
|
-
|
42
|
-
def scan_children(level = 0)
|
43
|
-
children = []
|
44
|
-
while true
|
45
|
-
return children unless whitespaces = whitespaces_at(level)
|
46
|
-
node_name = scan_name?
|
47
|
-
return children if node_name == "source_file" && level != 0 && unscan(node_name + whitespaces)
|
48
|
-
node_parameters = scan_parameters
|
49
|
-
|
50
|
-
node_children = scan_children(level + 1)
|
51
|
-
|
52
|
-
while next_params = scan_parameters_from_types # these are stupid params alike
|
53
|
-
break if next_params.empty?
|
54
|
-
node_parameters += next_params
|
55
|
-
node_children += scan_children(level + 1)
|
56
|
-
end
|
57
|
-
node = Node.new(node_name, node_parameters, node_children)
|
58
|
-
|
59
|
-
children << node
|
60
|
-
@scanner.scan(/(\s|\\|\n|\r|\t)*\)/)
|
61
|
-
end
|
62
|
-
children
|
63
|
-
end
|
64
|
-
|
65
|
-
def whitespaces_at(level = 0)
|
66
|
-
whitespaces = @scanner.scan(/(\s|\\|\n|\r|\t)*\(/)
|
67
|
-
if level == 0 && whitespaces.nil?
|
68
|
-
whitespaces = @scanner.scan(/.*?\(source_file/m)
|
69
|
-
return nil unless whitespaces
|
70
|
-
unscan("source_file")
|
71
|
-
end
|
72
|
-
whitespaces
|
73
|
-
end
|
74
|
-
|
75
|
-
def unscan(string)
|
76
|
-
@scanner.pos = @scanner.pos - string.length
|
77
|
-
end
|
78
|
-
|
79
|
-
def scan_name?
|
80
|
-
el_name = @scanner.scan(/#?[\w:]+/)
|
81
|
-
el_name
|
82
|
-
end
|
83
|
-
|
84
|
-
def scan_parameter?(is_parsing_rvalue = false)
|
85
|
-
#white spaces are skipped
|
86
|
-
|
87
|
-
# scan everything until space or opening sequence like ( < ' ".
|
88
|
-
# Since we can end up with closing bracket - we alos check for )
|
89
|
-
|
90
|
-
prefix = @scanner.scan(/[^\s()'"\[\\]+/) if is_parsing_rvalue
|
91
|
-
prefix = @scanner.scan(/[^\s()<'"\[\\=]+/) unless is_parsing_rvalue
|
92
|
-
|
93
|
-
next_char = @scanner.peek(1)
|
94
|
-
return nil unless next_char
|
95
|
-
should_unwrap_strings = !is_parsing_rvalue && !prefix
|
96
|
-
|
97
|
-
case next_char
|
98
|
-
when " " # next parameter
|
99
|
-
result = prefix
|
100
|
-
when "\\" # next parameter
|
101
|
-
@scanner.scan(/./)
|
102
|
-
result = prefix
|
103
|
-
|
104
|
-
when "\n" # next parameter
|
105
|
-
result = prefix
|
106
|
-
when ")" # closing bracket == end of element
|
107
|
-
result = prefix
|
108
|
-
when "\"" # doube quoted string
|
109
|
-
result = @scanner.scan(/./) + @scanner.scan_until(/"/)
|
110
|
-
result = result[1..-2] if should_unwrap_strings
|
111
|
-
result = (prefix || "") + result
|
112
|
-
when "'" # single quoted string
|
113
|
-
result = @scanner.scan(/./) + @scanner.scan_until(/'/)
|
114
|
-
result = result[1..-2] if should_unwrap_strings
|
115
|
-
result = (prefix || "") + result + (scan_parameter?(is_parsing_rvalue) || "")
|
116
|
-
when "<" # kinda generic
|
117
|
-
result = (prefix || "") + @scanner.scan(/./)
|
118
|
-
#in some cases this can be last char, just because we can end up with a=sdsd.function.<
|
119
|
-
result += @scanner.scan_until(/>/) + (scan_parameter?(is_parsing_rvalue) || "")
|
120
|
-
when "("
|
121
|
-
return nil if !prefix && !is_parsing_rvalue
|
122
|
-
result = (prefix || "") + @scanner.scan_until(/\)/) + (scan_parameter?(is_parsing_rvalue) || "")
|
123
|
-
when "["
|
124
|
-
result = (prefix || "") + scan_range + (scan_parameter?(is_parsing_rvalue) || "")
|
125
|
-
when "="
|
126
|
-
result = prefix + @scanner.scan(/./) + (scan_parameter?(true) || "")
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
# puts "prefix is '#{prefix}' ||#{is_parsing_rvalue} result =#{result}"
|
131
|
-
|
132
|
-
result
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
def scan_range
|
137
|
-
return unless @scanner.peek(1) == "["
|
138
|
-
result = @scanner.scan(/./)
|
139
|
-
|
140
|
-
while true
|
141
|
-
inside = @scanner.scan(/[^\]\[]+/) #everything but [ or ]
|
142
|
-
result += inside || ""
|
143
|
-
next_char = @scanner.peek(1)
|
144
|
-
|
145
|
-
return result + @scanner.scan(/./) if next_char == "]" # we found the end
|
146
|
-
result += scan_range if next_char == "["
|
147
|
-
raise "Unexpected character #{next_char} - [ or ] expected" if next_char != "[" && next_char != "]"
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
def scan_line_and_column
|
153
|
-
@scanner.scan(/:\d+:\d+/)
|
154
|
-
end
|
155
|
-
|
156
|
-
def isalpha(str)
|
157
|
-
!str.match(/[^A-Za-z@_]/)
|
158
|
-
end
|
159
|
-
def isAlphaDigit(str)
|
160
|
-
!str.match(/[^A-Za-z@_0-9]/)
|
161
|
-
end
|
162
|
-
def isalphaOrDot(str)
|
163
|
-
!str.match(/[^A-Za-z@_.,]/)
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
class Node
|
170
|
-
|
171
|
-
def initialize(name, parameters = [], children = [])
|
172
|
-
@name = name
|
173
|
-
@parameters = parameters
|
174
|
-
@children = children
|
175
|
-
end
|
176
|
-
|
177
|
-
def name
|
178
|
-
@name
|
179
|
-
end
|
180
|
-
|
181
|
-
def parameters
|
182
|
-
@parameters
|
183
|
-
end
|
184
|
-
|
185
|
-
def children
|
186
|
-
@children
|
187
|
-
end
|
188
|
-
|
189
|
-
def dump(level = 0)
|
190
|
-
@@line = 0 if level == 0
|
191
|
-
puts "\n" if level == 0
|
192
|
-
puts " " * level + "[#{@@line}][#{@name} #{@parameters}"
|
193
|
-
@@line = @@line + 1
|
194
|
-
@children.each { |child| child.dump(level + 1) }
|
195
|
-
end
|
196
|
-
|
197
|
-
def find_nodes(type)
|
198
|
-
found_nodes = []
|
199
|
-
@children.each { |child|
|
200
|
-
if child.name == type
|
201
|
-
found_nodes << child
|
202
|
-
else
|
203
|
-
found_nodes += child.find_nodes(type)
|
204
|
-
end
|
205
|
-
}
|
206
|
-
found_nodes
|
207
|
-
end
|
208
|
-
|
209
|
-
def on_node(type, &block)
|
210
|
-
@children.each { |child|
|
211
|
-
yield child if child.name == type
|
212
|
-
child.on_node(type, &block)
|
213
|
-
}
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|