class RBI::Node

Attributes

loc[RW]
parent_tree[RW]

Public Class Methods

new(loc: nil) click to toggle source
# File lib/rbi/model.rb, line 18
def initialize(loc: nil)
  @parent_tree = nil
  @loc = loc
end

Public Instance Methods

accept_printer(v) click to toggle source
# File lib/rbi/printer.rb, line 124
def accept_printer(v); end
compatible_with?(_other) click to toggle source
# File lib/rbi/rewriters/merge_trees.rb, line 283
def compatible_with?(_other)
  true
end
detach() click to toggle source
# File lib/rbi/model.rb, line 24
def detach
  tree = parent_tree
  return unless tree
  tree.nodes.delete(self)
  self.parent_tree = nil
end
group_kind() click to toggle source
# File lib/rbi/rewriters/group_nodes.rb, line 48
def group_kind
  case self
  when Include, Extend
    Group::Kind::Mixins
  when Helper
    Group::Kind::Helpers
  when TypeMember
    Group::Kind::TypeMembers
  when MixesInClassMethods
    Group::Kind::MixesInClassMethods
  when TStructField
    Group::Kind::TStructFields
  when TEnumBlock
    Group::Kind::TEnums
  when VisibilityGroup
    Group::Kind::Methods
  when Method
    if name == "initialize"
      Group::Kind::Inits
    else
      Group::Kind::Methods
    end
  when Scope, Const
    Group::Kind::Consts
  else
    raise "Unknown group for #{self}"
  end
end
merge_with(other) click to toggle source
# File lib/rbi/rewriters/merge_trees.rb, line 289
def merge_with(other); end
oneline?() click to toggle source
# File lib/rbi/printer.rb, line 140
def oneline?
  true
end
parent_conflict_tree() click to toggle source
# File lib/rbi/rewriters/merge_trees.rb, line 292
def parent_conflict_tree
  parent = T.let(parent_tree, T.nilable(Node))
  while parent
    return parent if parent.is_a?(ConflictTree)
    parent = parent.parent_tree
  end
  nil
end
parent_scope() click to toggle source
# File lib/rbi/model.rb, line 43
def parent_scope
  parent = T.let(parent_tree, T.nilable(Tree))
  parent = parent.parent_tree until parent.is_a?(Scope) || parent.nil?
  parent
end
print(out: $stdout, indent: 0, print_locs: false) click to toggle source
replace(node) click to toggle source
# File lib/rbi/model.rb, line 32
def replace(node)
  tree = parent_tree
  raise unless tree
  index = tree.nodes.index(self)
  raise unless index
  tree.nodes[index] = node
  node.parent_tree = tree
  self.parent_tree = nil
end
string(indent: 0, print_locs: false) click to toggle source
# File lib/rbi/printer.rb, line 133
def string(indent: 0, print_locs: false)
  out = StringIO.new
  print(out: out, indent: indent, print_locs: print_locs)
  out.string
end