Getting the Editor Content based on the Cursor Position in a Vs Code Extension

1Are there some available ways for getting the entire function based on the current cursor position in the Vs code Editor ,
For Eg. Refer This Image here my cursor is at a line inside the function , based on this is there a way we can take that entire function ?
We use vscode.window.activeTextEditor.selection to get the current selection, is there a way i can get the entire function based on the cursor position?

There is a way where we can pass the entire open file content , but i want to know is there a way we can get the function based on the cursor position.