Skip to content
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

How to automatically implement an interface into a class without typing out all methods? #270

Closed
MatthewMcConnell opened this issue Aug 2, 2017 · 11 comments
Assignees

Comments

@MatthewMcConnell
Copy link

I couldn't find a way to do this without copying each method, I know it can be done automatically but I'm not sure if this extension can do this.

Any help is much appreciated :)

@fbricon
Copy link
Collaborator

fbricon commented Aug 2, 2017

We're not there yet. We need a Code Action to implement missing methods. (See jdt.ls#169).

The least bad alternative right now is to use content assist to override each method. The method body will be generated.

aug-02-2017 12-14-18

@fbricon
Copy link
Collaborator

fbricon commented Aug 2, 2017

@yaohaizh is this something you or someone from your team could address? It's an important usability feature.
cc @akaroml

@yaohaizh yaohaizh self-assigned this Aug 3, 2017
@yaohaizh
Copy link
Collaborator

yaohaizh commented Aug 3, 2017

@fbricon No problem, I talked about this issue with @aeschli before and would like to add this code action.

@fbricon
Copy link
Collaborator

fbricon commented Aug 4, 2017

@yaohaizh PR works really well

aug-04-2017 13-30-14

we should be able to merge it once you fix the couple issues I mentioned in my review.

@fbricon
Copy link
Collaborator

fbricon commented Aug 8, 2017

New code action is available in the latest CI build. You can get the most recent java-<version>.vsix file from http://download.jboss.org/jbosstools/jdt.ls/staging/ and install it by following the instructions here.

@fbricon fbricon closed this as completed Aug 8, 2017
@fbricon
Copy link
Collaborator

fbricon commented Aug 8, 2017

Be aware though, for the moment, the implemented methods use tab indentation by default (see microsoft/vscode#32158).

If you use spaces for indentation instead and enabled automatic format on save ("editor.formatOnSave": true), then tabs will be replaced by spaces when the file is saved.

Alternatively, you can add the following to your project's .settings/org.eclipse.jdt.core.prefs:

org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=4

@kdlan
Copy link

kdlan commented Dec 17, 2018

How to use this feature? I could not find the Add unimplemented methods button in my editor

VSCode version:1.29.1
Language Support for Java(TM) by Red Hat version: 0.35.0

@yaohaizh
Copy link
Collaborator

yaohaizh commented Dec 17, 2018

@kdlan See this :
repro

@kdlan
Copy link

kdlan commented Dec 17, 2018

@yaohaizh
It works. Thanks

@mnguyen081002
Copy link

In Android Studio, ctrl + O
image

@Eskibear
Copy link
Contributor

In VS Code, Source actions.

source_actions.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants