coc-java icon indicating copy to clipboard operation
coc-java copied to clipboard

Select multiple fields when generating getters/setters, constructors, etc..

Open shadowphoenixpt opened this issue 6 years ago • 7 comments

I have been trying this plugin to replace JavaComplete2, but I have found a strange limitation on the method generation actions.When I try to generate a constructor, for examples, I can only select of the Class fields at a time. The same goes for generating getters and setters. Would it be possible to implement a way to select multiple field just like JavaComplete2 does? In a related matter, would be possible to separate setter and getter generation options? Sometimes I just need to create one or the other, not both.

shadowphoenixpt avatar Jul 01 '19 15:07 shadowphoenixpt

The problem is we don't have multiple selection method with vim.

chemzqm avatar Jul 02 '19 00:07 chemzqm

Well you can reuse coc-list code for that I guess.

purpleP avatar Jul 05 '19 16:07 purpleP

Are there any plans to add such a functionallity to coc.nvim so that this can be implemented?

patrickpichler avatar Oct 28 '19 18:10 patrickpichler

Well you can reuse coc-list code for that I guess.

Yes, it's just a bit complicated.

chemzqm avatar Oct 29 '19 01:10 chemzqm

As this is kinda of a showstopper for me, would you accept a PR which implements this functionality by doing multiple rounds of asking to select a field?

E.g. (~ shows user input):

Select fields:
1. name
2. age
3. height
4. cancel
~ 1

Select field:
1. age
2. height
3. cancel
~ 2

Select field:
1. age
2. cancel
~ [no input only enter]

You would have selected field 1,2

When selecting cancel the whole process would abort.

It is a bit primitive, but given what is currently available it is a basic solution which would work.

patrickpichler avatar Oct 29 '19 08:10 patrickpichler

In the PR I provided the naive simple approach. It works but it is nothing fancy.

patrickpichler avatar Oct 29 '19 22:10 patrickpichler

Well you can reuse coc-list code for that I guess.

Yes, it's just a bit complicated.

Well, maybe you could start with something simple - just create a buffer where each line would be the field name. User would delete lines he doesn't want and save the buffer. After it's saved you generate getters and setters and remove it.

purpleP avatar Nov 07 '19 05:11 purpleP

Should be fixed on recent version of coc-java, try upgrade coc.nvim to latest release and coc-java to version 1.14.0.

Multiple selection is support on recent coc.nvim.

chemzqm avatar Jan 29 '23 06:01 chemzqm

Curious… what's the keybinding to tick the boxes in the pop-up menu to select the fields for generating the constructor?

igbanam avatar Apr 12 '24 21:04 igbanam