public class PsiBasedFormattingModel extends java.lang.Object implements FormattingModelEx
Modifier and Type | Field and Description |
---|---|
protected boolean |
myCanModifyAllWhiteSpaces |
Constructor and Description |
---|
PsiBasedFormattingModel(PsiFile file,
Block rootBlock,
FormattingDocumentModelImpl documentModel) |
Modifier and Type | Method and Description |
---|---|
void |
canModifyAllWhiteSpaces() |
void |
commitChanges()
Commits the changes made by the formatter to the document.
|
protected ASTNode |
findElementAt(int offset) |
FormattingDocumentModel |
getDocumentModel()
Returns the formatting document model, which allows the formatter to access information about
the document containing the text to be formatted.
|
Block |
getRootBlock()
Returns the root block of the formatting model.
|
TextRange |
replaceWhiteSpace(TextRange textRange,
ASTNode nodeAfter,
java.lang.String whiteSpace)
Replaces the contents of the specified text range in the document with the specified text
string consisting of whitespace characters.
|
TextRange |
replaceWhiteSpace(TextRange textRange,
java.lang.String whiteSpace)
Replaces the contents of the specified text range in the document with the specified text
string consisting of whitespace characters.
|
protected java.lang.String |
replaceWithPsiInLeaf(TextRange textRange,
java.lang.String whiteSpace,
ASTNode leafElement) |
TextRange |
shiftIndentInsideRange(ASTNode node,
TextRange textRange,
int shift)
Indents every line except for the first in the specified text range representing a multiline block
by the specified amount.
|
public PsiBasedFormattingModel(PsiFile file, Block rootBlock, FormattingDocumentModelImpl documentModel)
public TextRange replaceWhiteSpace(TextRange textRange, java.lang.String whiteSpace)
FormattingModel
replaceWhiteSpace
in interface FormattingModel
textRange
- the text range to replace with whitespace.whiteSpace
- the whitespace to replace with.public TextRange replaceWhiteSpace(TextRange textRange, ASTNode nodeAfter, java.lang.String whiteSpace)
FormattingModelEx
replaceWhiteSpace
in interface FormattingModelEx
textRange
- the text range to replace with whitespace.nodeAfter
- the AST node following the whitespace, if knownwhiteSpace
- the whitespace to replace with.public TextRange shiftIndentInsideRange(ASTNode node, TextRange textRange, int shift)
FormattingModel
shiftIndentInsideRange
in interface FormattingModel
node
- the owner of the text range, if defined.textRange
- the text range to indent.shift
- the amount by which every line should be indented.public void commitChanges()
FormattingModel
commitChanges
in interface FormattingModel
protected java.lang.String replaceWithPsiInLeaf(TextRange textRange, java.lang.String whiteSpace, ASTNode leafElement)
protected ASTNode findElementAt(int offset)
public FormattingDocumentModel getDocumentModel()
FormattingModel
getDocumentModel
in interface FormattingModel
public Block getRootBlock()
FormattingModel
FormattingModelBuilder.createModel(com.intellij.psi.PsiElement, com.intellij.psi.codeStyle.CodeStyleSettings)
.getRootBlock
in interface FormattingModel
public void canModifyAllWhiteSpaces()