Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from obsolete ProgressIndicator to coroutines and modern IntelliJ Platform API #257

Open
2 tasks
Vladislav0Art opened this issue Jun 8, 2024 · 0 comments
Labels
new feature Implementation of a new feature refactoring Refactor the project

Comments

@Vladislav0Art
Copy link
Collaborator

Vladislav0Art commented Jun 8, 2024

Description

The current implementation of halting test generation involves checking the state of ProgressIndicator through the wrapping interface CustomProgressIndicator. Such implementation is a bad practice since the API utilizing ProgressIndicator and ProgressManager's methods is considered obsolete.

A better solution is to use Kotlin Coroutines within the IntelliJ Platform, which allows for a more manageable and robust cancellation implementation (via Coroutines cancellation).

The re-implementation will effectively allow us to reduce the interface CustomProgressIndicator to a mere view of the textual content of a UI indicator and avoid the use of the discouraged practice we have now. This task is addressed in another issue: #258.

Some suggestions:

  1. In suspend context: currentCoroutineContext().ensureActive() will check that the coroutine is not cancelled and throw a CE is it is. Respectively, you can use currentCoroutineContext().isActive to check whether it’s cancelled or not, but usually you just use the former function.
  2. Under progress indicator, you can use runBlockingCancellable { ... } to convert blocking code with progress indicators to coroutines.
  3. Instead of ProgressManager.run you can just use withBackgroundProgress fuction.
  4. Read ProgressIndicator’s javadoc please. It contains lots of links to various functions and knowledge base articles on how to work with progresses, coroutines, indicators, etc.

Useful to read

  1. IntelliJ Platform Plugin SDK "Kotlin Coroutines" (important).
  2. ProgressManager.java.
  3. YouTrack issue IJPL-10, Cancellation framework.
  4. YouTrack IJPL-A-6, Execution Contexts.
  5. YouTrack IJPL-A-10, How to run a coroutine.

Definition of Done

  • Migrate to kotlin coroutines and remove the use of API related to ProgressIndicator and ProgressManager.
  • Use ensureActive and methods alike to halt the execution upon UI indicator cancellation.
@Vladislav0Art Vladislav0Art changed the title Migration of **obsolete** ProgressIndicator to coroutines and modern IntelliJ Platform API Migration from obsolete ProgressIndicator to coroutines and modern IntelliJ Platform API Jun 8, 2024
@Vladislav0Art Vladislav0Art added new feature Implementation of a new feature refactoring Refactor the project labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Implementation of a new feature refactoring Refactor the project
Projects
None yet
Development

No branches or pull requests

1 participant