Language#

class scubatrace.Language#

Bases: object

Represents a programming language supported by ScubaTrace.

classmethod is_block_node(node: Node) bool#

Checks if the given node is a block statement.

Parameters:

node (Node) – The tree-sitter node to check.

Returns:

True if the node is a block statement, False otherwise.

Return type:

bool

classmethod is_function_node(node: Node) bool#

Checks if the given node is a function definition.

Parameters:

node (Node) – The tree-sitter node to check.

Returns:

True if the node is a function definition, False otherwise.

Return type:

bool

classmethod is_simple_node(node: Node) bool#

Checks if the given node is a simple statement.

Parameters:

node (Node) – The tree-sitter node to check.

Returns:

True if the node is a simple statement, False otherwise.

Return type:

bool

abstractmethod static query_goto_label(label_name: str) str#

Formats a tree-sitter query to match goto statements with the given label name.

abstractmethod static query_left_value(text: str) str#

Formats a tree-sitter query to match left values in the given text.

BLOCK_STATEMENTS: list[str] = []#

The tree-sitter AST types of block statements.

For example, in Python, this would include ‘if’, ‘for’, ‘while’, etc.

EXIT_STATEMENTS: list[str] = []#

The tree-sitter AST types of exit statements.

For example, in Python, this would include ‘return’.

SIMPLE_STATEMENTS: list[str] = []#

The tree-sitter AST types of simple statements.

For example, in Python, this would include ‘expression_statement’, ‘pass_statement’, etc.

extensions: list[str]#

The file extensions associated with the language.

For example, Python would have [‘.py’], C/C++ would have [‘.c’, ‘.cpp’], etc.

query_call: str#

The tree-sitter query to match function calls.

query_error = '(ERROR)@error'#

The tree-sitter query to match error nodes.

This is used to identify syntax errors in the code.

query_function_parameter: str#

The tree-sitter query to match function parameters.

query_identifier = '(identifier)@name'#

The tree-sitter query to match identifiers.

query_import_identifier: str#

The tree-sitter query to match import identifiers.

For example, in C/C++, this would match the header.h in #include <header.h>.