Vscode-java: How to automatically implement an interface into a class without typing out all methods?

Created on 2 Aug 2017  路  9Comments  路  Source: redhat-developer/vscode-java

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 :)

enhancement

Most helpful comment

Be aware though, for the moment, the implemented methods use tab indentation by default (see https://github.com/Microsoft/vscode/issues/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

All 9 comments

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

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

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

@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.

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.

Be aware though, for the moment, the implemented methods use tab indentation by default (see https://github.com/Microsoft/vscode/issues/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

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

@kdlan See this :
repro

@yaohaizh
It works. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ulongx picture ulongx  路  4Comments

protoEvangelion picture protoEvangelion  路  3Comments

tveimo picture tveimo  路  4Comments

ronniehicks picture ronniehicks  路  3Comments

yaohaizh picture yaohaizh  路  4Comments