Skip to content

Comments

Use a progress reporter to hint the current build status when run or debug a program#919

Merged
testforstephen merged 8 commits intomicrosoft:masterfrom
testforstephen:jinbo_progressReporter
Dec 15, 2020
Merged

Use a progress reporter to hint the current build status when run or debug a program#919
testforstephen merged 8 commits intomicrosoft:masterfrom
testforstephen:jinbo_progressReporter

Conversation

@testforstephen
Copy link
Contributor

@testforstephen testforstephen commented Dec 8, 2020

This PR includes:

  • Use a consistent progress reporter to report the build status before running/debugging an application.
    By default, progress notifications are used to display status. You can switch to using status bar to hint the progress by user settings "java.silentNotification": true.

  • Expose an extension API for test runner to use the same progress reporter. In addition, when third-party extensions such as test runner call the startDebugging API to start the debugger, they can add an attribute __progressId to the launchConfiguration so that the debugger can use the same progress reporter to report progress.

// The debugger will export the progressProvider instance to others for reuse.
{
  progressProvider: IProgressProvider
}

export interface IProgressReporter {
    /**
     * Returns the id of the progress reporter.
     */
    getId(): string;

    /**
     * Reports a progress message update.
     * @param message the message to update
     * @param increment use `increment` to report discrete progress. Each call with a `increment`
     *                  value will be summed up and reflected as overall progress until 100% is reached.
     *                  Note that currently only `ProgressLocation.Notification` is capable of showing
     *                  discrete progress.
     */
    report(message: string, increment?: number): void;

    /**
     * Shows the progress reporter.
     */
    show(): void;

    /**
     * Hides the progress reporter.
     * @param onlyNotifications only hide the progress reporter when it's shown as notification.
     */
    hide(onlyNotifications?: boolean): void;

    /**
     * Returns whether the progress reporter has been cancelled or completed.
     */
    isCancelled(): boolean;

    /**
     * Notifies the work is done that is either the task is completed or the user has cancelled it.
     */
    done(): void;

    /**
     * The CancellationToken to monitor if the progress reporter has been cancelled by the user.
     */
    getCancellationToken(): CancellationToken;

    /**
     * Disposes the progress reporter if the observed token has been cancelled.
     * @param token the cancellation token to observe
     */
    observe(token?: CancellationToken): void;
}

export interface IProgressProvider {
    /**
     * Creates a progress reporter.
     * @param jobName the job name
     * @param progressLocation The location at which progress should show, defaults to `ProgressLocation.Notification`.
     * @param cancellable Controls if a cancel button should show to allow the user to cancel the progress reporter,
     *                    defaults to true. Note that currently only `ProgressLocation.Notification` is supporting
     *                    to show a cancel button.
     */
    createProgressReporter(jobName: string, progressLocation?: ProgressLocation | { viewId: string }, cancellable?: boolean): IProgressReporter;

    /**
     * Returns the progress reporter with the progress id.
     * @param progressId the progress id
     */
    getProgressReporter(progressId: string): IProgressReporter | undefined;
}

@testforstephen testforstephen force-pushed the jinbo_progressReporter branch 3 times, most recently from 798be19 to bb79764 Compare December 8, 2020 12:49
@testforstephen
Copy link
Contributor Author

testforstephen commented Dec 9, 2020

A private vsix to test the progress reporter feature. https://github.com/testforstephen/vscode-test/blob/master/vscode-java-debug-0.29.1.vsix

Below is a sample to show the progress reporter such as resolving main class, compiling workspace, resolving launch configuration.
progressReporter

@jdneo
Copy link
Member

jdneo commented Dec 9, 2020

I have one question: When do we need to manually call progressReporterManager.remove()?

@testforstephen
Copy link
Contributor Author

I have one question: When do we need to manually call progressReporterManager.remove()?

Good question, you don't need call it. It's supposed to be used by progressReporter.cancel().

@testforstephen
Copy link
Contributor Author

@testforstephen testforstephen merged commit b9096ce into microsoft:master Dec 15, 2020
@testforstephen testforstephen deleted the jinbo_progressReporter branch December 15, 2020 06:56
@testforstephen testforstephen added this to the 0.30.0 milestone Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants