Emacs minor mode for editing and browsing Java source code
2016-02-13 | Version 0.98.0 of jtags-mode has been released, adding support for Java 8 constructs. Download it here. |
2016-01-18 | Version 0.97 has been released, after a long, long time. Among other things, it includes changes to make jtags work in Emacs 24.5. Download it here. |
2011-12-12 | Added support for http Javadoc URLs. You can configure jtags-mode to display either an http URL or a file URL depending on which package the looked up identifier belongs to. |
2011-11-22 | The latest development version of jtags-mode can now be found in a Git repository at SourceForge.net. |
The Emacs package jtags-mode is a minor mode that provides an improved tags lookup function compared to the ordinary etags package. The improved tags lookup function is only implemented for Java source code.
The jtags code acts as a middleware between Emacs and the etags program that is distributed with Emacs. Unlike the ordinary etags package, jtags parses the Java source code to find the correct context (e.g. the class around point, and any preceing expression). It then looks up and shows the declaration of the identifier, after finding the source code file in the tags table files. This is possible since jtags knows some Java syntax and deals only with Java source code.
Showing the declaration of an identifier
Consider the following line of Java code:
Bar.getInstance().foo().toString()
When showing the declaration of the method toString()
,
jtags will parse the Java code above, and with the help of the
tags lookup functions, find and parse the source code for the class
Bar
, and the methods getInstance()
and
foo()
. Using this information, jtags finds out in which
source code file the method toString()
is declared, loads
the file, and displays the declaration. Local variables and method
parameters can also be looked up, even though these are not included in
the tags table files.
Showing the Javadoc for an identifier
When showing the Javadoc for the method toString()
, jtags
will look up the declaration as above. It will then find and display
the Javadoc for the method toString()
or its class in the
system browser.
Completing an identifier
Consider the following unfinished statement:
myFile.li
When completing the statement above, jtags will parse the Java code and
lookup the variable myFile
. It will then find all members in
the corresponding class, and suggest completions like below.
Found 3 completions: list listFiles listRoots
Final and static members can be displayed using a different face, e.g. italics. Inherited members can also be displayed using a different face.
Adding and organizing import statements
When the compiler reports that it "cannot resolve symbol" because an import statement is missing, jtags can add the import statement for you. Place the point in the identifier and type C-c +. This will make jtags parse the Java code and the tags table files to find the package name, and add an import statement for the identifier.
You can also order and format the import statements in the current source code file. Type C-c =, and jtags will order the import statements and insert blank lines where appropriate. The sort order can be changed using customize.
These functions are placed in a separate package called jtags-extras since they are not part of the jtags-mode core functionality.
Updating tags table files
To find where in the source code an identifier is declared, jtags uses tags table files generated by the etags program. Included in the jtags package, is a function that automatically runs the etags program, and updates all the tags table files. You can also type C-c , to update only the tags table file for the project you are working on.
The latest release version of jtags-mode has been tested in GNU Emacs 23.1 and 24.5 on Windows 7.
Download the latest release version of jtags-mode here. Installation notes are included within the Emacs Lisp file itself. If you are using GNU Emacs 24 or later, you can also download and install jtags-mode from MELPA.
The latest development version of jtags-mode can be found in the Git repository.
© Johan Dykström 2016 | Last modified: 2016-02-13 20:47:03 |