/plugins/ErrorList/tags/release-1-2-2/users-guide.xml
# · XML · 473 lines · 372 code · 97 blank · 4 comment · 0 complexity · dca87e30a220d7f9e3f5f62606459596 MD5 · raw file
- <?xml version="1.0"?>
- <!-- ErrorList user's guide -->
- <!-- (C) 2001 Slava Pestov -->
- <!-- jEdit buffer-local properties: -->
- <!-- :tabSize=1:indentSize=1:noTabs=true: -->
- <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
- <book>
- <bookinfo><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>
- </bookinfo>
- <chapter 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, HTML and XML.
- If you would like to use it from your plugin, see <xref linkend="api" />.
- </para>
- </chapter>
- <chapter 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. This window is floating by default, but it can be made to
- dock into the view in the <guibutton>Docking</guibutton> pane of the
- <guimenuitem>Global Options</guimenuitem> dialog box.
- </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 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>
- </chapter>
- <chapter id="highlight"><title>Error highlighting</title>
- <para>
- The ErrorList plugin also 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>Global Options</guimenuitem> dialog box. The colors of
- the underlines can also be changed in that same option pane.
- </para>
- </chapter>
- <chapter 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>
- </chapter>
- <chapter 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 and EditBus plugins.
- The error reporting API is spread between these two plugins for historical
- reasons.</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 classes of the error reporting API, and the ErrorList plugin itself handle
- the rest automatically; displaying errors in a list, error highlighting, and
- so on.
- </para>
- <sect1 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.00.01.00
- plugin.MyPlugin.depend.2=plugin ErrorListPlugin 1.2</programlisting>
- <para>
- Note that the current version of the ErrorList plugin requires jEdit 4.0pre1
- 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 chapter are guaranteed to work with the above version,
- so in most cases you shouldn't worry about it.
- </para>
- </sect1>
- <sect1 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>
- Typically, error sources will be registered in your plugin's
- <function>start()</function> method, but that does not have to be the case.
- 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 also
- exists, for advanced uses of the API, like the Console plugin mentioned
- above.
- </para>
- <para>
- Putting all this together, a simple plugin core class
- <function>start()</function> method
- might look as follows:
- </para>
- <programlisting>public void start()
- {
- errorSource = new DefaultErrorSource("MyPlugin");
- ErrorSource.registerErrorSource(errorSource);
- // any other initialization your plugin
- // needs to perform
- }</programlisting>
- <para>
- Note that the newly-created error source is assigned to an instance variable.
- This allows the error source instance to be called upon later, when
- compiler errors are actually generated.
- </para>
- </sect1>
- <sect1 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>
- <para>
- This method reveals a limitation of the
- <classname>DefaultErrorSource</classname>
- class; errors cannot be removed selectively. The main reason this hasn't
- been implemented is lack of demand. If your plugin needs a means of only
- removing a subset of errors in an error source, feel free to modify the
- source for this class and contribute the changes back to the jEdit project.
- </para>
- </sect1>
- </chapter>
- <appendix id="changes"><title>Change log</title>
- <itemizedlist>
- <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>
- </book>