MCPcopy
hub / github.com/ternjs/tern / ensureFile

Function ensureFile

lib/tern.js:297–329  ·  view source on GitHub ↗
(srv, name, parent, text)

Source from the content-addressed store, hash-verified

295 }
296
297 function ensureFile(srv, name, parent, text) {
298 var known = srv.findFile(name);
299 if (known) {
300 if (text != null) {
301 if (known.scope) {
302 srv.needsPurge.push(name);
303 infer.clearScopes(known.ast);
304 known.scope = null;
305 }
306 updateText(known, text, srv);
307 }
308 if (parentDepth(srv, known.parent) > parentDepth(srv, parent)) {
309 known.parent = parent;
310 if (known.excluded) known.excluded = null;
311 }
312 return;
313 }
314
315 var file = new File(name, parent);
316 srv.files.push(file);
317 srv.fileMap[name] = file;
318 if (text != null) {
319 updateText(file, text, srv);
320 } else if (srv.options.async) {
321 srv.startAsyncAction();
322 srv.options.getFile(name, function(err, text) {
323 updateText(file, text || "", srv);
324 srv.finishAsyncAction(err);
325 });
326 } else {
327 updateText(file, srv.options.getFile(name) || "", srv);
328 }
329 }
330
331 function fetchAll(srv, c) {
332 var done = true, returned = false;

Callers 2

tern.jsFile · 0.85
doRequestFunction · 0.85

Calls 2

updateTextFunction · 0.85
parentDepthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…