Skip to content

FunctionDef source extract using getText() #3216

@Yuxin45

Description

@Yuxin45

Hi, I am trying to extract all function definitions within a source . I implemented a Listener and implemented fuction enterFuncdef(Python3Parser.FuncdefContext ctx). However, with using ctx.getText() to extract the source block for the function definition, I found out that within the result, all space are skipped after keywords (eg. return abc becomes 'returnabc', for i in list becomes 'foriinlist', ...) but I want to keep the original space within function definition since I need the source code. Is there anything I can do to address this issue?
Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions