Skip to content

Repository files navigation

Optimize Imports All Tabs

An IntelliJ Platform plugin that adds bulk Optimize Imports actions, running the built-in per-language optimizer on many files at once instead of one file at a time.

What it does

Both actions collect the target files' PSI, feed them to the platform's OptimizeImportsProcessor (a single undoable command), and live in the Code menu right after the standard Optimize Imports item.

  • Optimize Imports All Tabs — every file currently open in an editor tab. Enabled when at least one tab is open.
  • Optimize Imports Changed Files — every file with uncommitted VCS changes (modified/added files in an active change list, via ChangeListManager). Enabled when there are uncommitted changes.

Project layout

build.gradle.kts                         Gradle build (IntelliJ Platform Gradle Plugin 2.x)
settings.gradle.kts
gradle.properties
src/main/kotlin/.../OptimizeImportsAllTabsAction.kt        all open tabs
src/main/kotlin/.../OptimizeImportsChangedFilesAction.kt   uncommitted changes
src/main/resources/META-INF/plugin.xml                     plugin descriptor

Building

This project uses the Gradle wrapper. The wrapper JAR (gradle/wrapper/gradle-wrapper.jar) is a binary and is not included here (it could not be downloaded in this environment). Generate it once with a local Gradle installation:

gradle wrapper --gradle-version 8.10.2

After that, the usual tasks work:

./gradlew buildPlugin      # produces build/distributions/*.zip
./gradlew runIde           # launches a sandbox IDE with the plugin installed

Alternatively, open the project in IntelliJ IDEA (with the Plugin DevKit and Gradle support) and use the generated runIde run configuration.

Installing the built plugin

Settings ▸ Plugins ▸ ⚙ ▸ Install Plugin from Disk… and pick the ZIP from build/distributions/.

Notes

  • Targets IntelliJ Platform build 242+ (2024.2). Adjust sinceBuild in build.gradle.kts if you need an older baseline.
  • Depends on com.intellij.modules.platform and com.intellij.modules.vcs (the latter for the changed-files action's ChangeListManager), so it loads in any JetBrains IDE with VCS support; import optimization itself is provided per-language by the IDE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages