MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / jumpToDef

Function jumpToDef

lib/web/CodeMirror/addon/tern/tern.js:377–403  ·  view source on GitHub ↗
(ts, cm)

Source from the content-addressed store, hash-verified

375 // Moving to the definition of something
376
377 function jumpToDef(ts, cm) {
378 function inner(varName) {
379 var req = {type: "definition", variable: varName || null};
380 var doc = findDoc(ts, cm.getDoc());
381 ts.server.request(buildRequest(ts, doc, req), function(error, data) {
382 if (error) return showError(ts, cm, error);
383 if (!data.file && data.url) { window.open(data.url); return; }
384
385 if (data.file) {
386 var localDoc = ts.docs[data.file], found;
387 if (localDoc && (found = findContext(localDoc.doc, data))) {
388 ts.jumpStack.push({file: doc.name,
389 start: cm.getCursor("from"),
390 end: cm.getCursor("to")});
391 moveTo(ts, doc, localDoc, found.start, found.end);
392 return;
393 }
394 }
395 showError(ts, cm, "Could not find a definition.");
396 });
397 }
398
399 if (!atInterestingExpression(cm))
400 dialog(cm, "Jump to variable", function(name) { if (name) inner(name); });
401 else
402 inner();
403 }
404
405 function jumpBack(ts, cm) {
406 var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file];

Callers 1

tern.jsFile · 0.85

Calls 3

atInterestingExpressionFunction · 0.85
innerFunction · 0.85
dialogFunction · 0.70

Tested by

no test coverage detected