sidekick
Class SideKickParser

java.lang.Object
  extended by sidekick.SideKickParser
Direct Known Subclasses:
SourceParser

public abstract class SideKickParser
extends java.lang.Object

An abstract base class for plugin-provided parser implementations.

Plugins can provide SideKick parsers by defining entries in their services.xml files like so:

<SERVICE CLASS="sidekick.SideKickParser" NAME="name">
    new MyParser();
</SERVICE>
See org.gjt.sp.jedit.ServiceManager for details.

Note that each SideKickParser subclass has a name which is used to key a property sidekick.parser.name.label.

To associate a parser with some edit modes, define properties like this:

mode.scheme.sidekick.parser=lisp
mode.lisp.sidekick.parser=lisp

Version:
$Id: SideKickParser.java 9878 2007-06-29 03:51:20Z ezust $
Author:
Slava Pestov

Field Summary
protected  java.lang.String name
           
static java.lang.String SERVICE
           
 
Constructor Summary
SideKickParser(java.lang.String serviceName)
          The parser constructor.
 
Method Summary
 void activate(org.gjt.sp.jedit.EditPane editPane)
          This method is called when a buffer using this parser is selected in the specified view.
 void activate(org.gjt.sp.jedit.View view)
          Deprecated. Use the form taking an EditPane instead.
 boolean canCompleteAnywhere()
          Returns if completion popups should be shown after any period of inactivity.
 boolean canHandleBackspace()
           Returns true if the parser can handle the backspace key being typed when the completion popup is open, else false if not.
 SideKickCompletion complete(org.gjt.sp.jedit.EditPane editPane, int caret)
          Returns completions suitable for insertion at the specified position.
 void deactivate(org.gjt.sp.jedit.EditPane editPane)
          This method is called when a buffer using this parser is no longer selected in the specified view.
 void deactivate(org.gjt.sp.jedit.View view)
          Deprecated. Use the form taking an EditPane instead.
 java.lang.String getInstantCompletionTriggers()
          Returns a list of characters which trigger completion immediately.
 java.lang.String getName()
          Returns the parser's name.
 javax.swing.JPanel getPanel()
          Returns a parser-specific panel that will be shown in the SideKick dockable window just below the SideKick toolbar.
 java.lang.String getParseTriggers()
          Returns a list of characters which trigger a buffer re-parse.
abstract  SideKickParsedData parse(org.gjt.sp.jedit.Buffer buffer, errorlist.DefaultErrorSource errorSource)
          Parses the given text and returns a tree model.
 void stop()
          Stops the parse request currently in progress.
 boolean supportsCompletion()
          Returns if the parser supports code completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE

public static final java.lang.String SERVICE
See Also:
Constant Field Values

name

protected java.lang.String name
Constructor Detail

SideKickParser

public SideKickParser(java.lang.String serviceName)
The parser constructor.

Method Detail

getName

public final java.lang.String getName()
Returns the parser's name.


stop

public void stop()
Stops the parse request currently in progress. It is up to the parser to implement this.

Since:
SideKick 0.3

activate

public void activate(org.gjt.sp.jedit.View view)
Deprecated. Use the form taking an EditPane instead.

This method is called when a buffer using this parser is selected in the specified view.

Parameters:
view - The view
Since:
SideKick 0.2

deactivate

public void deactivate(org.gjt.sp.jedit.View view)
Deprecated. Use the form taking an EditPane instead.

This method is called when a buffer using this parser is no longer selected in the specified view.

Parameters:
view - The view
Since:
SideKick 0.2

activate

public void activate(org.gjt.sp.jedit.EditPane editPane)
This method is called when a buffer using this parser is selected in the specified view.

Parameters:
editPane - The edit pane
Since:
SideKick 0.3.1

deactivate

public void deactivate(org.gjt.sp.jedit.EditPane editPane)
This method is called when a buffer using this parser is no longer selected in the specified view.

Parameters:
editPane - The edit pane
Since:
SideKick 0.3.1

parse

public abstract SideKickParsedData parse(org.gjt.sp.jedit.Buffer buffer,
                                         errorlist.DefaultErrorSource errorSource)
Parses the given text and returns a tree model.

Parameters:
buffer - The buffer to parse.
errorSource - An error source to add errors to.
Returns:
A new instance of the SideKickParsedData class.

supportsCompletion

public boolean supportsCompletion()
Returns if the parser supports code completion. Returns false by default.


canHandleBackspace

public boolean canHandleBackspace()

Returns true if the parser can handle the backspace key being typed when the completion popup is open, else false if not.

If false, the completion popup is closed when backspace is typed.

If true, the SideKickCompletion.handleKeystroke(int, char) method must be overidden to handle receiving the backspace character, '\b', as a value for the keyChar parameter.

Returns false by default.

Since:
SideKick 0.3.4

canCompleteAnywhere

public boolean canCompleteAnywhere()
Returns if completion popups should be shown after any period of inactivity. Otherwise, they are only shown if explicitly requested by the user. Returns true by default.


getInstantCompletionTriggers

public java.lang.String getInstantCompletionTriggers()
Returns a list of characters which trigger completion immediately. Returns null by default.


getParseTriggers

public java.lang.String getParseTriggers()
Returns a list of characters which trigger a buffer re-parse. Returns null by default.

Since:
SideKick 0.3

complete

public SideKickCompletion complete(org.gjt.sp.jedit.EditPane editPane,
                                   int caret)
Returns completions suitable for insertion at the specified position. Returns null by default.

Parameters:
editPane - The edit pane involved.
caret - The caret position.

getPanel

public javax.swing.JPanel getPanel()
Returns a parser-specific panel that will be shown in the SideKick dockable window just below the SideKick toolbar. This panel is meant to be a toolbar, but can be another UI element if needed. Returns null by default.

Since:
SideKick 0.7.4