Java Code Macros
Prev | Appendix F. Macros Included With jEdit | Next

## Java Code Macros

These macros handle text formatting and generation tasks that are particularly useful in writing Java code.

- `Create_Constructor.bsh`

  Inserts constructor for the class at the current caret position.

- `Get_Class_Name.bsh`

  Inserts a Java class name based upon the buffer's file name.

- `Get_Package_Name.bsh`

  Inserts a plausible Java package name for the current buffer.

  The macro compares the buffer's path name with the elements of the classpath being used by the jEdit session. An error message will be displayed if no suitable package name is found. This macro will not work if jEdit is being run as a JAR file without specifying a classpath; in that case the classpath seen by the macro consists solely of the JAR file.

- `Java_File_Save.bsh`

  Acts as a wrapper script to the Save As action. If the buffer is a new file, it scans the first 250 lines for a Java class or interface declaration. On finding one, it extracts the appropriate filename to be used in the Save As dialog.

- `Make_Get_and_Set_Methods.bsh`

  Creates `getXXX()` or `setXXX()` methods that can be pasted into the buffer text.

  This macro presents a dialog that will “grab” the names of instance variables from the caret line of the current buffer and paste a corresponding `getXXX()` or `setXXX()` method to one of two text areas in the dialog. The text can be edited in the dialog and then pasted into the current buffer using the Insert... buttons. If the caret is set to a line containing something other than an instance variable, the text grabbing routine is likely to generate nonsense.

  As explained in the notes accompanying the source code, the macro uses a global variable which can be set to configure the macro to work with either Java or C++ code. When set for use with C++ code, the macro will also write (in commented text) definitions of `getXXX()` or `setXXX()` suitable for inclusion in a header file.

- `Preview_Javadoc_of_Buffer.bsh`

  Create and display API documentation for the current buffer.

  The macro includes various configuration variables you can change; see the comment at the beginning of the macro source for details.

Prev | Up | Next
User Interface Macros | Home | Miscellaneous Macros