123456789_123456789_123456789_123456789_123456789_

Class: RBS::AST::Ruby::Declarations::ClassModuleAliasDecl

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
Inherits: RBS::AST::Ruby::Declarations::Base
Defined in: lib/rbs/ast/ruby/declarations.rb

Class Method Summary

Instance Attribute Summary

Base - Inherited

Instance Method Summary

Constructor Details

.new(buffer, node, new_name, infered_old_name, leading_comment, annotation) ⇒ ClassModuleAliasDecl

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 230

def initialize(buffer, node, new_name, infered_old_name, leading_comment, annotation)
  super(buffer)
  @node = node
  @new_name = new_name
  @infered_old_name = infered_old_name
  @leading_comment = leading_comment
  @annotation = annotation
end

Instance Attribute Details

#annotation (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 228

attr_reader :annotation

#infered_old_name (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 227

attr_reader :infered_old_name

#leading_comment (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 225

attr_reader :leading_comment

#new_name (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 226

attr_reader :new_name

#node (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 224

attr_reader :node

Instance Method Details

#comment

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 264

def comment
  leading_comment&.as_comment
end

#location

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 239

def location
  rbs_location(node.location)
end

#name_location

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 243

def name_location
  case node
  when Prism::ConstantWriteNode
    rbs_location(node.name_loc)
  when Prism::ConstantPathWriteNode
    rbs_location(node.target.location)
  end
end

#old_name

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 252

def old_name
  # Return explicit type name from annotation if provided, otherwise use inferred name
  case
  when annotation.type_name
    annotation.type_name
  when infered_old_name
    infered_old_name
  else
    raise "No old name available"
  end
end

#type_fingerprint

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/declarations.rb', line 268

def type_fingerprint
  [
    "decls/class_module_alias",
    annotation.type_fingerprint,
    new_name.to_s,
    old_name.to_s,
    leading_comment&.as_comment&.string
  ]
end