Java SideKick

Version 4.2 (July 24 2022)

Dale Anson

Sreenivasa Viswanadha (base Java 1.5 grammar for javacc)

Michał Lorek (Antlr grammar for Java 17)

André Kaplan (JBrowse maintainer)

George Latkiewicz (original JBrowse author)

Alain Robert (JBrowse contributor)

Damien Radtke, Java code completion

Alan Ezust, documentation

Robert Schwenn, German translation

Introduction

The Java SideKick plug-in provides a highly customizable tool for navigating through Java source code. Using SideKick, you can see a tree view for the hierarchy of classes, interfaces, and methods for the file in the current buffer. In addition, attributes, extends, implements and method exception information can be displayed.

JavaSideKick parses and displays these files:

Like all SideKick plugins, JavaSideKick has no dockable view. Instead, it shares its view with other SideKick plugins through the SideKick Dockable. It is suggested you dock this to the left or the right.

Global Options -> Docking -> SideKick

"JBrowse" was the original Java browser plugin for jEdit, but is no longer being maintained. The "Java SideKick" retains all of the customizations that were provided by JBrowse, plus takes advantage of the features provided by SideKick. This documentation is based on the original provided with JBrowse.

A single mouse click on one of the nodes in the tree will highlight the line in the jEdit buffer where the definition of that item begins. Options are provided to control both what is displayed and how. Shift-click on a node will select that node in the buffer, so, for example, shift-clicking on a method will select the entire method. By virtue of SideKick, the tree will also follow the cursor in the buffer, so the selected node in the tree will change as you move from method to method in your source code.


Understanding the Java SideKick Tree Display

SideKick displays the hierarchy of elements in a tree using the options (see below) you have specified. You can choose to use either the standard icon set inherited from JBrowse, or icons like those used in Eclipse. Each element is displayed with one of the following icons:

Class icon  Class - all top-level classes, i.e. direct package members and nested static classes.

Interface icon  Interface - all top-level interfaces, i.e. direct package members and nested interfaces.

Member Class icon  Member Class - nested instance classes, i.e. non-static member classes.

Extends icon  Extends - a class that this class extends, or an interface that this interface extends.

Implements icon  Implements - an interface that this class implements.

Operation icon  Operation - operations (i.e. methods, functions, whatever you want to call them).

Throws icon  Throws - the type of an exception that this operation throws.

Attribute icon  Fields and Local Variables - both object and primitive fields as well as local variables may be displayed (see filter options below).

Error icon  Error - the parser has encountered an error in the source file. The specific error will be displayed in the ErrorList plugin. Fix the error and reparse to redisplay the tree.

It is possible to show these icons in the same style as Eclipse. Go to Plugins - Plugin Options - Java SideKick, then check Show icons and like Eclipse.

For javacc files the following icons may be displayed:

BNF Production icon  BNF productions

Regular Expression Production icon  Regular expression productions

Java Code Production icon  Java code productions

Token Manager Decl Production icon  Token manager declaration productions

Java SideKick Controls
Parse button icon Parse button - Clicking this button will cause the tree hierarchy to be re-built based on the current contents of the active buffer. When Java SideKick is opened, it automatically does this (unless the file does not have a ".java" extension). Changing any options will automatically update the tree display. Thus, the only reason to re-parse is because the file contents have changed, or a different buffer has been activated or because you want to check a file for errors before saving.


Navigating the Java SideKick Tree

The tree can be navigated using both the mouse and the keyboard. The keys and their associated actions, as listed below, are those that are common to all the standard look & feels.

Action Key
Expand/collapse node Right, Left
Toggle expand/collapse for current node Enter
Move up/down one node Up, Down
Move to first/last node Home, End
Move up/down one page PgUp, PgDn

Java SideKick Options

Note: Java SideKick is a SideKick extension, so some settings are controlled by the SideKick plugin itself (Plugins->Plugin Options->SideKick). The options described here are specific to Java SideKick (Plugins->Plugin Options->JavaSideKick);

Java SideKick is highly configurable, using a set of option values that control the behavior and appearance of the tree that is displayed for a parsed Java program file. A set of default option values is stored in a property file, which is loaded each time a new Java SideKick session is started. While Java SideKick is running these options may be changed on-the-fly using the Java SideKick Options Dialog.

The tables below describe the effect of each option value. These options are grouped into two basic categories:


Filtering options (What to display):

These options specify which types of elements are to be displayed in the tree. Changing any of these options will cause the entire tree to be reloaded using the new option setting.

Attributes If set then Object attributes will be included in the tree.
include primitives If set then primitive attributes will also be included in the tree.
Show local variables If set, then local variables within method bodies will be displayed.
show static initializers If set, then static initializer blocks will be included in the tree. Since static blocks don't have names, the name in the tree will be "static_XX", where XX is the line number for the start of the block.
extends/implements If set then for each class and interface the classes and interfaces that they extend or implement (if any) will be displayed as their immediate child nodes in the tree.
Method throws type(s) If set then the types of all exceptions that an operation is defined to throw (if any) will be listed as the immediate child nodes of that operation.
Lowest Visibility level to show, Top-Level Specifies the minimum visibility level that a top-level element (non-nested class or interface) must have to be displayed in the tree.
Lowest Visibility level to show, Member Specifies the minimum visibility level that a member element (attribute or method) must have to be displayed in the tree.

Display options (How to display):

These options specify the format that is to be used to display the elements in the tree. Changing any of these options will normally update the display without reloading the tree.

General Display Options

The following options can be set independently of the current Display Style.

Arguments If set then the type signature of each argument will be displayed for operations.
formal names If set then the formal names of each argument will be displayed for operations.
Show Generics type arguments If set, then generics type arguments, if any, will be shown. This applies to all elements that may show a generic type.
Qualify nested class/interface names If set then fully qualified names will be displayed for all nested classes and interfaces (as opposed to just the final component of the name).
Keywords specified by icons If set then the keywords directly associated with the icons for class, interface, extends, implements & throws will be displayed, otherwise they are suppressed.
Implementation detail modifiers If set then display all implementation detail modifiers (i.e. synchronized, native, strictfp, transient, & volatile), else suppress these modifiers.
Line Numbers If set then the line number at which the definition of each element begins will be displayed.
Sort by Item can be sorted by line, name, or visibility.
Show parse errors in ErrorList If set then any errors found during parsing of the buffer will be displayed in the ErrorList plugin. For Java files, this can be useful since the parser will find most of the errors that will be found by javac without the overhead of invoking the compiler.
Display Style Can be set to Java (all custom options off), UML (all custom options on) or Custom (allows individual settings for all custom options).

Since JavaSickKick is a SideKick extension, mousing over items in the tree will cause the full details of the item to be displayed in jEdit's status bar. This means you can do things like turn off display of line numbers in the tree, but still see the line number for an item by moving the mouse over the item then looking in the status bar. Mousing over the root of the tree will also show some statistics about the file: class, interface, method, and field count will be displayed in the status bar.

Custom Display Options

The following options are controlled by the current Display Style. they can be individually set if the current Display Style is set to 'Custom'.

Use Visibility Symbols If set then 'public', 'protected', 'package' and 'private' visibility is labeled by a '+', '#', ' ' or '-', respectively.
Abstract in italics If set then interfaces and abstract classes and methods are identified by appearing in italics (as opposed to specifying the modifier).
Static as underlined If set static methods and attributes are identified by being underlined, (as opposed to presence of the 'static' modifier).
Type identifier as a suffix  If set then the type identifiers (for method return types, arguments and attributes) will appear after the item whose type is being specified (preceded by a ' : ').

Actions

There are actions to insert an import statement for the symbol under the cursor, as well as for refreshing the global classloader. Other functionality of this plugin (such as completion) comes from the SideKick plugin, so there are more actions there.


Code Completion

Code Completion

JavaSideKick offers several different uses for code completion. The line at the end of each example represents the cursor position when completion is invoked (Plugins -> SideKick -> Show Completion Popup).

The delay and behavior of auto-completion can be configured from Plugin Options - Sidekick - General.

Using with SuperAbbrevs

If you have the SuperAbbrevs plugin installed, completing methods or constructors works a little bit differently. Rather than insert just the name of the method, the entire declaration will be inserted, with each parameter highlighted; pressing Tab cycles through the parameters.


Configuring the Classpath

Configuring the Classpath

Classpath settings have been migrated to the Classpath plugin.
Building a parser with javacc

Building a Parser with javacc

This is out of date, it still applies to the javacc parser and the properties parser, but the java parser uses Antlr rather than javacc.

The source code for the JavaSideKick plugin is ready to build with javac and jar. On occasion, it may be necessary to make changes to the parser. The parser is actually created by javacc. Javacc is a parser generator, it reads a 'grammar specification' file, and from that file creates a number of java files that can recognize matches to that grammar.

The parser directory contains a number of files. Only one should be edited, and a second deserves special mention. The remaining files should never be dealt with by hand.

This file can be edited. It contains all the parsing code and builds the nodes for the tree:

This file is used by javacc to actually create the parser. (Why 'Tiger'? 'Tiger' was Sun's code name for Java 1.5.)

This file should not be edited (unless you know exactly what you're doing).

This file is used by Tiger.jj to parsing Java source code into tokens. It has been hand-modified specifically for Tiger.jj.

The remaining files are generated by javacc from Tiger.jj. Do not edit these by hand. The build file will delete these files and regenerate them when the javacc target is executed.

Once the Tiger.jj file has been processed by javacc, the complete plugin can be built by javac. So the build sequence is:

Enjoy!