codeOf

open override fun codeOf(astNode: Python.AST.AST): String?

This functions extracts the source code from the input file given a location. This is a bit tricky in Python, as indents are part of the syntax. We also don't want to include leading whitespaces/tabs in case of extracting a nested code fragment. Thus, we use the following approximation to retrieve the fragment's source code:

  1. Get the relevant source code lines

  2. Delete extra code at the end of the last line that is not part of the provided location

  3. Remove trailing whitespaces / tabs