class SwiftAST::Node
Public Class Methods
new(name, parameters = [], children = [])
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 178 def initialize(name, parameters = [], children = []) @name = name @parameters = parameters @children = children end
Public Instance Methods
children()
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 192 def children @children end
dump(level = 0)
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 196 def dump(level = 0) @@line = 0 if level == 0 puts "\n" if level == 0 puts " " * level + "[#{@@line}][#{@name} #{@parameters}" @@line = @@line + 1 @children.each { |child| child.dump(level + 1) } end
find_nodes(type)
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 204 def find_nodes(type) found_nodes = [] @children.each { |child| if child.name == type found_nodes << child else found_nodes += child.find_nodes(type) end } found_nodes end
name()
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 184 def name @name end
on_node(type) { |child| ... }
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 216 def on_node(type, &block) @children.each { |child| yield child if child.name == type child.on_node(type, &block) } end
parameters()
click to toggle source
# File lib/swift_ast_dump_parser.rb, line 188 def parameters @parameters end