Class: RBS::AST::Ruby::Declarations::ClassModuleAliasDecl
- Defined in:
- lib/rbs/ast/ruby/declarations.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
readonly
Returns the value of attribute annotation.
-
#infered_old_name ⇒ Object
readonly
Returns the value of attribute infered_old_name.
-
#leading_comment ⇒ Object
readonly
Returns the value of attribute leading_comment.
-
#new_name ⇒ Object
readonly
Returns the value of attribute new_name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Attributes inherited from Base
Instance Method Summary collapse
- #comment ⇒ Object
-
#initialize(buffer, node, new_name, infered_old_name, leading_comment, annotation) ⇒ ClassModuleAliasDecl
constructor
A new instance of ClassModuleAliasDecl.
- #location ⇒ Object
- #name_location ⇒ Object
- #old_name ⇒ Object
- #type_fingerprint ⇒ Object
Methods included from Helpers::LocationHelper
Methods included from Helpers::ConstantHelper
Constructor Details
#initialize(buffer, node, new_name, infered_old_name, leading_comment, annotation) ⇒ ClassModuleAliasDecl
Returns a new instance of ClassModuleAliasDecl.
230 231 232 233 234 235 236 237 |
# 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 ⇒ Object (readonly)
Returns the value of attribute annotation.
228 229 230 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 228 def annotation @annotation end |
#infered_old_name ⇒ Object (readonly)
Returns the value of attribute infered_old_name.
227 228 229 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 227 def infered_old_name @infered_old_name end |
#leading_comment ⇒ Object (readonly)
Returns the value of attribute leading_comment.
225 226 227 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 225 def leading_comment @leading_comment end |
#new_name ⇒ Object (readonly)
Returns the value of attribute new_name.
226 227 228 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 226 def new_name @new_name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
224 225 226 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 224 def node @node end |
Instance Method Details
#comment ⇒ Object
264 265 266 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 264 def comment leading_comment&.as_comment end |
#location ⇒ Object
239 240 241 |
# File 'lib/rbs/ast/ruby/declarations.rb', line 239 def location rbs_location(node.location) end |
#name_location ⇒ Object
243 244 245 246 247 248 249 250 |
# 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 ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 |
# 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 ⇒ Object
268 269 270 271 272 273 274 275 276 |
# 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 |