Class: RBS::AST::Ruby::Declarations::ClassModuleAliasDecl
- Defined in:
- lib/rbs/ast/ruby/declarations.rb,
sig/ast/ruby/declarations.rbs
Instance Attribute Summary collapse
-
#annotation ⇒ annotation
readonly
Returns the value of attribute annotation.
-
#infered_old_name ⇒ TypeName?
readonly
The infered old name from the right-hand side of the constant declaration.
-
#leading_comment ⇒ CommentBlock?
readonly
Returns the value of attribute leading_comment.
-
#new_name ⇒ TypeName
readonly
Returns the value of attribute new_name.
-
#node ⇒ node
readonly
Returns the value of attribute node.
Attributes inherited from Base
Instance Method Summary collapse
- #comment ⇒ Comment?
-
#initialize(buffer, node, new_name, infered_old_name, leading_comment, annotation) ⇒ ClassModuleAliasDecl
constructor
A new instance of ClassModuleAliasDecl.
- #location ⇒ Location
- #name_location ⇒ Location
-
#old_name ⇒ TypeName
Returns the old name of the class/module alias.
- #type_fingerprint ⇒ Object
Methods included from Helpers::LocationHelper
Methods included from Helpers::ConstantHelper
constant_as_type_name, #self?.constant_as_type_name
Constructor Details
#initialize(buffer, node, new_name, infered_old_name, leading_comment, annotation) ⇒ ClassModuleAliasDecl
Returns a new instance of ClassModuleAliasDecl.
240 241 242 243 244 245 246 247 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 240 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 ⇒ annotation (readonly)
Returns the value of attribute annotation.
238 239 240 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 238 def annotation @annotation end |
#infered_old_name ⇒ TypeName? (readonly)
The infered old name from the right-hand side of the constant declaration
nilif the annotation has the type name
137 138 139 |
# File 'sig/ast/ruby/declarations.rbs', line 137 def infered_old_name @infered_old_name end |
#leading_comment ⇒ CommentBlock? (readonly)
Returns the value of attribute leading_comment.
235 236 237 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 235 def leading_comment @leading_comment end |
#new_name ⇒ TypeName (readonly)
Returns the value of attribute new_name.
236 237 238 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 236 def new_name @new_name end |
#node ⇒ node (readonly)
Returns the value of attribute node.
234 235 236 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 234 def node @node end |
Instance Method Details
#comment ⇒ Comment?
274 275 276 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 274 def comment leading_comment&.as_comment end |
#location ⇒ Location
249 250 251 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 249 def location rbs_location(node.location) end |
#name_location ⇒ Location
253 254 255 256 257 258 259 260 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 253 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 ⇒ TypeName
Returns the old name of the class/module alias
149 150 151 152 153 154 155 156 157 158 159 |
# File 'sig/ast/ruby/declarations.rbs', line 149 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 ⇒ Object
278 279 280 281 282 283 284 285 286 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 278 def type_fingerprint [ "decls/class_module_alias", annotation.type_fingerprint, new_name.to_s, old_name.to_s, leading_comment&.as_comment&.string ] end |