in Extension/src/LanguageServer/references.ts [242:314]
private reportProgress(progress: vscode.Progress<{message?: string; increment?: number }>, forceUpdate: boolean, mode: ReferencesCommandMode): void {
const helpMessage: string = (mode !== ReferencesCommandMode.Find) ? "" : ` ${localize("click.search.icon", "To preview results, click the search icon in the status bar.")}`;
if (this.referencesCurrentProgress) {
switch (this.referencesCurrentProgress.referencesProgress) {
case ReferencesProgress.Started:
case ReferencesProgress.StartedRename:
progress.report({ message: localize("started", "Started."), increment: 0 });
break;
case ReferencesProgress.ProcessingSource:
progress.report({ message: localize("processing.source", "Processing source."), increment: 0 });
break;
case ReferencesProgress.ProcessingTargets:
let numWaitingToLex: number = 0;
let numLexing: number = 0;
let numParsing: number = 0;
let numConfirmingReferences: number = 0;
let numFinishedWithoutConfirming: number = 0;
let numFinishedConfirming: number = 0;
for (const targetLocationProgress of this.referencesCurrentProgress.targetReferencesProgress) {
switch (targetLocationProgress) {
case TargetReferencesProgress.WaitingToLex:
++numWaitingToLex;
break;
case TargetReferencesProgress.Lexing:
++numLexing;
break;
case TargetReferencesProgress.WaitingToParse:
// The count is derived.
break;
case TargetReferencesProgress.Parsing:
++numParsing;
break;
case TargetReferencesProgress.ConfirmingReferences:
++numConfirmingReferences;
break;
case TargetReferencesProgress.FinishedWithoutConfirming:
++numFinishedWithoutConfirming;
break;
case TargetReferencesProgress.FinishedConfirming:
++numFinishedConfirming;
break;
default:
break;
}
}
let currentMessage: string;
const numTotalToLex: number = this.referencesCurrentProgress.targetReferencesProgress.length;
const numFinishedLexing: number = numTotalToLex - numWaitingToLex - numLexing;
const numTotalToParse: number = this.referencesCurrentProgress.targetReferencesProgress.length - numFinishedWithoutConfirming;
if (numLexing >= (numParsing + numConfirmingReferences) && numFinishedConfirming === 0) {
if (numTotalToLex === 0) {
currentMessage = localize("searching.files", "Searching files."); // TODO: Prevent this from happening.
} else {
currentMessage = localize("files.searched", "{0}/{1} files searched.{2}", numFinishedLexing, numTotalToLex, helpMessage);
}
} else {
currentMessage = localize("files.confirmed", "{0}/{1} files confirmed.{2}", numFinishedConfirming, numTotalToParse, helpMessage);
}
const currentLexProgress: number = numFinishedLexing / numTotalToLex;
const confirmingWeight: number = 0.5; // Count confirming as 50% of parsing time (even though it's a lot less) so that the progress bar change is more noticeable.
const currentParseProgress: number = (numConfirmingReferences * confirmingWeight + numFinishedConfirming) / numTotalToParse;
const averageLexingPercent: number = 25;
const currentIncrement: number = currentLexProgress * averageLexingPercent + currentParseProgress * (100 - averageLexingPercent);
if (forceUpdate || currentIncrement > this.referencesPrevProgressIncrement || currentMessage !== this.referencesPrevProgressMessage) {
progress.report({ message: currentMessage, increment: currentIncrement - this.referencesPrevProgressIncrement });
this.referencesPrevProgressIncrement = currentIncrement;
this.referencesPrevProgressMessage = currentMessage;
}
break;
}
}
}