class IcAgent::Ast::Nodes::TypeDeclaration
Represents a type declaration node in the abstract syntax tree, a subclass of NamedNode
.
Public Instance Methods
title()
click to toggle source
The title of the type declaration node.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 74 def title :type_declaration end
to_obj()
click to toggle source
Converts the type declaration node to a hash representation.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 126 def to_obj { 'type_param_name' => type_param_name, 'type_root_opt_code' => type_root_opt_code, 'type_child_item_keys' => type_child_item_keys, 'type_child_item_values' => type_refer_items } end
to_s()
click to toggle source
Converts the type declaration node to a string representation.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 121 def to_s text_value end
type_child_item_keys()
click to toggle source
Returns an array of keys of type child items.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 103 def type_child_item_keys names = [] type_child_items.each do |ele| names << ele.elements[0].text_value.strip end names end
type_child_items()
click to toggle source
Returns an array of type child items.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 94 def type_child_items if elements && elements[1] && elements[1].elements && elements[1].elements[0] elements[1].elements[0].elements else [] end end
type_param_content()
click to toggle source
Returns the content of the type parameter without newlines and trailing ';}' replaced with '}'.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 84 def type_param_content elements[1].source_content.gsub("\n", '').gsub(';}', '}') end
type_param_name()
click to toggle source
Returns the name of the type parameter.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 79 def type_param_name elements[0].source_content end
type_refer_items()
click to toggle source
Returns an array of referenced types in the type parameter content.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 112 def type_refer_items source_string = self.type_param_content parser = IcAgent::Ast::StatementParser.new parser.parse(source_string) refer_type = parser.source_tree.content[:refer_type] refer_type end
type_root_opt_code()
click to toggle source
Returns the opt code of the root type element.
# File lib/ic_agent/ast/nodes/named_nodes.rb, line 89 def type_root_opt_code elements[1].opt_code end