()
| 218 | return "(obj)" |
| 219 | |
| 220 | def tern_ensureCompletionCached(): |
| 221 | cached = vim.eval("b:ternLastCompletionPos") |
| 222 | curRow, curCol = vim.current.window.cursor |
| 223 | curLine = vim.current.buffer[curRow - 1] |
| 224 | |
| 225 | if (curRow == int(cached["row"]) and curCol >= int(cached["end"]) and |
| 226 | curLine[0:int(cached["end"])] == cached["word"] and |
| 227 | (not re.match(".*\\W", curLine[int(cached["end"]):curCol]))): |
| 228 | return |
| 229 | |
| 230 | data = tern_runCommand({"type": "completions", "types": True, "docs": True}, |
| 231 | {"line": curRow - 1, "ch": curCol}) |
| 232 | if data is None: return |
| 233 | |
| 234 | completions = [] |
| 235 | for rec in data["completions"]: |
| 236 | completions.append({"word": rec["name"], |
| 237 | "menu": tern_asCompletionIcon(rec.get("type")), |
| 238 | "info": tern_typeDoc(rec) }) |
| 239 | vim.command("let b:ternLastCompletion = " + json.dumps(completions)) |
| 240 | start, end = (data["start"]["ch"], data["end"]["ch"]) |
| 241 | vim.command("let b:ternLastCompletionPos = " + json.dumps({ |
| 242 | "row": curRow, |
| 243 | "start": start, |
| 244 | "end": end, |
| 245 | "word": curLine[0:end] |
| 246 | })) |
| 247 | |
| 248 | def tern_typeDoc(rec): |
| 249 | tp = rec.get("type") |
nothing calls this directly
no test coverage detected