Inherits from

SymbolGroup, Editable

Properties


extended

Returns a SymbolGroup of all extended nodes. This allows a common edit interface for all of extended nodes.

def extended(self) -> SymbolGroup:
    ...

extended_source

Text representation of all its extended nodes

def extended_source(self) -> str:
    ...

file

The file object that this Editable instance belongs to

def file(self) -> File:
    ...

filepath

The file path of the file that this Editable instance belongs to

def filepath(self) -> str:
    ...

next_named_sibling

Returns the next named sibling of the symbol group

def next_named_sibling(self) -> Editable | None:
    ...

next_sibling

Returns the next sibling of the symbol group

def next_sibling(self) -> Editable | None:
    ...

source

Returns the source of the symbol group. Composed of the source of all symbols in the group.

def source(self) -> str:
    ...

symbols

Returns the list of symbols in the group

def symbols(self) -> list[Child]:
    ...

variable_usages

Returns Editables for all TreeSitter node instances of variable usages. (Excludes: property identifiers and argument keywords) This is useful for renaming variables locally and analyzing variable usages.

def variable_usages(self) -> list[Editable]:
    ...

Methods


commit

Commit just this node

def commit(self) -> None:
    ...

edit

Replace the source of this Editable with new_src. When fix_indentation is True, the indentation of the new_src will be adjusted to match the current text’s indentation.

def edit(self, *args, **kwargs) -> None:
    ...

find

Returns a list of all substring match in strings_to_match, similar to python’s str.find(..)

Args: exact: Only match individual nodes which exactly match the query

def find(self, strings_to_match: list[str] | str, *, exact: bool = False) -> list[Editable]:
    ...

find_string_literals

Returns a list of all editable substrings within string literals that match strings_to_match

def find_string_literals(self, strings_to_match: list[str], fuzzy_match: bool = False) -> list[Editable]:
    ...

flag

Adds a comment so the developer can see this Editable

def flag(self) -> None:
    ...

get_variable_usages

Returns Editables for all TreeSitter nodes corresponding to instances of variable usage that matches the given variable name. (Excludes: property identifiers and argument keywords) fuzzy_match allows for partial matching of variable names and effectively does var_name in usage.name

def get_variable_usages(self, var_name: str, fuzzy_match: bool = False) -> list[Editable]:
    ...

index

Return the index of the first occurrence of value. Returns -1 if value is not present.

def index(self, value: Child, start: int = 0, stop: int | None = None) -> int:
    ...

insert

Adds value to the container that this node represents Args: value: source to add index: If provided, the value will be inserted at that index, otherwise will default to end of the list.

def insert(self, index: int, value: str | Child) -> None:
    ...

insert_after

Inserts new_src after this node

def insert_after(self, new_src: str, fix_indentation: bool = False, newline: bool = True, priority: int = 0, dedupe: bool = True) -> None:
    ...

insert_before

Inserts new_src before this node

def insert_before(self, new_src: str, fix_indentation: bool = False, newline: bool = True, priority: int = 0, dedupe: bool = True) -> None:
    ...

remove

Deletes this node, and optionally its related extended nodes (e.g. decorators, comments, etc.)

def remove(self, value: Child) -> None:
    ...

replace

Replaces all instances of old with new in the symbol group

def replace(self, old: str, new: str, count: int = -1, priority: int = 0) -> int:
    ...

Returns a list of all regex matches of regex_pattern as Editable, similar to python’s re.search(...)

  • When include_strings is False, the search will exclude the contents of string literals from the search.
  • When include_comments is False, the search will exclude the contents of comments from the search.
def search(self, regex_pattern: str, include_strings: bool = True, include_comments: bool = True) -> list[Editable]:
    ...