Class: RBS::AST::Ruby::Members::AttributeMember
- Defined in:
- lib/rbs/ast/ruby/members.rb,
sig/ast/ruby/members.rbs
Direct Known Subclasses
Instance Attribute Summary collapse
-
#leading_comment ⇒ CommentBlock?
readonly
Returns the value of attribute leading_comment.
-
#name_nodes ⇒ Array[Prism::SymbolNode]
readonly
Returns the value of attribute name_nodes.
-
#node ⇒ Prism::CallNode
readonly
Returns the value of attribute node.
-
#type_annotation ⇒ Annotations::NodeTypeAssertion?
readonly
Returns the value of attribute type_annotation.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(buffer, node, name_nodes, leading_comment, type_annotation) ⇒ AttributeMember
constructor
A new instance of AttributeMember.
- #location ⇒ Location
- #name_locations ⇒ Array[Location]
- #names ⇒ Array[Symbol]
- #type ⇒ Types::t?
- #type_fingerprint ⇒ Object
Methods included from Helpers::LocationHelper
Constructor Details
#initialize(buffer, node, name_nodes, leading_comment, type_annotation) ⇒ AttributeMember
Returns a new instance of AttributeMember.
656 657 658 659 660 661 662 |
# File 'lib/rbs/ast/ruby/members.rb', line 656 def initialize(buffer, node, name_nodes, leading_comment, type_annotation) super(buffer) @node = node @name_nodes = name_nodes @leading_comment = leading_comment @type_annotation = type_annotation end |
Instance Attribute Details
#leading_comment ⇒ CommentBlock? (readonly)
Returns the value of attribute leading_comment.
654 655 656 |
# File 'lib/rbs/ast/ruby/members.rb', line 654 def leading_comment @leading_comment end |
#name_nodes ⇒ Array[Prism::SymbolNode] (readonly)
Returns the value of attribute name_nodes.
652 653 654 |
# File 'lib/rbs/ast/ruby/members.rb', line 652 def name_nodes @name_nodes end |
#node ⇒ Prism::CallNode (readonly)
Returns the value of attribute node.
651 652 653 |
# File 'lib/rbs/ast/ruby/members.rb', line 651 def node @node end |
#type_annotation ⇒ Annotations::NodeTypeAssertion? (readonly)
Returns the value of attribute type_annotation.
653 654 655 |
# File 'lib/rbs/ast/ruby/members.rb', line 653 def type_annotation @type_annotation end |
Instance Method Details
#location ⇒ Location
670 671 672 |
# File 'lib/rbs/ast/ruby/members.rb', line 670 def location rbs_location(node.location) end |
#name_locations ⇒ Array[Location]
674 675 676 677 678 |
# File 'lib/rbs/ast/ruby/members.rb', line 674 def name_locations name_nodes.map do |name_node| rbs_location(name_node.location) end end |
#names ⇒ Array[Symbol]
664 665 666 667 668 |
# File 'lib/rbs/ast/ruby/members.rb', line 664 def names name_nodes.map do |node| node.unescaped.to_sym end end |
#type ⇒ Types::t?
680 681 682 |
# File 'lib/rbs/ast/ruby/members.rb', line 680 def type type_annotation&.type end |
#type_fingerprint ⇒ Object
684 685 686 687 688 689 690 691 692 |
# File 'lib/rbs/ast/ruby/members.rb', line 684 def type_fingerprint [ "members/attribute", self.class.name, names.map(&:to_s), type_annotation&.type_fingerprint, leading_comment&.as_comment&.string ] end |