TSCommentGroup
A group of related symbols that represent a comment or docstring in TypeScript
For example: // Comment 1 // Comment 2 // Comment 3
would be 3 individual comments (accessible via symbols
), but together they form a CommentGroup
(accessible via `self).
Inherits from
CommentGroup, SymbolGroup, Editable
Properties
extended
Returns a SymbolGroup of all extended nodes. This allows a common edit interface for all of extended nodes.
extended_source
Text representation of all its extended nodes
file
The file object that this Editable instance belongs to
filepath
The file path of the file that this Editable instance belongs to
next_named_sibling
Returns the next named sibling of the symbol group
next_sibling
Returns the next sibling of the symbol group
source
Returns the source of the symbol group. Composed of the source of all symbols in the group.
symbols
Returns the list of symbols in the group
text
Return the text content of the comment block. This is the content of all comments in the block.
This does not include the comment delimiters like #
or /* */
.
To get the full comment block, use source
instead.
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.
Methods
commit
Commit just this node
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.
edit_text
Replace the text of the comment with new_text. Autoformats the comment delimiters like #
or /* */
.
Args: new_src (str): The new content to replace the existing comment.
Returns: 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
find_string_literals
Returns a list of all editable substrings within string literals that match strings_to_match
flag
Adds a comment so the developer can see this Editable
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
insert_after
Inserts new_src
after this node
insert_before
Inserts new_src
before this node
remove
Deletes this node, and optionally its related extended nodes (e.g. decorators, comments, etc.)
replace
Replaces all instances of old
with new
in the symbol group
search
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.
Was this page helpful?