public class FormattingDocumentModelImpl extends java.lang.Object implements FormattingDocumentModel
| Constructor and Description |
|---|
FormattingDocumentModelImpl(Document document,
PsiFile file) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.CharSequence |
adjustWhiteSpaceIfNecessary(java.lang.CharSequence whiteSpaceText,
int startOffset,
int endOffset,
ASTNode nodeAfter,
boolean changedViaPsi)
There is a possible case that white space to apply should be additionally adjusted because of formatter processing.
|
static boolean |
canUseDocumentModel(Document document,
PsiFile file) |
boolean |
containsWhiteSpaceSymbolsOnly(int startOffset,
int endOffset)
Allows to answer if all document symbols from
[startOffset; endOffset) region are treated as white spaces by formatter. |
static FormattingDocumentModelImpl |
createOn(PsiFile file) |
Document |
getDocument() |
static Document |
getDocumentToBeUsedFor(PsiFile file) |
PsiFile |
getFile() |
int |
getLineNumber(int offset)
Returns the line number corresponding to the specified offset in the document.
|
int |
getLineStartOffset(int line)
Returns the offset corresponding to the start of the specified line in the document.
|
java.lang.CharSequence |
getText(TextRange textRange)
Returns the text contained in the specified text range of the document.
|
int |
getTextLength()
Returns the length of the entire document text.
|
public static FormattingDocumentModelImpl createOn(PsiFile file)
public int getLineNumber(int offset)
FormattingDocumentModelgetLineNumber in interface FormattingDocumentModeloffset - the offset for which the line number is requested.public int getLineStartOffset(int line)
FormattingDocumentModelgetLineStartOffset in interface FormattingDocumentModelline - the line number for which the offset is requested.public java.lang.CharSequence getText(TextRange textRange)
FormattingDocumentModelgetText in interface FormattingDocumentModeltextRange - the text range for which the text is requested.public int getTextLength()
FormattingDocumentModelgetTextLength in interface FormattingDocumentModelpublic Document getDocument()
getDocument in interface FormattingDocumentModelpublic PsiFile getFile()
public boolean containsWhiteSpaceSymbolsOnly(int startOffset,
int endOffset)
FormattingDocumentModel[startOffset; endOffset) region are treated as white spaces by formatter.containsWhiteSpaceSymbolsOnly in interface FormattingDocumentModelstartOffset - target start document offset (inclusive)endOffset - target end document offset (exclusive)true if all document symbols from [startOffset; endOffset) region are treated
as white spaces by formatter; false otherwisepublic java.lang.CharSequence adjustWhiteSpaceIfNecessary(java.lang.CharSequence whiteSpaceText,
int startOffset,
int endOffset,
ASTNode nodeAfter,
boolean changedViaPsi)
FormattingDocumentModel'\' symbol at multi-line expression.
Current method adjusts given white space text if necessary.adjustWhiteSpaceIfNecessary in interface FormattingDocumentModelwhiteSpaceText - white space text to use by defaultstartOffset - start offset of the document text that is intended to be replaced by the given white space text (inclusive)endOffset - end offset of the document text that is intended to be replaced by the given white space text (exclusive)nodeAfter - the AST node following the block, if knownchangedViaPsi - flag that identifies whether formatter introduces changes via PSI tree or directly via the document[startOffset; endOffset) region