How to use the asttokens.AssignLastTokens.visit_tree function in asttokens

To help you get started, we’ve selected a few asttokens examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gristlabs / asttokens / asttokens.py View on Github external
def mark_tokens(self, root_node):
    """
    Given the root of the AST tree produced from source_text, visits all nodes marking them with
    token and position information by adding .first_token and .last_token attributes.
    """
    AssignFirstTokens(self).visit_tree(root_node)
    AssignLastTokens(self).visit_tree(root_node)