Skip to content

ALT-10995#25

Merged
adkozlov merged 5 commits intomainfrom
ALT-10995
Mar 10, 2026
Merged

ALT-10995#25
adkozlov merged 5 commits intomainfrom
ALT-10995

Conversation

@adkozlov
Copy link
Collaborator

@adkozlov adkozlov commented Mar 5, 2026

No description provided.

@adkozlov adkozlov self-assigned this Mar 5, 2026
@adkozlov adkozlov requested a review from meanmail March 5, 2026 17:38
Copy link
Contributor

@meanmail meanmail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

.github/workflows/publish.yaml

Line 4: push trigger without branch filter

Changing from pull_request to push without specifying branches means this workflow will run on every push to every branch, including main. If this is intentional for debugging CI — OK, but consider adding a branch filter before merging to main:

on:
  push:
    branches:
      - main

Or if needed for all branches, at least exclude dependabot/** and similar.

Also, the step name on line 43 still says "Upload plugin to PR" — but now the trigger is push, not pull_request, so the name is misleading.


intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt

Lines 155-164: invokeLater + findPsiFile without runReadAction

findPsiFile (from com.intellij.openapi.vfs.findPsiFile) internally calls PsiManager.getInstance(project).findFile(this) which requires read access. Running on EDT does not guarantee a read lock in newer platform versions.

The old code had the same issue, but since this block is being refactored, it would be good to wrap the PSI access:

ApplicationManager.getApplication().invokeLater({
  runReadAction {
    val editorManager = FileEditorManager.getInstance(project)
    val analyzer = DaemonCodeAnalyzerEx.getInstanceEx(project)
    editorManager.openFiles
      .asSequence()
      .mapNotNull { it.findPsiFile(project) }
      .forEach { analyzer.cleanFileLevelHighlights(Pass.LOCAL_INSPECTIONS, it) }
  }
}, project.disposed)

Note: verify that cleanFileLevelHighlights doesn't require EDT-only (no read lock) — if it does, you'd need to split the read and write parts.

Lines 160-163: asSequence() on a small array

editorManager.openFiles returns a small array (typically < 20 files). Using asSequence() here adds overhead without meaningful benefit. A simple forEach chain would be cleaner:

for (file in editorManager.openFiles) {
  val psiFile = file.findPsiFile(project) ?: continue
  analyzer.cleanFileLevelHighlights(Pass.LOCAL_INSPECTIONS, psiFile)
}

This is a minor style nit, not blocking.


Overall

The refactoring is a clear improvement — removing the unnecessary module loop and hasOpenFiles() check, and properly deferring to EDT via invokeLater. The project.disposed condition is correct.

Main actionable item: wrap findPsiFile in runReadAction.

@adkozlov
Copy link
Collaborator Author

adkozlov commented Mar 9, 2026

The push change was experimental, I wasn't able to understand why the workflow wasn't running.
Apparently, it was just a queue issue.

@adkozlov
Copy link
Collaborator Author

adkozlov commented Mar 9, 2026

asSequence was used not to create an intermediate list. And to run analysis straight away.

@adkozlov
Copy link
Collaborator Author

adkozlov commented Mar 9, 2026

invokeLater is guaranteed to run with a Write intent lock, see com/intellij/openapi/application/Application.java:405.
So an explicit read action can be omitted here.

Copy link
Contributor

@meanmail meanmail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the clarifications:

  • invokeLater runs under Write Intent lock — confirmed in Application.java javadoc, so explicit runReadAction is indeed unnecessary.
  • asSequence — fair point about avoiding intermediate list creation.
  • push trigger — understood it was experimental. Just make sure to scope it (or revert) before merging to main.

The refactoring is clean: unnecessary module loop removed, hasOpenFiles() guard eliminated, properly deferred to EDT. 👍

@adkozlov adkozlov merged commit fc0862c into main Mar 10, 2026
0 of 2 checks passed
@adkozlov adkozlov deleted the ALT-10995 branch March 10, 2026 10:55
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