## org.eclipse.datatools.sqltools.sqleditor.internal.indent
Class SQLIndenter

    java.lang.Object
      org.eclipse.datatools.sqltools.sqleditor.internal.indent.SQLIndenter

    public class SQLIndenter

extends java.lang.Object

Uses the `com.sybase.stf.dmp.ui.text.SQLHeuristicScanner`to get the indentation level for a certain position in a document.

An instance holds some internal position in the document and is therefore not threadsafe.

Since:
  3.0

Constructor Summary
`SQLIndenter(org.eclipse.jface.text.IDocument document, SQLHeuristicScanner scanner)` Creates a new instance.

Method Summary
`java.lang.StringBuffer` `computeIndentation(int offset)` Computes the indentation at `offset`.
`java.lang.StringBuffer` `computeIndentation(int offset, boolean assumeOpening)` Computes the indentation at `offset`.
`int` `findReferencePosition(int offset)` Returns the reference position regarding to indentation for `offset`, or `NOT_FOUND`.
`java.lang.StringBuffer` `getReferenceIndentation(int offset)` Computes the indentation at the reference point of `position`.
`void` `nextToken(int start)` Reads the next token in backward direction of `start` from the heuristic scanner and sets the fields `fToken, fPreviousPosition` and `fPosition` accordingly.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SQLIndenter

    public SQLIndenter(org.eclipse.jface.text.IDocument document,
                       SQLHeuristicScanner scanner)

  Creates a new instance.

  Parameters:
    `document` - the document to scan
    `scanner` - the `SQLHeuristicScanner`to be used for scanning the document. It must be installed on the same `IDocument`.

Method Detail

### getReferenceIndentation

    public java.lang.StringBuffer getReferenceIndentation(int offset)

  Computes the indentation at the reference point of `position`.

  Parameters:
    `offset` - the offset in the document
  Returns:
    a String which reflects the indentation at the line in which the reference position to `offset` resides, or `null` if it cannot be determined

### computeIndentation

    public java.lang.StringBuffer computeIndentation(int offset)

  Computes the indentation at `offset`.

  Parameters:
    `offset` - the offset in the document
  Returns:
    a String which reflects the correct indentation for the line in which offset resides, or `null` if it cannot be determined

### computeIndentation

    public java.lang.StringBuffer computeIndentation(int offset,
                                                     boolean assumeOpening)

  Computes the indentation at `offset`.

  Parameters:
    `offset` - the offset in the document
    `assumeOpening` - `true` if an opening statement should be assumed
  Returns:
    a String which reflects the correct indentation for the line in which offset resides, or `null` if it cannot be determined

### findReferencePosition

    public int findReferencePosition(int offset)

  Returns the reference position regarding to indentation for `offset`, or `NOT_FOUND`. This method calls `findReferencePosition(offset, nextChar)`where `nextChar` is the next character after `offset`.

  Parameters:
    `offset` - the offset for which the reference is computed
  Returns:
    the reference statement relative to which `offset` should be indented, or `SQLHeuristicScanner.NOT_FOUND`

### nextToken

    public void nextToken(int start)

  Reads the next token in backward direction of `start` from the heuristic scanner and sets the fields `fToken, fPreviousPosition` and `fPosition` accordingly.