semantic icon indicating copy to clipboard operation
semantic copied to clipboard

Getting the line number of the end of a function definition

Open hendychua opened this issue 3 years ago • 0 comments

Hi there,

I would like to get the line number of the end of a function definition. Is there a way to do this?

To give an example, suppose the source code is:

def Foo(x): # line 1
  if x == 42:
    return True
  else:
    return False # line 5

The parsed output would return where the function definition completes, i.e. line 5.

Currently, span.end seems to point to where the symbol name definition ends but not where the whole function ends:

{
  "symbol": "Foo",
  "kind": "Function",
  "line": "def Foo(x):",
  "span": {
    "start": {
      "line": 1,
      "column": 5
    },
    "end": {
      "line": 1,
      "column": 8
    }
  },
  "nodeType": "DEFINITION"
},

Thank you.

hendychua avatar Jun 06 '22 13:06 hendychua