intellij icon indicating copy to clipboard operation
intellij copied to clipboard

feat: Add gazelle to plugin

Open blorente opened this issue 3 years ago • 1 comments

This is a WIP because I can't figure out how to make the tests work.

Checklist

  • [X] I have filed an issue about this change and discussed potential changes with the maintainers.
  • [X] I have received the approval from the maintainers to make this change.
  • [X] This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See the Contributions section in the README for more details.

Discussion thread for this change

Issue number: 3216

Description of this change

See linked issue for a description and general design. This is a port of the existing plugin: https://github.com/blorente/intellij_gazelle. Refer to that README for usage.

Architecturally, this plugin does two things:

  • Implements a GazelleSyncPlugin, which inserts itself between the bazel info and bazel build phases of a sync cycle, to run gazelle in between, via a BlazeGazelleRunnerImpl.
  • Hooks into UserSettings, to add a global field to specify a gazelle target to run on sync.

Refer to gazelle/src/META-INF/blaze-gazelle.xml for a reference of the extension points to the plugin.

NOTE: The added tests in this PR set up a full repository and run gazelle. This is potentially expensive, in the order of single-digit seconds.

blorente avatar Sep 09 '22 14:09 blorente

If I'm not mistaken this will run gazelle on a list of preconfigured targets, could potentially take a long time if working on several different projects in a large monorepo. I guess this is in no way blocking since if users don't configure anything, it won't run at all.

Just FYI I've been working on something similar but only run gazelle on a list of paths that contain dependency graph changes, I can open another PR with my changes when they are ready.

HaimingTian avatar Sep 22 '22 17:09 HaimingTian

I believe this fixes https://github.com/bazelbuild/intellij/issues/3216

gibfahn avatar Oct 10 '22 10:10 gibfahn

@mai93 Thank you so much for your comments, I think the plugin has improved a lot as a result. I've tried to address all of them, if you could take a look at your earliest convenience, it would be great.

blorente avatar Oct 13 '22 14:10 blorente

@mai93 Thanks for your review! I've addressed the comments and rebased the branch.

blorente avatar Nov 10 '22 16:11 blorente

Thank you, @blorente! That looks good but the CI tests are failing with a timeout, can you please check that (https://buildkite.com/bazel/intellij-ue-plugin/builds/7314)?

mai93 avatar Nov 16 '22 00:11 mai93

@mai93 Thanks for the review! The issues with the tests was that the UI setup wasn't done properly for testing. Turns out, we should probably not do any UI setup for testing at all, so added a headless mode in the latest commit.

Tests should pass now, please let me know what you think.

blorente avatar Nov 16 '22 16:11 blorente