Class: TreeHaver::Backends::Java::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/tree_haver/backends/java.rb

Overview

Wrapper for java-tree-sitter Tree

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(impl) ⇒ Tree

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 Tree.



482
483
484
# File 'lib/tree_haver/backends/java.rb', line 482

def initialize(impl)
  @impl = impl
end

Instance Attribute Details

#implObject (readonly)

Returns the value of attribute impl.



479
480
481
# File 'lib/tree_haver/backends/java.rb', line 479

def impl
  @impl
end

Instance Method Details

#edit(start_byte:, old_end_byte:, new_end_byte:, start_point:, old_end_point:, new_end_point:) ⇒ void

This method returns an undefined value.

Mark the tree as edited for incremental re-parsing

Parameters:

  • start_byte (Integer)

    byte offset where the edit starts

  • old_end_byte (Integer)

    byte offset where the old text ended

  • new_end_byte (Integer)

    byte offset where the new text ends

  • start_point (Hash)

    starting position as ‘{ row:, column: }`

  • old_end_point (Hash)

    old ending position as ‘{ row:, column: }`

  • new_end_point (Hash)

    new ending position as ‘{ row:, column: }`



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/tree_haver/backends/java.rb', line 502

def edit(start_byte:, old_end_byte:, new_end_byte:, start_point:, old_end_point:, new_end_point:)
  point_class = Java.java_classes[:Point]
  input_edit_class = Java.java_classes[:InputEdit]

  start_pt = point_class.new(start_point[:row], start_point[:column])
  old_end_pt = point_class.new(old_end_point[:row], old_end_point[:column])
  new_end_pt = point_class.new(new_end_point[:row], new_end_point[:column])

  input_edit = input_edit_class.new(
    start_byte,
    old_end_byte,
    new_end_byte,
    start_pt,
    old_end_pt,
    new_end_pt,
  )

  @impl.edit(input_edit)
end

#root_nodeNode

Get the root node of the tree

Returns:

  • (Node)

    the root node



489
490
491
# File 'lib/tree_haver/backends/java.rb', line 489

def root_node
  Node.new(@impl.rootNode)
end