|
org.netbeans.modules.editor.indent/2 1.28 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.modules.editor.indent.api.Indent
public final class Indent
Reindentation of a single or multiple lines in the document
means fixing of the line's indent only but does not do any other
code beautification.
The following pattern should be used:
indent.lock();
try {
doc.atomicLock();
try {
indent.reindent(...);
} finally {
doc.atomicUnlock();
}
} finally {
indent.unlock();
}
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
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
|
org.netbeans.modules.editor.indent/2 1.28 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||