80 lines
2.0 KiB
Plaintext
80 lines
2.0 KiB
Plaintext
*vim-java-delegate*
|
|
|
|
|
|
Delegate Methods
|
|
****************
|
|
|
|
*:JavaDelegate*
|
|
|
|
Eclim supports generation of delegate methods via the :JavaDelegate
|
|
command. To utilize this functionality you must first place the cursor
|
|
on a global field (in the main source file class or within an inner
|
|
class), and then invoke the :JavaDelegate command.
|
|
|
|
In the following source, you can place the cursor anywhere starting
|
|
from the first 'p' in private, to the trailing semicolon, and then
|
|
invoke the :JavaDelegate command.
|
|
|
|
>
|
|
|
|
private List myList;
|
|
|
|
<
|
|
|
|
|
|
Invoking this command with the cursor on some other source element
|
|
will generate the appropriate error.
|
|
|
|
Once successfully invoked, the result will be the opening of a lower
|
|
window with all the methods that may be inserted that will delegate to
|
|
the value of the field.
|
|
|
|
Here is a section of the content displayed when invoking the command
|
|
on a field of type java.util.List like the one above.
|
|
|
|
>
|
|
|
|
com.test.TestList
|
|
|
|
package java.util;
|
|
public interface List
|
|
public abstract int size ()
|
|
public abstract boolean isEmpty ()
|
|
public abstract boolean contains (Object o)
|
|
public abstract Object[] toArray ()
|
|
...
|
|
|
|
<
|
|
|
|
|
|
From this newly opened window you can select a method by simply
|
|
hitting <enter> with the cursor over the method signature and a
|
|
delegate method will be created.
|
|
|
|
For example, if you hit <enter> on the size() method, then the
|
|
following code will be inserted.
|
|
|
|
>
|
|
|
|
/**
|
|
*/
|
|
public int size ()
|
|
{
|
|
return myList.size();
|
|
}
|
|
|
|
<
|
|
|
|
|
|
If you would like to generate delegate methods for all methods in an
|
|
interface or class, then simply hit <enter> with the cursor over the
|
|
class name, and delegate methods will be created for each method in
|
|
that interface or class.
|
|
|
|
Note: The insertion of method stubs is done externally with Eclipse and
|
|
with that comes a couple caveats (|vim-issues|).
|
|
|
|
This functionality is currently supported for both outer and inner
|
|
classes, but not for anonymous inner classes.
|
|
|
|
vim:ft=eclimhelp |