org.eclipse.xtext.ui.editor.autoedit
Class MultiLineTerminalsEditStrategy

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategy
      extended by org.eclipse.xtext.ui.editor.autoedit.AbstractTerminalsEditStrategy
          extended by org.eclipse.xtext.ui.editor.autoedit.MultiLineTerminalsEditStrategy
All Implemented Interfaces:
java.util.EventListener, org.eclipse.jface.text.IAutoEditStrategy, org.eclipse.swt.custom.VerifyKeyListener, org.eclipse.swt.internal.SWTEventListener
Direct Known Subclasses:
AutoEditStrategyProvider.MultiLineTerminalsEditStrategyInRichString

public class MultiLineTerminalsEditStrategy
extends AbstractTerminalsEditStrategy

This strategy applies auto edits when typing a newline character within a block (denoted by a start and end terminal).

Author:
Sven Efftinge - Initial contribution and API

Nested Class Summary
static class MultiLineTerminalsEditStrategy.Factory
           
 
Field Summary
 
Fields inherited from class org.eclipse.xtext.ui.editor.autoedit.AbstractTerminalsEditStrategy
util
 
Fields inherited from class org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategy
debug, DEBUG
 
Constructor Summary
MultiLineTerminalsEditStrategy(java.lang.String leftTerminal, java.lang.String indentationString, java.lang.String rightTerminal)
           
 
Method Summary
protected  boolean atEndOfLineInput(org.eclipse.jface.text.IDocument document, int offset)
          determines whether the given offset is at the end of the input in the line.
protected  CommandInfo handleCursorBetweenStartAndStopLine(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command, org.eclipse.jface.text.IRegion startTerminal, org.eclipse.jface.text.IRegion stopTerminal)
          adds a new line with required indentation after the cursor.
protected  CommandInfo handleCursorInFirstLine(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command, org.eclipse.jface.text.IRegion startTerminal, org.eclipse.jface.text.IRegion stopTerminal)
          Expects the cursor to be in the same line as the start terminal puts any text between start terminal and cursor into a separate newline before the cursor.
protected  CommandInfo handleCursorInStopLine(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command, org.eclipse.jface.text.IRegion startTerminal, org.eclipse.jface.text.IRegion stopTerminal)
          delegates to handleCursorBetweenStartAndStopLine(IDocument, DocumentCommand, IRegion, IRegion).
protected  CommandInfo handleNoStopTerminal(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command, org.eclipse.jface.text.IRegion startTerminal, org.eclipse.jface.text.IRegion stopTerminal)
          Expects the cursor not to be in the first line of the block inserts a closing terminal if not existent.
protected  void internalCustomizeDocumentCommand(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command)
           
 
Methods inherited from class org.eclipse.xtext.ui.editor.autoedit.AbstractTerminalsEditStrategy
allowsEqualTerminals, findStartTerminal, findStopTerminal, getDocumentUtil, getLeftTerminal, getRightTerminal, setDocumentUtil
 
Methods inherited from class org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategy
count, customizeDocumentCommand, getDocumentContent, handleBadLocationException, isIdentifierPart, verifyKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiLineTerminalsEditStrategy

public MultiLineTerminalsEditStrategy(java.lang.String leftTerminal,
                                      java.lang.String indentationString,
                                      java.lang.String rightTerminal)
Method Detail

internalCustomizeDocumentCommand

protected void internalCustomizeDocumentCommand(org.eclipse.jface.text.IDocument document,
                                                org.eclipse.jface.text.DocumentCommand command)
                                         throws org.eclipse.jface.text.BadLocationException
Specified by:
internalCustomizeDocumentCommand in class AbstractEditStrategy
Throws:
org.eclipse.jface.text.BadLocationException

handleCursorInFirstLine

protected CommandInfo handleCursorInFirstLine(org.eclipse.jface.text.IDocument document,
                                              org.eclipse.jface.text.DocumentCommand command,
                                              org.eclipse.jface.text.IRegion startTerminal,
                                              org.eclipse.jface.text.IRegion stopTerminal)
                                       throws org.eclipse.jface.text.BadLocationException
Expects the cursor to be in the same line as the start terminal puts any text between start terminal and cursor into a separate newline before the cursor. puts any text between cursor and end terminal into a separate newline after the cursor. puts the closing terminal into a separate line at the end. adds a closing terminal if not existent.

Throws:
org.eclipse.jface.text.BadLocationException

handleNoStopTerminal

protected CommandInfo handleNoStopTerminal(org.eclipse.jface.text.IDocument document,
                                           org.eclipse.jface.text.DocumentCommand command,
                                           org.eclipse.jface.text.IRegion startTerminal,
                                           org.eclipse.jface.text.IRegion stopTerminal)
                                    throws org.eclipse.jface.text.BadLocationException
Expects the cursor not to be in the first line of the block inserts a closing terminal if not existent.

Throws:
org.eclipse.jface.text.BadLocationException

handleCursorBetweenStartAndStopLine

protected CommandInfo handleCursorBetweenStartAndStopLine(org.eclipse.jface.text.IDocument document,
                                                          org.eclipse.jface.text.DocumentCommand command,
                                                          org.eclipse.jface.text.IRegion startTerminal,
                                                          org.eclipse.jface.text.IRegion stopTerminal)
                                                   throws org.eclipse.jface.text.BadLocationException
adds a new line with required indentation after the cursor.

Throws:
org.eclipse.jface.text.BadLocationException

handleCursorInStopLine

protected CommandInfo handleCursorInStopLine(org.eclipse.jface.text.IDocument document,
                                             org.eclipse.jface.text.DocumentCommand command,
                                             org.eclipse.jface.text.IRegion startTerminal,
                                             org.eclipse.jface.text.IRegion stopTerminal)
                                      throws org.eclipse.jface.text.BadLocationException
delegates to handleCursorBetweenStartAndStopLine(IDocument, DocumentCommand, IRegion, IRegion).

Throws:
org.eclipse.jface.text.BadLocationException

atEndOfLineInput

protected boolean atEndOfLineInput(org.eclipse.jface.text.IDocument document,
                                   int offset)
                            throws org.eclipse.jface.text.BadLocationException
determines whether the given offset is at the end of the input in the line. trailing whitespace is disregarded.

Throws:
org.eclipse.jface.text.BadLocationException