public processResults()

in Extension/src/LanguageServer/references.ts [420:524]


    public processResults(referencesResult: ReferencesResult): void {
        if (this.referencesFinished) {
            return;
        }
        this.initializeViews();
        this.clearViews();

        if (this.client.ReferencesCommandMode === ReferencesCommandMode.Peek && !this.referencesChannel) {
            this.referencesChannel = vscode.window.createOutputChannel(localize("c.cpp.peek.references", "C/C++ Peek References"));
            this.disposables.push(this.referencesChannel);
        }

        if (this.referencesStartedWhileTagParsing) {
            const msg: string = localize("some.references.may.be.missing", "[Warning] Some references may be missing, because workspace parsing was incomplete when {0} was started.",
                referencesCommandModeToString(this.client.ReferencesCommandMode));
            if (this.client.ReferencesCommandMode === ReferencesCommandMode.Peek) {
                if (this.referencesChannel) {
                    this.referencesChannel.appendLine(msg);
                    this.referencesChannel.appendLine("");
                    this.referencesChannel.show(true);
                }
            } else if (this.client.ReferencesCommandMode === ReferencesCommandMode.Find) {
                const logChannel: vscode.OutputChannel = logger.getOutputChannel();
                logChannel.appendLine(msg);
                logChannel.appendLine("");
                logChannel.show(true);
            }
        }

        // Need to reset these before we call the callback, as the callback my trigger another request
        // and we need to ensure these values are already reset before that happens.
        const referencesRequestPending: boolean = this.referencesRequestPending;
        const referencesCanceled: boolean = this.referencesCanceled;
        this.referencesRequestPending = false;
        this.referencesCanceled = false;

        const currentReferenceCommandMode: ReferencesCommandMode = this.client.ReferencesCommandMode;

        if (referencesResult.isFinished) {
            this.symbolSearchInProgress = false;
            if (this.referencesDelayProgress) {
                clearInterval(this.referencesDelayProgress);
            }
            if (this.currentUpdateProgressTimer) {
                if (this.currentUpdateProgressTimer) {
                    clearInterval(this.currentUpdateProgressTimer);
                }
                if (this.currentUpdateProgressResolve) {
                    this.currentUpdateProgressResolve(undefined);
                }
                this.currentUpdateProgressResolve = undefined;
                this.currentUpdateProgressTimer = undefined;
            }
            this.client.setReferencesCommandMode(ReferencesCommandMode.None);
        }

        if (currentReferenceCommandMode === ReferencesCommandMode.Rename) {
            if (!referencesCanceled) {
                if (this.resultsCallback) {
                    this.resultsCallback(referencesResult, true);
                }
            } else {
                // Do nothing when rename is canceled while searching for references was in progress.
                if (this.resultsCallback) {
                    this.resultsCallback(null, true);
                }
            }
        } else {
            if (this.findAllRefsView) {
                this.findAllRefsView.setData(referencesResult, referencesCanceled, this.groupByFile.Value);
            }

            // Display data based on command mode: peek references OR find all references
            if (currentReferenceCommandMode === ReferencesCommandMode.Peek) {
                const showConfirmedReferences: boolean = referencesCanceled;
                if (this.findAllRefsView) {
                    const peekReferencesResults: string = this.findAllRefsView.getResultsAsText(showConfirmedReferences);
                    if (peekReferencesResults) {
                        if (this.referencesChannel) {
                            this.referencesChannel.appendLine(peekReferencesResults);
                            this.referencesChannel.show(true);
                        }
                    }
                }
            } else if (currentReferenceCommandMode === ReferencesCommandMode.Find) {
                if (this.findAllRefsView) {
                    this.findAllRefsView.show(true);
                }
            }
            if (referencesResult.isFinished) {
                this.lastResults = referencesResult;
                this.referencesFinished = true;
            }
            if (!this.referencesRefreshPending) {
                if (referencesResult.isFinished && this.referencesRequestHasOccurred && !referencesRequestPending && !this.referencesCanceledWhilePreviewing) {
                    this.referencesRefreshPending = true;
                    vscode.commands.executeCommand("references-view.refresh");
                } else {
                    if (this.resultsCallback) {
                        this.resultsCallback(referencesResult, !this.referencesCanceledWhilePreviewing);
                    }
                }
            }
        }
    }