public final class Context extends Object
Context.isIndent()
allows to check whether the actual processing
is indentation or reformatting.Modifier and Type | Class and Description |
---|---|
static class |
Context.Region
Description of the region where the indentation/reformatting should operate.
|
Modifier and Type | Method and Description |
---|---|
int |
caretOffset()
Return offset of the caret passed to the indentation
infrastructure.
|
Document |
document()
Document for which the reformatting or indenting is being done.
|
int |
endOffset()
Starting offset of the area to be reformatted or reindented.
|
Lookup |
getLookup()
Returns lookup which is merge of lookups provided by individual
formatters involved in formatting given document.
|
List<Context.Region> |
indentRegions()
Get list of regions for the given mime-path
where the indent or reformat task should operate.
|
boolean |
isIndent() |
int |
lineIndent(int lineStartOffset)
Determine indent on the given line as a number of spaces.
|
int |
lineStartOffset(int offset)
Determine start of the line for the given offset.
|
String |
mimePath()
Get mimePath of this context as string.
|
void |
modifyIndent(int lineStartOffset,
int newIndent)
Modify indent of the line at the offset passed as the parameter.
|
void |
modifyIndent(int lineStartOffset,
int oldIndentCharCount,
String newIndent)
Modify indent of the line at the offset passed as the parameter, by stripping the given
number of input characters and inserting the given indent.
|
void |
setCaretOffset(int offset)
Override the offset at which the caret should be placed after the indentation
is finished.
|
int |
startOffset()
Starting offset of the area to be reformatted or reindented.
|
public Lookup getLookup()
IndentTask.reindent()
or ReformatTask.reformat()
.public Document document()
public String mimePath()
public int startOffset()
public int endOffset()
public int lineStartOffset(int offset) throws BadLocationException
offset
- offset in a document being formatted.BadLocationException
- if the given offset is not within
corresponding document's bounds.public int lineIndent(int lineStartOffset) throws BadLocationException
lineStartOffset
- start offset of a line where the indent is being determined.BadLocationException
- if the given lineStartOffset is not within
corresponding document's bounds.public void modifyIndent(int lineStartOffset, int newIndent) throws BadLocationException
lineStartOffset
- start offset of a line where the indent is being modified.newIndent
- new indent as a number of spaces. The method will possibly use tabs
according to the indentation settings for the given document.BadLocationException
- if the given lineStartOffset is not within
corresponding document's bounds.public void modifyIndent(int lineStartOffset, int oldIndentCharCount, String newIndent) throws BadLocationException
lineStartOffset
- start offset of a line where the indent is being modified.oldIndentCharCount
- number of characters to remove.newIndent
- new indent.BadLocationException
- if the given lineStartOffset is not within
corresponding document's bounds.public int caretOffset()
Context.setCaretOffset(int)
.public void setCaretOffset(int offset) throws BadLocationException
offset
- new offset where the caret should be placed.BadLocationException
- if the given offset is outside
of underlying document bounds.Context.caretOffset()
public List<Context.Region> indentRegions()
public boolean isIndent()