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

Function createDiagnosticExplainingFile

test/fixtures/snapshot/typescript.js:118942–118974  ·  view source on GitHub ↗
(file, fileProcessingReason, diagnostic, args)

Source from the content-addressed store, hash-verified

118940 }
118941 }
118942 function createDiagnosticExplainingFile(file, fileProcessingReason, diagnostic, args) {
118943 var _a;
118944 var fileIncludeReasons;
118945 var relatedInfo;
118946 var locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : undefined;
118947 if (file)
118948 (_a = fileReasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(processReason);
118949 if (fileProcessingReason)
118950 processReason(fileProcessingReason);
118951 // If we have location and there is only one reason file is in which is the location, dont add details for file include
118952 if (locationReason && (fileIncludeReasons === null || fileIncludeReasons === void 0 ? void 0 : fileIncludeReasons.length) === 1)
118953 fileIncludeReasons = undefined;
118954 var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
118955 var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
118956 var redirectInfo = file && ts.explainIfFileIsRedirect(file);
118957 var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
118958 return location && isReferenceFileLocation(location) ?
118959 ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
118960 ts.createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
118961 function processReason(reason) {
118962 (fileIncludeReasons || (fileIncludeReasons = [])).push(ts.fileIncludeReasonToDiagnostics(program, reason));
118963 if (!locationReason && isReferencedFile(reason)) {
118964 // Report error at first reference file or file currently in processing and dont report in related information
118965 locationReason = reason;
118966 }
118967 else if (locationReason !== reason) {
118968 relatedInfo = ts.append(relatedInfo, fileIncludeReasonToRelatedInformation(reason));
118969 }
118970 // Remove fileProcessingReason if its already included in fileReasons of the program
118971 if (reason === fileProcessingReason)
118972 fileProcessingReason = undefined;
118973 }
118974 }
118975 function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
118976 (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
118977 kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */,

Callers 2

createProgramFunction · 0.85

Calls 7

isReferencedFileFunction · 0.85
processReasonFunction · 0.85
isReferenceFileLocationFunction · 0.85
getMethod · 0.65
forEachMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…