How to easily add a new method in Eclipse?

My colleague, new to Eclipse (from JBuilder), wants to know how to simply click on a class and add a new method. I right-clicked on the class in the Contour view, and of course there is no “new method” command. I can generate getters and setters, as well as delegate methods and retrieve methods, as well as pull methods up or push them, all of which are very useful, but I don’t see how to create a new method.

I can print private (or public), without spaces, and access code help using the control space, and also create a new method, and then I can right-click on this method and change the method signature from refactoring (alt-shift -C), but it seems that there should be a good way to click on the class somehow and immediately open the wizard of this signature to create a new method.

Is there any way to do this?

+5
source share
3 answers

The closest thing you can get to what you are describing is 1. Enter the name of the method (without a modifier or something else)
2. Press Ctrl-1 → Create a stub method
3. Press Alt-Shift-C to change the signature

+3
source

In addition to Turismo:

, TDD, Testcase. , , , .

void someTest() {
 MyClass myInstance = new MyClass();
 myInstance.theNewMethodGoesHere();
}

"theNewMethodGoesHere", undefined. ctrl + 1 , . . , testdriven.:)

+3

JDT , eclipse ( OSIN OSGi), Java.
: ... Java-.

The only eclipse environment in which you see this function (click on a class and enter new methods) is a UML-oriented editor, such as Omondo .
(In a UML2 , Papyrus or MDT-UML2Tools project, it may ultimately provide such editing capabilities)
But aside from these kinds of plugins, I don’t think you can achieve this way of creating new methods.

+2
source

All Articles