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)
FormattingDocumentModel
getLineNumber
in interface FormattingDocumentModel
offset
- the offset for which the line number is requested.public int getLineStartOffset(int line)
FormattingDocumentModel
getLineStartOffset
in interface FormattingDocumentModel
line
- the line number for which the offset is requested.public java.lang.CharSequence getText(TextRange textRange)
FormattingDocumentModel
getText
in interface FormattingDocumentModel
textRange
- the text range for which the text is requested.public int getTextLength()
FormattingDocumentModel
getTextLength
in interface FormattingDocumentModel
public Document getDocument()
getDocument
in interface FormattingDocumentModel
public PsiFile getFile()
public boolean containsWhiteSpaceSymbolsOnly(int startOffset, int endOffset)
FormattingDocumentModel
[startOffset; endOffset)
region are treated as white spaces by formatter.containsWhiteSpaceSymbolsOnly
in interface FormattingDocumentModel
startOffset
- 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 FormattingDocumentModel
whiteSpaceText
- 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