org.eclipse.mofscript.editor
Class MofScriptAutoIndentStrategy

java.lang.Object
  extended by org.eclipse.mofscript.editor.MofScriptAutoIndentStrategy
All Implemented Interfaces:
org.eclipse.jface.text.IAutoEditStrategy

public class MofScriptAutoIndentStrategy
extends java.lang.Object
implements org.eclipse.jface.text.IAutoEditStrategy

Auto indent strategy sensitive to brackets.

Author:
jol

Constructor Summary
MofScriptAutoIndentStrategy(MofScriptConfiguration configuration)
           
 
Method Summary
 void customizeDocumentCommand(org.eclipse.jface.text.IDocument d, org.eclipse.jface.text.DocumentCommand c)
          Looks for bracket or * inserts and triggers smart inserts
protected  int findEndOfWhiteSpace(org.eclipse.jface.text.IDocument document, int offset, int end)
          Returns the first offset greater than offset and smaller than end whose character is not a space or tab character.
protected  int findMatchingOpenBracket(org.eclipse.jface.text.IDocument document, int line, int end, int closingBracketIncrease, int bracketType)
          Returns the line number of the next bracket after end.
protected  java.lang.String getIndentOfLine(org.eclipse.jface.text.IDocument document, int line)
          Returns the String at line with the leading whitespace removed.
protected  void smartIndentAfterNewLine(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command)
          Set the indent of a new line based on the command provided in the supplied document.
protected  void smartInsertAfterBracket(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command, int bracketType)
          Set the indent of a bracket based on the command provided in the supplied document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MofScriptAutoIndentStrategy

public MofScriptAutoIndentStrategy(MofScriptConfiguration configuration)
Method Detail

customizeDocumentCommand

public void customizeDocumentCommand(org.eclipse.jface.text.IDocument d,
                                     org.eclipse.jface.text.DocumentCommand c)
Looks for bracket or * inserts and triggers smart inserts

Specified by:
customizeDocumentCommand in interface org.eclipse.jface.text.IAutoEditStrategy
Parameters:
d -
c -

findMatchingOpenBracket

protected int findMatchingOpenBracket(org.eclipse.jface.text.IDocument document,
                                      int line,
                                      int end,
                                      int closingBracketIncrease,
                                      int bracketType)
                               throws org.eclipse.jface.text.BadLocationException
Returns the line number of the next bracket after end.

Parameters:
document - - the document being parsed
line - - the line to start searching back from
end - - the end position to search back from
closingBracketIncrease - - the number of brackets to skip
Throws:
org.eclipse.jface.text.BadLocationException

getIndentOfLine

protected java.lang.String getIndentOfLine(org.eclipse.jface.text.IDocument document,
                                           int line)
                                    throws org.eclipse.jface.text.BadLocationException
Returns the String at line with the leading whitespace removed.

Parameters:
document - - the document being parsed
line - - the line being searched
Throws:
org.eclipse.jface.text.BadLocationException

smartIndentAfterNewLine

protected void smartIndentAfterNewLine(org.eclipse.jface.text.IDocument document,
                                       org.eclipse.jface.text.DocumentCommand command)
Set the indent of a new line based on the command provided in the supplied document.

Parameters:
document - - the document being parsed
command - - the command being performed

smartInsertAfterBracket

protected void smartInsertAfterBracket(org.eclipse.jface.text.IDocument document,
                                       org.eclipse.jface.text.DocumentCommand command,
                                       int bracketType)
Set the indent of a bracket based on the command provided in the supplied document.

Parameters:
document - - the document being parsed
command - - the command being performed

findEndOfWhiteSpace

protected int findEndOfWhiteSpace(org.eclipse.jface.text.IDocument document,
                                  int offset,
                                  int end)
                           throws org.eclipse.jface.text.BadLocationException
Returns the first offset greater than offset and smaller than end whose character is not a space or tab character. If no such offset is found, end is returned.

Parameters:
document - the document to search in
offset - the offset at which searching start
end - the offset at which searching stops
Returns:
the offset in the specified range whose character is not a space or tab
Throws:
org.eclipse.jface.text.BadLocationException - if position is an invalid range in the given document