/bundles/plugins-trunk/ErrorList/users-guide.xml
# · XML · 670 lines · 547 code · 119 blank · 4 comment · 0 complexity · e5aee5bd1ef2efca617defb948cae65c MD5 · raw file
- <?xml version="1.0"?>
- <!-- ErrorList user's guide -->
- <!-- (C) 2001, 2005 Slava Pestov -->
- <!-- jEdit buffer-local properties: -->
- <!-- :tabSize=1:indentSize=1:noTabs=true:folding=sidekick: -->
- <article xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation='http://www.docbook.org/xsd/4.4/docbook.xsd' >
- <articleinfo><title>ErrorList plugin user's guide</title>
- <author><firstname>Slava</firstname><surname>Pestov</surname></author>
- <legalnotice><title>Legal Notice</title>
- <para>
- 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
- <quote>Invariant Sections</quote>, <quote>Front-Cover Texts</quote> or
- <quote>Back-Cover Texts</quote>, each as defined in the license. A copy of
- the license can be found in the file <filename>COPYING.DOC.txt</filename>
- included with jEdit.
- </para>
- </legalnotice>
- </articleinfo>
- <section id="intro"><title>Introduction</title>
- <para>
- 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.
- </para>
- <para>
- The error reporting API is particularly well-suited to reporting compiler errors
- and such; plugins that use this API include Console, JCompiler, and
- SideKick.
- If you would like to use it from your plugin, see <xref linkend="api" />.
- </para>
- </section>
- <section id="window"><title>The error list window</title>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Error List</guimenuitem> displays the error
- list window.
- </para>
- <para>
- Errors are shown in a tree control, with each branch being a file, and each
- leaf an error. Clicking on a file will open that file; clicking on an error
- will open the file containing the error and move the caret to its location.
- </para>
- <para>
- 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.
- </para>
- <para>
- 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.
- </para>
- <para>
- For information on keyboard-based navigation of the tree, see
- <xref linkend="actions" />.
- </para>
- </section>
- <section id="highlight"><title>Error highlighting</title>
- <para>
- 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.
- </para>
- <para>
- Hovering the mouse over a line with an error highlight will show a tooltip
- with the error message.
- </para>
- <para>
- Error highlighting can be disabled in the <guibutton>Error List</guibutton> pane
- of the <guimenuitem>Plugin Options</guimenuitem> dialog box. The colors of
- the underlines can also be changed in that same option pane.
- </para>
- </section>
- <section id="overview"><title>Error overview</title>
- <para>
- 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.
- </para>
- <para>
- The error overview can be disabled in the <guibutton>Error List</guibutton>
- pane of the <guimenuitem>Plugin Options</guimenuitem> dialog box. The colors
- of the highlights can also be changed in that same option pane.
- </para>
- </section>
- <section id="actions"><title>Additional commands</title>
- <para>
- The ErrorList plugin provides a few additional commands that can be bound to
- keyboard shortcuts in the <guibutton>Shortcuts</guibutton> pane of the
- <guimenuitem>Global Options</guimenuitem> dialog box.
- </para>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Go to Previous Error</guimenuitem> 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.
- </para>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Go to Next Error</guimenuitem> 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.
- </para>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Go to Previous File With Errors</guimenuitem>
- 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.
- </para>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Go to Next File With Errors</guimenuitem>
- 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.
- </para>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Toggle Display of Errors</guimenuitem>
- toggles the display of errors in the tree.
- </para>
- <para>
- <guimenu>Plugins</guimenu>><guisubmenu>Error
- List</guisubmenu>><guimenuitem>Toggle Display of Warnings</guimenuitem>
- toggles the display of warnings in the tree.
- </para>
- </section>
- <section id="options"> <title> ErrorList Options </title>
- <para> Errorlist offers the following configurable options. </para>
- <glosslist>
- <glossentry>
- <glossterm> Automatically Display on Error </glossterm>
- <glossdef> <para> Show the errorlist whenever an error is found </para> </glossdef>
- </glossentry>
- <glossentry>
- <glossterm> Auto-close on no errors </glossterm>
- <glossdef> <para> Hide the errorlist when there are no errors </para></glossdef>
- </glossentry>
- <glossentry>
- <glossterm> Auto-refocus on text area </glossterm>
- <glossdef><para> Give the TextArea keyboard focus after the ErrorList is shown </para></glossdef>
- </glossentry>
- <glossentry>
- <glossterm> Show Error Overview </glossterm>
- <glossdef><para> Show totals (errors/warnings) at top of errorlist </para></glossdef>
- </glossentry>
- <glossentry>
- <glossterm> Filename Filters </glossterm>
- <glossdef><para> Select whether you want the glob pattern to be for inclusion or exclusion, and enter a glob pattern below. For example: <literal>*.{c,h}</literal> specifies all C source and header files. See Appendix D. "Glob Patterns" in the jEdit users guide for more details.
- </para></glossdef>
- </glossentry>
- <glossentry>
- <glossterm> Show Icons instead of Underlines </glossterm>
- <glossdef><para> To make jEdit more "eclipse-like" put icons in the gutter instead of underlines. </para></glossdef>
- </glossentry>
- </glosslist>
- </section>
- <section id="api"><title>The error reporting API</title>
- <para>
- The error reporting API is very simple. A plugin that wishes to use it must
- do these three things:
- </para>
- <itemizedlist>
- <listitem><para>Specify that it requires the ErrorList plugin.</para></listitem>
- <listitem><para>Register an <quote>error source</quote> at some stage,
- usually during startup.</para></listitem>
- <listitem><para>Add errors to the error source when they occur.</para></listitem>
- </itemizedlist>
- <para>
- The ErrorList plugin handles
- the rest (displaying errors in a list, error highlighting, and
- so on) automatically.
- </para>
- <note>
- <para>
- All error list classes mentioned in this section are contained in the
- <filename>errorlist</filename> package. So you should add an import statement
- like the following to the start of your plugin's source file(s):
- </para>
- <programlisting>import errorlist.*;</programlisting>
- </note>
- <section id="api-deps"><title>Specifying dependencies</title>
- <para>
- 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 <classname>MyPlugin</classname>, the
- corresponding dependencies might look like so:
- </para>
- <programlisting>plugin.MyPlugin.depend.0=jedit 04.02.02.00
- plugin.MyPlugin.depend.2=plugin errorlist.ErrorListPlugin 1.3</programlisting>
- <para>
- 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.
- </para>
- </section>
- <section id="api-register"><title>Creating and registering an error source</title>
- <para>
- Errors are managed by implementations of the
- <classname>errorlist.ErrorSource</classname> abstract class.
- Extending this class is a bit involved and requires writing a lot of
- low-level code; most
- plugins can use the <classname>errorlist.DefaultErrorSource</classname>
- class instead, which provides a very easy-to-use front-end.
- </para>
- <para>
- The constructor for the <classname>DefaultErrorSource</classname> class
- accepts one parameter; 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.
- </para>
- <para>
- 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 consoles are opened
- and closed.
- </para>
- <para>
- To add an error source to the list of registered error sources, you must call
- the static <function>registerErrorSource()</function> method of the
- <classname>errorlist.ErrorSource</classname> class.
- </para>
- <para>
- A corresponding <function>unregisterErrorSource()</function> method must be
- called before your plugin is unloaded to avoid leaking memory.
- </para>
- </section>
- <section id="api-report"><title>Reporting errors</title>
- <para>
- A custom <classname>ErrorSource</classname> implementation would need to
- send the appropriate EditBus message when an error arrives, and then
- provide implementations of various <quote>getter</quote> methods that
- the ErrorList plugin would later call to obtain the error.
- Using <classname>DefaultErrorSource</classname> makes the task much easier.
- In fact, all that is involved is calling a single method on the appropriate
- <classname>DefaultErrorSource</classname> instance:
- </para>
- <funcsynopsis>
- <funcprototype>
- <funcdef>public void <function>addError</function></funcdef>
- <paramdef>DefaultErrorSource.DefaultError <parameter>error</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- The constructor of the <classname>DefaultErrorSource.DefaultError</classname>
- class is as follows:
- </para>
- <funcsynopsis>
- <funcprototype>
- <funcdef>public <function>DefaultError</function></funcdef>
- <paramdef>int <parameter>type</parameter></paramdef>
- <paramdef>String <parameter>path</parameter></paramdef>
- <paramdef>int <parameter>line</parameter></paramdef>
- <paramdef>int <parameter>start</parameter></paramdef>
- <paramdef>int <parameter>end</parameter></paramdef>
- <paramdef>String <parameter>message</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <itemizedlist>
- <listitem><para><varname>type</varname> - this should be either
- <classname>ErrorSource.ERROR</classname> or
- <classname>ErrorSource.WARNING</classname>.</para></listitem>
- <listitem><para><varname>path</varname> - the path name or URL of
- the file containing the error. If this is a relative path, it will
- be qualified relative to the current working directory
- (<literal>user.dir</literal> system property). However, it is best to qualify
- it beforehand, using the <function>MiscUtilities.constructPath()</function>
- method.</para></listitem>
- <listitem><para><varname>line</varname> - 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.</para></listitem>
- <listitem><para><varname>start</varname> - an offset in the line where
- the error begins.</para></listitem>
- <listitem><para><varname>end</varname> - 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.</para></listitem>
- <listitem><para><varname>message</varname> - the error message itself,
- as shown in the error list window and error highlighting tooltips.
- </para></listitem>
- </itemizedlist>
- <para>
- 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 <function>SwingUtilities.invokeLater()</function> tricks required
- when calling non-thread safe methods.
- </para>
- <para>
- Here are two examples of <function>addError()</function> 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:
- </para>
- <programlisting>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"));</programlisting>
- <para>
- Multiple-line messages can be created by calling the following method
- on the <classname>DefaultError</classname> instance before it is added
- to the error source (the last part is important, otherwise the extra
- messages will not be shown):
- </para>
- <funcsynopsis>
- <funcprototype>
- <funcdef>public void <function>addExtraMessage</function></funcdef>
- <paramdef>String <parameter>extra</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- That's basically all there is to it. There is one more method in the
- <classname>DefaultErrorSource</classname> class that needs to be mentioned:
- </para>
- <funcsynopsis>
- <funcprototype>
- <funcdef>public void <function>clear</function></funcdef>
- <void />
- </funcprototype>
- </funcsynopsis>
- <para>
- 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.
- </para>
- <funcsynopsis>
- <funcprototype>
- <funcdef>public void <function>removeFileErrors</function></funcdef>
- <void />
- </funcprototype>
- </funcsynopsis>
- <para>
- For more selective error removal, this method can be used to remove errors
- associated with one file only.
- </para>
- </section>
- <section><title>Performance Considerations</title>
- <para>
- Only create and register an <classname>ErrorSource</classname> instance
- when necessary. Do not do this in your plugin's <function>start()</function>
- method, since that forces the ErrorList to be loaded, etc. The "lazy" fashion is the best:
- Register the error source only after sending the first error.
- </para>
- </section>
- </section>
- <appendix id="changes"><title>Change log</title>
- <itemizedlist>
- <listitem>
- <formalpara><title>Version 1.9</title> <para>requires JDK 1.5, and jEdit 4.3.99.00. </para> </formalpara>
- <itemizedlist>
- <listitem><para> Fixed deadlock condition arising from new EditBus behavior in jEdit 4.4 (Kazutoshi Satoda) </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem>
- <formalpara><title>Version 1.8</title> <para>requires JDK 1.5, and jEdit 4.3pre7. </para> </formalpara>
- <itemizedlist>
- <listitem><para> display error.extraMessages in GutterIcon (Dwayne Bernard - # 1854405) </para></listitem>
- <listitem><para> Remembers state of error/warning buttons (Shlomy Reinstein) </para></listitem>
- <listitem><para> Automatically Show on Errors no longer shows when only hidden warnings pass through (#2907190 - Shlomy Reinstein) </para></listitem>
- <listitem><para> No longer displays ErrorList when adding a zero-length ErrorSource. (#1869137 - Alan Ezust) </para></listitem>
- <listitem><para> Enable multiple errors at different offsets in a same line. (Patch #2011885 - kerik) </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem>
- <formalpara><title>Version 1.7</title> <para>requires JDK 1.5, and jEdit 4.3pre7. </para> </formalpara>
- <itemizedlist>
- <listitem><para> <classname>DefaultErrorSource.DefaultError</classname> has new method: <methodname>setFilePath()</methodname> (for SshConsole). </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem>
- <formalpara><title>Version 1.6</title> <para>requires JDK 1.5, and jEdit 4.3pre7. </para> </formalpara>
- <itemizedlist>
- <listitem><para> New option to hide warnings (patch 1719791 by Shlomy Reinstein) </para></listitem>
- <listitem><para> New options to filter files based on filename globs. (Shlomy Reinstein) </para></listitem>
- <listitem><para> New option to show icons instead of underlines under errors (Shlomy Reinstein, 1653073) </para></listitem>
- <listitem><para> Improved keyboard Handling when ErrorList has focus (patch 1729970 by k_satoda) </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.5</title>
- <para>requires JDK 1.4, and jEdit 4.2 final. </para></formalpara>
- <itemizedlist>
- <listitem><para>Bugfix to avoid displaying duplicate errors (k_satoda). </para></listitem>
- <listitem><para>New option: autoRefocusTextArea:
- When ErrorList gets focus, it now deliberately passes the focus back to the current jEditTextArea. (ezust)
- </para></listitem>
- </itemizedlist></listitem>
- <listitem>
- <formalpara>
- <title>Version 1.4</title>
- <para>requires jEdit 4.2final. </para>
- </formalpara>
- <itemizedlist>
- <listitem><para>Add option to close error list after no errors remain (Gerd Knops).
- </para></listitem>
- <listitem><para>Option "Automatically display on error" no longer causes ErrorList
- to request the focus, so that the cursor stays in the edit pane (Dirk Moebius).
- </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.3.2</title><para>requires
- jEdit 4.2pre8.
- </para></formalpara>
- <itemizedlist>
- <listitem><para>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.</para></listitem>
- <listitem><para>Fix display of selected entires in the error list when using the GTK look and feel.</para></listitem>
- <listitem><para>New icons for errors and warnings.</para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.3.1</title><para>requires
- jEdit 4.2pre2.
- </para></formalpara>
- <itemizedlist>
- <listitem><para><guilabel>Show on error</guilabel> option didn't always work.</para></listitem>
- <listitem><para>Fixed exception when using GTK+ look and feel.</para></listitem>
- <listitem><para>Fixed assorted problems when file paths contained
- symbolic links.</para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.3</title><para>requires
- jEdit 4.2pre2.
- </para></formalpara>
- <itemizedlist>
- <listitem><para>Added optional <quote>error overview</quote> to the right of
- the text area (on by default).
- </para></listitem>
- <listitem><para>Added buttons to the error list window
- for going to the next and previous error and
- file with errors, respectively.
- </para></listitem>
- <listitem><para>Fixed problem with errors appearing twice when
- the <guilabel>Show on error</guilabel> option was on.
- </para></listitem>
- <listitem><para>Fixed problems with soft wrap.
- </para></listitem>
- <listitem><para>Fixed problems with split views.
- </para></listitem>
- <listitem><para>Updated for jEdit 4.2 API changes.
- </para></listitem>
- <listitem><para>Added <function>removeFileErrors()</function> method to
- <classname>DefaultErrorSource</classname> class.
- </para></listitem>
- <listitem><para>Performance improvements.
- </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.2.3</title><para>requires
- jEdit 4.1pre2.
- </para></formalpara>
- <itemizedlist>
- <listitem><para>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.
- </para></listitem>
- <listitem><para>Error tool tips were not shown for some errors.
- </para></listitem>
- <listitem><para>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.
- </para></listitem>
- <listitem><para>Fixed minor issue with error tree root node.
- </para></listitem>
- <listitem><para>Updated code to use a few 4.1 API additions.
- </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.2.2</title><para>requires
- jEdit 4.0pre4.
- </para></formalpara>
- <itemizedlist>
- <listitem><para>Fixed possible <classname>NullPointerException</classname>
- under Java 2 version 1.4.
- </para></listitem>
- <listitem><para>Error highlight didn't work properly when soft wrap was
- enabled.
- </para></listitem>
- <listitem><para>If the <quote>show on error</quote> feature is enabled, the
- error list will now open in the currently focused view, not the most
- recently opened view as before.
- </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.2.1</title><para>requires
- jEdit 4.0pre4.
- </para></formalpara>
- <itemizedlist>
- <listitem><para>Updated to use jEdit 4.0pre4 text area extension API.
- </para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.2</title><para>requires jEdit 4.0pre1.
- </para></formalpara>
- <itemizedlist>
- <listitem><para>Updated for jEdit 4.0 API changes.</para></listitem>
- <listitem><para>EditBus plugin merged with this one.</para></listitem>
- <listitem><para>Changes to error source API; see <xref linkend="api" />
- for details.</para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.1.2</title><para>requires jEdit 3.2pre8
- and the EditBus plugin 1.1.</para></formalpara>
- <itemizedlist>
- <listitem><para>If the error list was open but not visible, the
- <guilabel>Show on error</guilabel> option would do nothing.</para></listitem>
- <listitem><para>If no error sources were registered, all highlights added
- after the error list would not be painted.</para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.1.1</title><para>requires jEdit 3.2pre8
- and the EditBus plugin 1.1.</para></formalpara>
- <itemizedlist>
- <listitem><para>Line numbers in the tree are now increased by one, so that
- they match the textarea line numbers (Dirk Moebius)</para></listitem>
- <listitem><para>The commands "Next/Previous Error" and "Next/Previous File
- With Errors" now ensure that the newly selected error is visible
- (Dirk Moebius)</para></listitem>
- <listitem><para>Supports multiple-line error messages, introduced
- by EditBus 1.1</para></listitem>
- </itemizedlist>
- </listitem>
- <listitem><formalpara><title>Version 1.1</title><para>requires jEdit 3.2pre8
- and the EditBus plugin 1.0.1.</para></formalpara>
- <itemizedlist>
- <listitem><para>Errors are now shown in a tree, not a list</para></listitem>
- <listitem><para>Error highlighting does not highlight leading whitespace
- of lines, leading to better appearance</para></listitem>
- <listitem><para>Minor update for jEdit 3.2 selection API</para></listitem>
- <listitem><para>Documentation generated with DocBook</para></listitem>
- <listitem><para>Error reporting API documentation included</para></listitem>
- </itemizedlist>
- </listitem>
- </itemizedlist>
- </appendix>
- </article>