MCPcopy Index your code
hub / github.com/ternjs/tern / analyzeAll

Function analyzeAll

lib/tern.js:361–405  ·  view source on GitHub ↗
(srv, timeBudget, c)

Source from the content-addressed store, hash-verified

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

Callers 3

tern.jsFile · 0.85
doRequestFunction · 0.85
doneFunction · 0.85

Calls 5

waitOnFetchFunction · 0.85
cFunction · 0.85
parentDepthFunction · 0.85
chargeOnBudgetFunction · 0.85
analyzeFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…