in tsc/src/lsif.ts [3636:3684]
private endVisitSourceFile(sourceFile: ts.SourceFile): void {
this.options.logger.doneIndexFile(sourceFile.fileName);
if (this.isFullContentIgnored(sourceFile)) {
return;
}
const program = this.tsProject.getProgram();
const documentData = this.currentDocumentData;
// Diagnostics
const diagnostics: lsp.Diagnostic[] = [];
const syntactic = program.getSyntacticDiagnostics(sourceFile);
for (const element of syntactic) {
diagnostics.push(Converter.asDiagnostic(element));
}
const semantic = program.getSemanticDiagnostics(sourceFile);
for (const element of semantic) {
if (element.file !== undefined && element.start !== undefined && element.length !== undefined) {
diagnostics.push(Converter.asDiagnostic(element as ts.DiagnosticWithLocation));
}
}
if (diagnostics.length > 0) {
documentData.addDiagnostics(diagnostics);
}
// Folding ranges
const spans = this.languageService.getOutliningSpans(sourceFile as any);
if (ts.textSpanEnd.length > 0) {
const foldingRanges: lsp.FoldingRange[] = [];
for (const span of spans) {
foldingRanges.push(Converter.asFoldingRange(sourceFile,span));
}
if (foldingRanges.length > 0) {
documentData.addFoldingRanges(foldingRanges);
}
}
// Document symbols.
const values = (this.symbolContainer.pop() as RangeBasedDocumentSymbol).children;
if (values !== undefined && values.length > 0) {
documentData.addDocumentSymbols(values);
}
this.recordDocumentSymbol.pop();
this.currentSourceFile = undefined;
this._currentDocumentData = undefined;
this.dataManager.documentProcessed(sourceFile);
if (this.symbolContainer.length !== 0) {
throw new Error(`Unbalanced begin / end calls`);
}
}