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

Function ensureFile

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

Source from the content-addressed store, hash-verified

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

Callers 2

tern.jsFile · 0.85
doRequestFunction · 0.85

Calls 4

updateTextFunction · 0.85
parentDepthFunction · 0.85
getFileMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected