Class: RBI::Tree
- Inherits:
-
NodeWithComments
show all
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/index.rb,
lib/rbi/model.rb,
lib/rbi/rewriters/annotate.rb,
lib/rbi/rewriters/deannotate.rb,
lib/rbi/rewriters/sort_nodes.rb,
lib/rbi/rewriters/group_nodes.rb,
lib/rbi/rewriters/merge_trees.rb,
lib/rbi/rewriters/attr_to_methods.rb,
lib/rbi/rewriters/filter_versions.rb,
lib/rbi/rewriters/add_sig_templates.rb,
lib/rbi/rewriters/flatten_visibilities.rb,
lib/rbi/rewriters/nest_singleton_methods.rb,
lib/rbi/rewriters/nest_top_level_members.rb,
lib/rbi/rewriters/nest_non_public_members.rb,
lib/rbi/rewriters/flatten_singleton_methods.rb
Instance Attribute Summary collapse
#comments
Attributes inherited from Node
#loc, #parent_tree
Instance Method Summary
collapse
#annotations, #merge_with, #version_requirements
Methods inherited from Node
#compatible_with?, #detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string
Constructor Details
#initialize(loc: nil, comments: [], &block) ⇒ Tree
Returns a new instance of Tree.
121
122
123
124
125
|
# File 'lib/rbi/model.rb', line 121
def initialize(loc: nil, comments: [], &block)
super(loc: loc, comments: )
@nodes = T.let([], T::Array[Node])
block&.call(self)
end
|
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
112
113
114
|
# File 'lib/rbi/model.rb', line 112
def nodes
@nodes
end
|
Instance Method Details
#<<(node) ⇒ Object
128
129
130
131
|
# File 'lib/rbi/model.rb', line 128
def <<(node)
node.parent_tree = self
@nodes << node
end
|
#add_sig_templates!(with_todo_comment: true) ⇒ Object
66
67
68
69
|
# File 'lib/rbi/rewriters/add_sig_templates.rb', line 66
def add_sig_templates!(with_todo_comment: true)
visitor = Rewriters::AddSigTemplates.new(with_todo_comment: )
visitor.visit(self)
end
|
#annotate!(annotation, annotate_scopes: false, annotate_properties: false) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/rbi/rewriters/annotate.rb', line 49
def annotate!(annotation, annotate_scopes: false, annotate_properties: false)
visitor = Rewriters::Annotate.new(
annotation,
annotate_scopes: annotate_scopes,
annotate_properties: annotate_properties,
)
visitor.visit(self)
end
|
#deannotate!(annotation) ⇒ Object
41
42
43
44
|
# File 'lib/rbi/rewriters/deannotate.rb', line 41
def deannotate!(annotation)
visitor = Rewriters::Deannotate.new(annotation)
visitor.visit(self)
end
|
#empty? ⇒ Boolean
134
135
136
|
# File 'lib/rbi/model.rb', line 134
def empty?
nodes.empty?
end
|
#filter_versions!(version) ⇒ Object
118
119
120
121
|
# File 'lib/rbi/rewriters/filter_versions.rb', line 118
def filter_versions!(version)
visitor = Rewriters::FilterVersions.new(version)
visitor.visit(self)
end
|
#flatten_singleton_methods! ⇒ Object
60
61
62
63
|
# File 'lib/rbi/rewriters/flatten_singleton_methods.rb', line 60
def flatten_singleton_methods!
visitor = Rewriters::FlattenSingletonMethods.new
visitor.visit(self)
end
|
#flatten_visibilities! ⇒ Object
60
61
62
63
|
# File 'lib/rbi/rewriters/flatten_visibilities.rb', line 60
def flatten_visibilities!
visitor = Rewriters::FlattenVisibilities.new
visitor.visit(self)
end
|
#group_nodes! ⇒ Object
81
82
83
84
|
# File 'lib/rbi/rewriters/group_nodes.rb', line 81
def group_nodes!
visitor = Rewriters::GroupNodes.new
visitor.visit(self)
end
|
#index ⇒ Object
68
69
70
|
# File 'lib/rbi/index.rb', line 68
def index
Index.index(self)
end
|
#merge(other, left_name: "left", right_name: "right", keep: Rewriters::Merge::Keep::NONE) ⇒ Object
324
325
326
|
# File 'lib/rbi/rewriters/merge_trees.rb', line 324
def merge(other, left_name: "left", right_name: "right", keep: Rewriters::Merge::Keep::NONE)
Rewriters::Merge.merge_trees(self, other, left_name: left_name, right_name: right_name, keep: keep)
end
|
#nest_non_public_members! ⇒ Object
46
47
48
49
|
# File 'lib/rbi/rewriters/nest_non_public_members.rb', line 46
def nest_non_public_members!
visitor = Rewriters::NestNonPublicMembers.new
visitor.visit(self)
end
|
#nest_singleton_methods! ⇒ Object
36
37
38
39
|
# File 'lib/rbi/rewriters/nest_singleton_methods.rb', line 36
def nest_singleton_methods!
visitor = Rewriters::NestSingletonMethods.new
visitor.visit(self)
end
|
#nest_top_level_members! ⇒ Object
63
64
65
66
|
# File 'lib/rbi/rewriters/nest_top_level_members.rb', line 63
def nest_top_level_members!
visitor = Rewriters::NestTopLevelMembers.new
visitor.visit(self)
end
|
#replace_attributes_with_methods! ⇒ Object
53
54
55
56
|
# File 'lib/rbi/rewriters/attr_to_methods.rb', line 53
def replace_attributes_with_methods!
visitor = Rewriters::AttrToMethods.new
visitor.visit(self)
end
|
#sort_nodes! ⇒ Object
119
120
121
122
|
# File 'lib/rbi/rewriters/sort_nodes.rb', line 119
def sort_nodes!
visitor = Rewriters::SortNodes.new
visitor.visit(self)
end
|