Class: TreeHaver::Backends::Java::Node
- Inherits:
-
Object
- Object
- TreeHaver::Backends::Java::Node
- Defined in:
- lib/tree_haver/backends/java.rb
Overview
Wrapper for java-tree-sitter Node
Instance Attribute Summary collapse
-
#impl ⇒ Object
readonly
Returns the value of attribute impl.
Instance Method Summary collapse
-
#child(index) ⇒ Node
Get a child by index.
-
#child_count ⇒ Integer
Get the number of children.
-
#each {|Node| ... } ⇒ void
Iterate over children.
-
#end_byte ⇒ Integer
Get the end byte position.
-
#end_point ⇒ Hash
Get the end point (row, column).
-
#has_error? ⇒ Boolean
Check if this node has an error.
-
#initialize(impl) ⇒ Node
constructor
private
A new instance of Node.
-
#missing? ⇒ Boolean
Check if this node is missing.
-
#start_byte ⇒ Integer
Get the start byte position.
-
#start_point ⇒ Hash
Get the start point (row, column).
-
#text ⇒ String
Get the text of this node.
-
#type ⇒ String
Get the type of this node.
Constructor Details
#initialize(impl) ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Node.
530 531 532 |
# File 'lib/tree_haver/backends/java.rb', line 530 def initialize(impl) @impl = impl end |
Instance Attribute Details
#impl ⇒ Object (readonly)
Returns the value of attribute impl.
527 528 529 |
# File 'lib/tree_haver/backends/java.rb', line 527 def impl @impl end |
Instance Method Details
#child(index) ⇒ Node
Get a child by index
552 553 554 |
# File 'lib/tree_haver/backends/java.rb', line 552 def child(index) Node.new(@impl.child(index)) end |
#child_count ⇒ Integer
Get the number of children
544 545 546 |
# File 'lib/tree_haver/backends/java.rb', line 544 def child_count @impl.childCount end |
#each {|Node| ... } ⇒ void
This method returns an undefined value.
Iterate over children
560 561 562 563 564 565 |
# File 'lib/tree_haver/backends/java.rb', line 560 def each return enum_for(:each) unless block_given? child_count.times do |i| yield child(i) end end |
#end_byte ⇒ Integer
Get the end byte position
577 578 579 |
# File 'lib/tree_haver/backends/java.rb', line 577 def end_byte @impl.endByte end |
#end_point ⇒ Hash
Get the end point (row, column)
592 593 594 595 |
# File 'lib/tree_haver/backends/java.rb', line 592 def end_point pt = @impl.endPoint {row: pt.row, column: pt.column} end |
#has_error? ⇒ Boolean
Check if this node has an error
600 601 602 |
# File 'lib/tree_haver/backends/java.rb', line 600 def has_error? @impl.hasError end |
#missing? ⇒ Boolean
Check if this node is missing
607 608 609 |
# File 'lib/tree_haver/backends/java.rb', line 607 def missing? @impl.isMissing end |
#start_byte ⇒ Integer
Get the start byte position
570 571 572 |
# File 'lib/tree_haver/backends/java.rb', line 570 def start_byte @impl.startByte end |
#start_point ⇒ Hash
Get the start point (row, column)
584 585 586 587 |
# File 'lib/tree_haver/backends/java.rb', line 584 def start_point pt = @impl.startPoint {row: pt.row, column: pt.column} end |
#text ⇒ String
Get the text of this node
614 615 616 |
# File 'lib/tree_haver/backends/java.rb', line 614 def text @impl.text.to_s end |
#type ⇒ String
Get the type of this node
537 538 539 |
# File 'lib/tree_haver/backends/java.rb', line 537 def type @impl.type end |