nx-console icon indicating copy to clipboard operation
nx-console copied to clipboard

[IntelliJ] SearchEverywhereContributor for projects and targets

Open lppedd opened this issue 9 months ago • 8 comments

Description

Nx Console currently uses a SearchEverywhereContributor only for generators, it appears.
~~Although I'm not able to verify if it's working or not, as no results for the Nx group appear.~~

I'd like to have a contributor also for projects, and targets.
What I find myself looking for frequently is a mix of project + project target, with or without partial names.
The typical query is

my-project-name my-target-name // full match
my-proj my-target-             // partial match
my-target-name                 // only target name

Ideally the contributor would spawn its own Nx tab (isShownInSeparateTab()) to filter down results, and split those results by category: Nx projects, Nx targets.

lppedd avatar Feb 26 '25 09:02 lppedd

It's a great idea, I like it! I don't have the time to work on this at the moment but I'd love to help out with a contribution if you're willing. Otherwise let's see when I get to this.

MaxKless avatar Feb 26 '25 10:02 MaxKless

No worries. I'll play around with it on the weekend possibly.

Could you point out what's the entry point(s) to read the workspace projects?
I suppose we could then extract targets from said project models.

lppedd avatar Feb 26 '25 10:02 lppedd

for sure! You can use NxlsService.getInstance(project).workspace() to get all information about the workspace, which includes projects and their targets. You'll have to filter that down. As inspiration, have a look at the apps/intellij/src/main/kotlin/dev/nx/console/generate/NxGeneratorSearchEverywhereContributorFactory.kt class. As you've noticed, it doesn't quite work as expected right now, though. Still, what you will have to do will probably be similar.

Looking forward to what you cook up and I'm here to help out :)

MaxKless avatar Feb 26 '25 12:02 MaxKless

I've coded a prototype, however I'm trying to understand why a separate tab doesn't show the items.

Image

Debugging the underlying SE code is pretty much mission impossible.

lppedd avatar Mar 01 '25 13:03 lppedd

hmmm are you sure you want to add a separate tab there? It seems like a noisy addition... and the search everywhere does it job just fine, right?

MaxKless avatar Mar 06 '25 13:03 MaxKless

@MaxKless the problem arises when the amount of projects is decently large.
The All tab is ok when your search term is focused, but otherwise search results might get lost there.

There is also the question of item priority: should Nx items be prioritized over the rest?
Then again that tab becomes unusable when looking for other things.

lppedd avatar Mar 06 '25 13:03 lppedd

Btw, the additional tab can be configurable, so I guess it's not a big deal.

lppedd avatar Mar 06 '25 14:03 lppedd

yeah okay. I would make the extra tab off by default and opt-in in the settings, maybe. The other search everywhere are triggered by a specific keyword like nx run... maybe something similar could work here? Because when ppl type nx run it's fine that the search results are completely overtaken. What do you think?

MaxKless avatar Mar 07 '25 08:03 MaxKless