jEdit ErrorList plugin user's guide | Version 2.4.0 (April 8 2021) |
Legal Notice
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
"Invariant Sections", "Front-Cover Texts" or
"Back-Cover Texts", each as defined in the license. A copy of
the license can be found in the file COPYING.DOC.txt
included with jEdit.
Table of Contents
The ErrorList plugin displays errors and warnings generated by other plugins. It does nothing on its own; for it to be useful, some plugins that support the error reporting API must be installed.
The error reporting API is particularly well-suited to reporting compiler errors and such; plugins that use this API include Console, SideKick, and ClangCompletion. If you would like to use it from your plugin, see the section called “The error reporting API”.
In projects with multiple subfolders, a build error message may not report the
complete or correct pathname of the file with the error, and ErrorList may have trouble
opening the correct file when the user clicks on an ErrorList entry.
In such a case, ErrorList will use a FileOpenerService
, such as
FastOpen
or SmartOpen
, to open the file. Since each
of these plugins can be configured to search the current project and/or the recently open
buffers, this gives you flexibility on how ErrorList can open the files of the errors
you click on in ErrorList. To tell ErrorList to use a
FileOpenerService
, simply install one of these plugins:
SmartOpen
or FastOpen.
> > displays the error list window.
The ErrorList can show multiple errors from multiple error sources at the same time, for example, PMD errors can be shown in the error tree, then subsequent compiler errors can be shown in the same tree. Simply click the 'Toggle multiple errors' icon in the ErrorList toolbar.
The buttons with the error and warning icons on the left of the window toolbar enable you to toggle the display of errors and warnings.
The error reporting API supports two types of errors; genuine errors and warnings. The two are differentiated with different-colored icons in the tree; errors have a red icon, warnings have a yellow one.
It is possible to copy the text of all or some of the error messages to the system clipboard either from the actions menu, or from context menu on the error list pane.
For information on keyboard-based navigation of the tree, see the section called “Additional commands”.
The ErrorList plugin highlights errors in-place in the text area with a colored underline. The color depends on the error type; genuine errors have a red underline, warnings have a yellow one.
Hovering the mouse over a line with an error highlight will show a tooltip with the error message.
Error highlighting can be disabled in the
pane of the dialog box. The colors of the underlines can also be changed in that same option pane.When a buffer has errors, the ErrorList plugin displays a global overview of all errors in a vertical bar to the left of the text area's vertical scroll bar. Each error is shown as a thin horizontal line. The color depends on the error type; genuine errors have a red underline, warnings have a yellow one. Clicking on an error will scroll the text area to that location. Hovering the mouse over an error will show a tooltip with the error message.
The error overview can be disabled in the
pane of the dialog box. The colors of the highlights can also be changed in that same option pane.The ErrorList plugin provides a few additional commands that can be bound to keyboard shortcuts in the
pane of the dialog box.> > moves the caret to the error immediately before the one currently selected in the error list window. If no error is selected, the last error in the list is chosen. This will open the appropriate file if the error is in a different file.
> > moves the caret to the error immediately after the one currently selected in the error list window. If no error is selected, the first error in the list is chosen. This will open the appropriate file if the error is in a different file.
> > opens the file immediately before the one currently selected in the error list window. If no file is selected, the last file with errors is chosen.
> > opens the file immediately after the one currently selected in the error list window. If no file is selected, the first file with errors is chosen.
> > toggles the display of errors in the tree.
> > toggles the display of warnings in the tree.
> > copies the currently highlighted error to the clipboard.
> > copies all the errors from the current error list to the clipboard.
> > expands all of the errors displayed in the error tree.
> > collapses all of the errors displayed in the error tree.
Errorlist offers the following configurable options.
Show the errorlist whenever an error is found
Hide the errorlist when there are no errors
Give the TextArea keyboard focus after the ErrorList is shown
Show totals (errors/warnings) at top of errorlist
Select whether you want the glob pattern to be for inclusion or
exclusion, and enter a glob pattern below. For example: *.{c,h}
specifies all C source and header files. See Appendix D. "Glob Patterns" in the
jEdit users guide for more details.
To make jEdit more "eclipse-like" put icons in the gutter instead of underlines.
The error reporting API is very simple. A plugin that wishes to use it must do these three things:
Specify that it requires the ErrorList plugin.
Register an "error source" at some stage, usually during startup.
Add errors to the error source when they occur.
The ErrorList plugin handles the rest (displaying errors in a list, error highlighting, and so on) automatically.
All error list classes mentioned in this section are contained in the
errorlist
package. So you should add an import statement
like the following to the start of your plugin's source file(s):
import errorlist.*;
In order to give the user a helpful error message if the ErrorList
plugin is not installed, your plugin should specify dependency properties.
If your plugin's core class is named MyPlugin
, the
corresponding dependencies might look like so:
plugin.MyPlugin.depend.0=jedit 04.02.02.00 plugin.MyPlugin.depend.2=plugin errorlist.ErrorListPlugin 1.3
Note that the current version of the ErrorList plugin requires jEdit 4.2pre2 or later, so your plugin should also require at least that jEdit version. If a newer version of the ErrorList plugin is available, you can specify higher version numbers than in the example above. However, all the API calls in this section are guaranteed to work with the above version, so in most cases you shouldn't worry about it.
Errors are managed by implementations of the
errorlist.ErrorSource
abstract class.
Extending this class is a bit involved and requires writing a lot of
low-level code; most
plugins can use the errorlist.DefaultErrorSource
class instead, which provides a very easy-to-use front-end.
The constructor for the DefaultErrorSource
class
accepts two parameters; the first is a string that will identify the error source.
Currently, this identifier is not used, but in the future the ErrorList plugin
might show which error comes from which plugin, for example.
The second argument is the View that errors should be shown in. Plugins that
send errors should take care to send them to the correct View's ErrorList, so that
they do not appear in all Views.
Error sources should be registered when the user first invokes your plugins. A plugin can create any number of error sources. The Console plugin, for example, maintains a separate error source for each console window, and registers an unregisters them as each command is executed.
To add an error source to the list of registered error sources, you must call
the static registerErrorSource()
method of the
errorlist.ErrorSource
class.
A corresponding unregisterErrorSource()
method must be
called before your plugin is unloaded to avoid leaking memory.
A custom ErrorSource
implementation would need to
send the appropriate EditBus message when an error arrives, and then
provide implementations of various "getter" methods that
the ErrorList plugin would later call to obtain the error.
Using DefaultErrorSource
makes the task much easier.
In fact, all that is involved is calling a single method on the appropriate
DefaultErrorSource
instance:
public void addError( | DefaultErrorSource.DefaultError error) ; |
The constructor of the DefaultErrorSource.DefaultError
class is as follows:
public DefaultError( | int type, |
String path, | |
int line, | |
int start, | |
int end, | |
String message) ; |
type
- this should be either
ErrorSource.ERROR
or
ErrorSource.WARNING
.
path
- the path, filename, or URL of
the file containing the error. If this is just a filename, ErrorList will
use a FileOpenerService
to open the buffer.
line
- the line number in the file
where the error occurred. Lines are numbered starting from zero; since most
tools and compilers report line numbers starting from 1, you might need to
subtract 1 from the number before passing it to this method.
start
- an offset in the line where
the error begins.
end
- an offset in the line where
the error ends. These two values are only used to give a more exact
display for error highlighting, and if both are zero, the entire line will be
highlighted.
message
- the error message itself,
as shown in the error list window and error highlighting tooltips.
This method is fully thread safe; if your plugin generates errors from
another thread, it can call this method without having to use any of the
usual SwingUtilities.invokeLater()
tricks required
when calling non-thread safe methods.
Here are two examples of addError()
calls. The first
adds a warning, covering the entire line, the second adds an error that
only applies to a subset of the specified line:
errorSource.addError(new ErrorSource.DefaultError( ErrorSource.WARNING,path,line,0,0, "Are you sure this is what you intended?")); errorSource.addError(new ErrorSource.DefaultError( ErrorSource.WARNING, MiscUtilities.constructPath(directory,"input.src"), line,0,5,"First five characters of line are bad"));
Multiple-line messages can be created by calling the following method
on the DefaultError
instance before it is added
to the error source (the last part is important, otherwise the extra
messages will not be shown):
public void addExtraMessage( | String extra) ; |
That's basically all there is to it. There is one more method in the
DefaultErrorSource
class that needs to be mentioned:
public void clear( | void) ; |
This method removes all errors from the error source. It is typically called before each invocation of the operation that generates errors; for example, the Console plugin clears its error source before each new command is run.
public void removeFileErrors( | void) ; |
For more selective error removal, this method can be used to remove errors associated with one file only.
Version 2.4. Requires Java 11, and jEdit 5.5
Plugin Patch #182: ErrorList Avoid NPE on Error with null message (Eric Le Lay)
Plugin Patch #183: Handle Properties Changed message properly (Eric Le Lay)
Fixed plugin-bug #1812: ErrorList: Copy all to clipboard doesn't.
Version 2.3. By Alan Ezust, Requires Java 1.6, and jEdit 5.0
Plugin Feature Request #208: Copy errors to clipboard, either via right click menu, or by action menu. (Plugin Patch #163 - Tim Blackler)
Plugin Feature Request #312: Expand/Collapse All (Plugin Patch #164 - Tim Blackler)
Version 2.2. by Alan Ezust, Requires Java 1.6, and jEdit 5.0
Revisited #3596333: Preserve contents when floating/docking.
FileOpenerService is now being used in the correct way by ErrorList
Version 2.1. Requires Java 1.6, and jEdit 5.0
Fixed #3573458: ErrorList does not work with SymLinks (Patrick Eibl)
Fixed errors not appearing without manual dockable activation, a bug introduced in version 2.0 (#3556671 Jarek Czekalski)
Added squiggle underline style (Matthieu Casanova)
"Clear Errors" no longer clears errors in all views (Alan Ezust).
Fixed #3596333: bad initial contents when creating a new view (Alan Ezust).
German localization (Robert Schwenn)
Version 2.0. Requires Java 1.6, and jEdit 5.0pre1.
Uses jEdit 5's FileOpenerService
for filenames when
no full path is supplied to the DefaultError. (#3481157 - Alan Ezust)
New API for specifying the View of an ErrorSource. (#2106739 - Alan Ezust)
Fixed a deadlock and concurrency issues. (#3526070, #3530999 Jarek Czekalski)
Fixed errors appearing twice at first time. (#3028049 Jarek Czekalski)
French localization (jojaba_67)
Version 1.9. requires Java 1.5, and jEdit 4.3.
Fixed deadlock condition arising from new EditBus behavior in jEdit 4.4 (Kazutoshi Satoda)
Version 1.8. requires Java 1.5, and jEdit 4.3pre7.
display error.extraMessages in GutterIcon (Dwayne Bernard - # 1854405)
Remembers state of error/warning buttons (Shlomy Reinstein)
Automatically Show on Errors no longer shows when only hidden warnings pass through (#2907190 - Shlomy Reinstein)
No longer displays ErrorList when adding a zero-length ErrorSource. (#1869137 - Alan Ezust)
Enable multiple errors at different offsets in a same line. (Patch #2011885 - kerik)
Version 1.7. requires Java 1.5, and jEdit 4.3pre7.
DefaultErrorSource.DefaultError
has new method: setFilePath()
(for SshConsole).
Version 1.6. requires Java 1.5, and jEdit 4.3pre7.
New option to hide warnings (patch 1719791 by Shlomy Reinstein)
New options to filter files based on filename globs. (Shlomy Reinstein)
New option to show icons instead of underlines under errors (Shlomy Reinstein, 1653073)
Improved keyboard Handling when ErrorList has focus (patch 1729970 by k_satoda)
Version 1.5. requires Java 1.4, and jEdit 4.2 final.
Bugfix to avoid displaying duplicate errors (k_satoda).
New option: autoRefocusTextArea: When ErrorList gets focus, it now deliberately passes the focus back to the current jEditTextArea. (ezust)
Version 1.4. requires jEdit 4.2final.
Add option to close error list after no errors remain (Gerd Knops).
Option "Automatically display on error" no longer causes ErrorList to request the focus, so that the cursor stays in the edit pane (Dirk Moebius).
Version 1.3.2. requires jEdit 4.2pre8.
After adding and adding an error source, removing and adding it again would not add the error source to the EditBus, so it would not receive notifications of buffers being opened, and as a result floating positions for errors would not be created.
Fix display of selected entires in the error list when using the GTK look and feel.
New icons for errors and warnings.
Version 1.3.1. requires jEdit 4.2pre2.
Show on error option didn't always work.
Fixed exception when using GTK+ look and feel.
Fixed assorted problems when file paths contained symbolic links.
Version 1.3. requires jEdit 4.2pre2.
Added optional "error overview" to the right of the text area (on by default).
Added buttons to the error list window for going to the next and previous error and file with errors, respectively.
Fixed problem with errors appearing twice when the Show on error option was on.
Fixed problems with soft wrap.
Fixed problems with split views.
Updated for jEdit 4.2 API changes.
Added removeFileErrors()
method to
DefaultErrorSource
class.
Performance improvements.
Version 1.2.3. requires jEdit 4.1pre2.
The error list no longer flashes like a deprived man due to constant tree collapsing and expansion if errors are being added in a background thread.
Error tool tips were not shown for some errors.
Highlighter no longer paints wavy lines, since with some fonts this would result in the line extending below the bottom of the text descent. Now the error highlights are plain vanilla underlines.
Fixed minor issue with error tree root node.
Updated code to use a few 4.1 API additions.
Version 1.2.2. requires jEdit 4.0pre4.
Fixed possible NullPointerException
under Java 2 version 1.4.
Error highlight didn't work properly when soft wrap was enabled.
If the "show on error" feature is enabled, the error list will now open in the currently focused view, not the most recently opened view as before.
Version 1.2.1. requires jEdit 4.0pre4.
Updated to use jEdit 4.0pre4 text area extension API.
Version 1.2. requires jEdit 4.0pre1.
Updated for jEdit 4.0 API changes.
EditBus plugin merged with this one.
Changes to error source API; see the section called “The error reporting API” for details.
Version 1.1.2. requires jEdit 3.2pre8 and the EditBus plugin 1.1.
If the error list was open but not visible, the Show on error option would do nothing.
If no error sources were registered, all highlights added after the error list would not be painted.
Version 1.1.1. requires jEdit 3.2pre8 and the EditBus plugin 1.1.
Line numbers in the tree are now increased by one, so that they match the textarea line numbers (Dirk Moebius)
The commands "Next/Previous Error" and "Next/Previous File With Errors" now ensure that the newly selected error is visible (Dirk Moebius)
Supports multiple-line error messages, introduced by EditBus 1.1
Version 1.1. requires jEdit 3.2pre8 and the EditBus plugin 1.0.1.
Errors are now shown in a tree, not a list
Error highlighting does not highlight leading whitespace of lines, leading to better appearance
Minor update for jEdit 3.2 selection API
Documentation generated with DocBook
Error reporting API documentation included
All jEdit users are encouraged to join the
<jedit-users@lists.sourceforge.net>
mailing list to give
feedback or ask questions to other users and developers.
The preferred way to send bug reports against most jEdit plugins is to use the jEdit Plugin Bugs Tracker.
Feature requests can be found on the jEdit Plugin feature requests tracker.
Development questions should be posted to the jEdit development
mailing-list <jedit-devel@lists.sourceforge.net>
.