MCPcopy Index your code
hub / github.com/nodejs/node / getDiagnosticsWorker

Function getDiagnosticsWorker

test/fixtures/snapshot/typescript.js:86029–86057  ·  view source on GitHub ↗
(sourceFile)

Source from the content-addressed store, hash-verified

86027 addLazyDiagnostic = oldAddLazyDiagnostics;
86028 }
86029 function getDiagnosticsWorker(sourceFile) {
86030 if (sourceFile) {
86031 ensurePendingDiagnosticWorkComplete();
86032 // Some global diagnostics are deferred until they are needed and
86033 // may not be reported in the first call to getGlobalDiagnostics.
86034 // We should catch these changes and report them.
86035 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
86036 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
86037 checkSourceFileWithEagerDiagnostics(sourceFile);
86038 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
86039 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
86040 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
86041 // If the arrays are not the same reference, new diagnostics were added.
86042 var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
86043 return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
86044 }
86045 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
86046 // If the arrays are the same reference, but the length has changed, a single
86047 // new diagnostic was added as DiagnosticCollection attempts to reuse the
86048 // same array.
86049 return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
86050 }
86051 return semanticDiagnostics;
86052 }
86053 // Global diagnostics are always added when a file is not provided to
86054 // getDiagnostics
86055 ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
86056 return diagnostics.getDiagnostics();
86057 }
86058 function getGlobalDiagnostics() {
86059 ensurePendingDiagnosticWorkComplete();
86060 return diagnostics.getGlobalDiagnostics();

Callers 1

getDiagnosticsFunction · 0.85

Calls 3

forEachMethod · 0.65

Tested by

no test coverage detected