kernelfoundry.algorithm.utils.code_editing¶
Classes
|
Object describing a code edit operation. |
|
- class kernelfoundry.algorithm.utils.code_editing.CodeEditCommand(start: int, end: int, replacement: str)[source]¶
Object describing a code edit operation.
- class kernelfoundry.algorithm.utils.code_editing.CodeEditing(source_code: str, parse_header_files: bool = True)[source]¶
- __init__(source_code: str, parse_header_files: bool = True)[source]¶
CodeEditing class for manipulating C++ source code using libclang :param source_code: The C++ source code to manipulate. :type source_code: str :param parse_header_files: If True, header files will be parsed. :type parse_header_files: bool
- property translation_unit: TranslationUnit¶
- find_sycl_queue() list[Cursor][source]¶
Find SYCL queue variable declaration nodes in the AST. :returns: A list of Cursor nodes representing SYCL queue variable declarations. :rtype: list[Cursor]
- find_sycl_wait(queue_node: Cursor) list[Cursor][source]¶
Find SYCL queue wait call expressions in the AST for a given queue variable. :param queue_node: The Cursor node representing the SYCL queue variable. :type queue_node: Cursor
- Returns:
A list of Cursor nodes representing SYCL queue wait call expressions.
- Return type:
list[Cursor]
- static replace_node_with_str(node: Cursor, replacement_str: str, source_code: str, remove_semicolon: bool = False) CodeEditCommand[source]¶
Helper function for manipulating the source code by replacing a node with a string. :param node: The node to replace. :type node: Cursor :param replacement_str: The string to replace the node with. :type replacement_str: str :param source_code: The source code to manipulate. :type source_code: str :param remove_semicolon: If True, removes a trailing semicolon after the node’s extent. :type remove_semicolon: bool
- Returns:
The modified source code with the node replaced by the string.
- Return type: