MCPcopy
hub / github.com/ternjs/tern_for_vim / tern_lookupDefinition

Function tern_lookupDefinition

script/tern.py:288–306  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

286 if data: tern_echoWrap(data.get("type", ""),name=fname)
287
288def tern_lookupDefinition(cmd):
289 data = tern_runCommand("definition")
290 if data is None: return
291
292 if "file" in data:
293 lnum = data["start"]["line"] + 1
294 col = data["start"]["ch"] + 1
295 filename = data["file"]
296
297 if cmd == "edit" and filename == tern_relativeFile():
298 vim.command("normal! m`")
299 vim.command("call cursor(" + str(lnum) + "," + str(col) + ")")
300 else:
301 vim.command(cmd + " +call\ cursor(" + str(lnum) + "," + str(col) + ") " +
302 tern_projectFilePath(filename).replace(u" ", u"\\ "))
303 elif "url" in data:
304 vim.command("echo " + json.dumps("see " + data["url"]))
305 else:
306 vim.command("echo 'no definition found'")
307
308def tern_projectFilePath(path):
309 return os.path.join(tern_projectDir(), path)

Callers

nothing calls this directly

Calls 3

tern_runCommandFunction · 0.85
tern_relativeFileFunction · 0.85
tern_projectFilePathFunction · 0.85

Tested by

no test coverage detected