Class: RBS::AST::Ruby::Members::DefMember

Inherits:
Base
  • Object
show all
Defined in:
lib/rbs/ast/ruby/members.rb

Constant Summary collapse

Overload =
AST::Members::MethodDefinition::Overload

Instance Attribute Summary collapse

Attributes inherited from Base

#buffer

Instance Method Summary collapse

Methods included from Helpers::LocationHelper

#rbs_location

Constructor Details

#initialize(buffer, name, node, method_type, leading_comment, kind: :instance) ⇒ DefMember

Returns a new instance of DefMember.



556
557
558
559
560
561
562
563
# File 'lib/rbs/ast/ruby/members.rb', line 556

def initialize(buffer, name, node, method_type, leading_comment, kind: :instance)
  super(buffer)
  @name = name
  @node = node
  @kind = kind
  @method_type = method_type
  @leading_comment = leading_comment
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



552
553
554
# File 'lib/rbs/ast/ruby/members.rb', line 552

def kind
  @kind
end

#leading_commentObject (readonly)

Returns the value of attribute leading_comment.



554
555
556
# File 'lib/rbs/ast/ruby/members.rb', line 554

def leading_comment
  @leading_comment
end

#method_typeObject (readonly)

Returns the value of attribute method_type.



553
554
555
# File 'lib/rbs/ast/ruby/members.rb', line 553

def method_type
  @method_type
end

#nameObject (readonly)

Returns the value of attribute name.



550
551
552
# File 'lib/rbs/ast/ruby/members.rb', line 550

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



551
552
553
# File 'lib/rbs/ast/ruby/members.rb', line 551

def node
  @node
end

Instance Method Details

#annotationsObject



585
586
587
# File 'lib/rbs/ast/ruby/members.rb', line 585

def annotations
  []
end

#instance?Boolean

Returns:

  • (Boolean)


569
570
571
# File 'lib/rbs/ast/ruby/members.rb', line 569

def instance?
  kind == :instance
end

#locationObject



573
574
575
# File 'lib/rbs/ast/ruby/members.rb', line 573

def location
  rbs_location(node.location)
end

#name_locationObject



589
590
591
# File 'lib/rbs/ast/ruby/members.rb', line 589

def name_location
  rbs_location(node.name_loc)
end

#overloading?Boolean

Returns:

  • (Boolean)


581
582
583
# File 'lib/rbs/ast/ruby/members.rb', line 581

def overloading?
  method_type.overloading?
end

#overloadsObject



577
578
579
# File 'lib/rbs/ast/ruby/members.rb', line 577

def overloads
  method_type.overloads
end

#singleton?Boolean

Returns:

  • (Boolean)


565
566
567
# File 'lib/rbs/ast/ruby/members.rb', line 565

def singleton?
  kind == :singleton
end

#type_fingerprintObject



593
594
595
596
597
598
599
600
601
# File 'lib/rbs/ast/ruby/members.rb', line 593

def type_fingerprint
  [
    "members/def",
    kind.to_s,
    name.to_s,
    method_type.type_fingerprint,
    leading_comment&.as_comment&.string
  ]
end