Skip to content

Add code action: Generate Delegate Methods... #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2019

Conversation

testforstephen
Copy link
Contributor

@testforstephen testforstephen commented May 17, 2019

Signed-off-by: Jinbo Wang [email protected]

Close #1042

delegateMethods

@snjeza
Copy link
Contributor

snjeza commented May 17, 2019

test this please

@fbricon
Copy link
Contributor

fbricon commented May 17, 2019

Works pretty well, but like in Eclipse, we should be able to select delegate methods from different sources, so instead of selecting one delegate, we should have a multiple selection instead in the 1st step, and eventually be able to cherry pick which methods from any/all delegate to implement.

Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

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

Please allow selection of multiple delegates

@testforstephen
Copy link
Contributor Author

testforstephen commented May 20, 2019

I have tried to allow multiple selection at 1st step, but i didn't find a good way to handle the method name conflicts at 2st step.

For example, if you select two fields with the same class type at 1st, then select all at 2st step, eclipse adds some validation at the dialog, and disable the Generate button with error message "x duplicated methods selected". In VS Code UI, i didn't think of a good way to provide validation error in real time yet.

Keep it as single selection at 1st step, that could avoid the method conflict. Actually this is also the Intellij IDEA behavior.

@testforstephen
Copy link
Contributor Author

test this please

@fbricon
Copy link
Contributor

fbricon commented May 21, 2019

Ok fair enough. I can live with that for a bit.
I'm a bit annoyed by the message you receive when there's no more methods to delegate. Take this for instance:

private Runnable runner;

public void run() {
    runner.run();
}

It says No delegatable fields found in current class., which is incorrect. When there's no methods left to delegate, the message should something like All delegatable methods are already implemented. (or something better)

@testforstephen
Copy link
Contributor Author

already updated the client side PR for the error message.

@testforstephen
Copy link
Contributor Author

test this please

@fbricon fbricon merged commit aca941c into eclipse-jdtls:master May 23, 2019
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.

Add code action to generate delegate methods
3 participants