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

Function analyzeAll

lib/web/tern/tern.js:354–398  ·  view source on GitHub ↗
(srv, timeBudget, c)

Source from the content-addressed store, hash-verified

352 }
353
354 function analyzeAll(srv, timeBudget, c) {
355 if (srv.pending) return waitOnFetch(srv, timeBudget, c);
356
357 var e = srv.fetchError;
358 if (e) { srv.fetchError = null; return c(e); }
359
360 if (srv.needsPurge.length > 0) infer.withContext(srv.cx, function() {
361 infer.purge(srv.needsPurge);
362 srv.needsPurge.length = 0;
363 });
364
365 var done = true;
366 // The second inner loop might add new files. The outer loop keeps
367 // repeating both inner loops until all files have been looked at.
368 for (var i = 0; i < srv.files.length;) {
369 var toAnalyze = [];
370 for (; i < srv.files.length; ++i) {
371 var file = srv.files[i];
372 if (file.text == null) done = false;
373 else if (file.scope == null && !file.excluded) toAnalyze.push(file);
374 }
375 toAnalyze.sort(function(a, b) {
376 return parentDepth(srv, a.parent) - parentDepth(srv, b.parent);
377 });
378 for (var j = 0; j < toAnalyze.length; j++) {
379 var file = toAnalyze[j];
380 if (file.parent && !chargeOnBudget(srv, file)) {
381 file.excluded = true;
382 } else if (timeBudget) {
383 var startTime = +new Date;
384 try {
385 infer.withTimeout(timeBudget[0], function() { analyzeFile(srv, file); });
386 } catch(e) {
387 if (e instanceof infer.TimedOut) return c(e)
388 else throw e
389 }
390 timeBudget[0] -= +new Date - startTime;
391 } else {
392 analyzeFile(srv, file);
393 }
394 }
395 }
396 if (done) c();
397 else waitOnFetch(srv, timeBudget, c);
398 }
399
400 function firstLine(str) {
401 var end = str.indexOf("\n");

Callers 3

tern.jsFile · 0.85
doRequestFunction · 0.85
doneFunction · 0.85

Calls 6

waitOnFetchFunction · 0.85
parentDepthFunction · 0.85
chargeOnBudgetFunction · 0.85
analyzeFileFunction · 0.85
cFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected