public final class Indent extends Object
indent.lock(); try { doc.atomicLock(); try { indent.reindent(...); } finally { doc.atomicUnlock(); } } finally { indent.unlock(); }
Modifier and Type | Method and Description |
---|---|
static Indent |
get(Document doc)
Get the indentation for the given document.
|
int |
indentNewLine(int offset)
Creates new line at
offset and reindents it. |
void |
lock()
Clients should call this method before acquiring of document's write lock.
|
void |
reindent(int offset)
Correct indentation on a single line determined by the given offset.
|
void |
reindent(int startOffset,
int endOffset)
Correct indentation of all lines in the given offset range.
|
void |
unlock()
Clients should call this method after releasing of document's write lock.
|
public static Indent get(Document doc)
doc
- non-null document.public void lock()
indent.lock(); try { doc.atomicLock(); try { indent.reindent(...); } finally { doc.atomicUnlock(); } } finally { indent.unlock(); }
public void unlock()
indent.lock(); try { doc.atomicLock(); try { indent.reindent(...); } finally { doc.atomicUnlock(); } } finally { indent.unlock(); }
public void reindent(int offset) throws BadLocationException
offset
- >=0 any offset on the line to be reformatted.BadLocationException
- in case the indenter attempted to insert/remove
at an invalid offset or e.g. into a guarded section.public void reindent(int startOffset, int endOffset) throws BadLocationException
startOffset
- >=0 any offset on a first line to be reformatted.endOffset
- >=startOffset any offset (including end offset)
on a last line to be reformatted.BadLocationException
- in case the indenter attempted to insert/remove
at an invalid offset or e.g. into a guarded section.public int indentNewLine(int offset) throws BadLocationException
offset
and reindents it.
This method will insert a line break (ie EOL character) at the specified offset and then reindent the newly created line. The method will return the offset of the indented beginning of the new line. That is the offset where the new text should appear when typing in the document.
offset
- The document offset where the new line will be created.BadLocationException