public abstract class PsiAwareLineWrapPositionStrategy extends java.lang.Object implements LineWrapPositionStrategy
LineWrapPositionStrategy
implementations that want to restrict wrap positions
only for particular elements/tokens (e.g. we may want to avoid line wrap in the middle of xml tag name etc).Modifier and Type | Field and Description |
---|---|
static int |
NO_ELEMENT_WRAP |
static int |
NO_LINE_WRAP |
Constructor and Description |
---|
PsiAwareLineWrapPositionStrategy(boolean nonVirtualOnly,
IElementType... enabledTypes)
Creates new
PsiAwareLineWrapPositionStrategy object. |
Modifier and Type | Method and Description |
---|---|
int |
calculateWrapPosition(Document document,
Project project,
int startOffset,
int endOffset,
int maxPreferredOffset,
boolean allowToBeyondMaxPreferredOffset,
boolean isSoftWrap)
Allows to calculate the most appropriate position to wrap target line.
|
protected abstract int |
doCalculateWrapPosition(Document document,
Project project,
PsiElement element,
int startOffset,
int endOffset,
int maxPreferredOffset,
boolean isSoftWrap)
Serves for the same purposes as
calculateWrapPosition(Document, Project, int, int, int, boolean, boolean) but ensures
that given offsets target enabled token/element types . |
public static final int NO_ELEMENT_WRAP
public static final int NO_LINE_WRAP
public PsiAwareLineWrapPositionStrategy(boolean nonVirtualOnly, IElementType... enabledTypes)
PsiAwareLineWrapPositionStrategy
object.nonVirtualOnly
- defines if current PSI-aware logic should be exploited only for 'real wrap' position requestsenabledTypes
- target element/token types where line wrapping is allowedpublic int calculateWrapPosition(Document document, Project project, int startOffset, int endOffset, int maxPreferredOffset, boolean allowToBeyondMaxPreferredOffset, boolean isSoftWrap)
LineWrapPositionStrategy
calculateWrapPosition
in interface LineWrapPositionStrategy
document
- target document which text is being processedproject
- target projectstartOffset
- start offset to use with the given text holder (exclusive)endOffset
- end offset to use with the given text holder (exclusive)maxPreferredOffset
- this method is expected to do its best to return offset that belongs to
(startOffset; maxPreferredOffset]
interval. However, it's allowed
to return value from (maxPreferredOffset; endOffset)
interval
unless 'allowToBeyondMaxPreferredOffset'
if 'false'
allowToBeyondMaxPreferredOffset
- indicates if it's allowed to return value from
(maxPreferredOffset; endOffset]
interval in case of inability to
find appropriate offset from (startOffset; maxPreferredOffset]
intervalisSoftWrap
- identifies if current request is for isSoftWrap wrap position(startOffset; endOffset)
interval where
target line should be wrapped OR -1
if no wrapping should be performedprotected abstract int doCalculateWrapPosition(Document document, Project project, PsiElement element, int startOffset, int endOffset, int maxPreferredOffset, boolean isSoftWrap)
calculateWrapPosition(Document, Project, int, int, int, boolean, boolean)
but ensures
that given offsets target enabled token/element types
.document
- target document which text is being processedproject
- target projectstartOffset
- start offset to use with the given text holder (inclusive)endOffset
- end offset to use with the given text holder (exclusive)maxPreferredOffset
- this method is expected to do its best to return offset that belongs to
(startOffset; maxPreferredOffset]
interval. However, it's allowed
to return value from (maxPreferredOffset; endOffset]
interval
unless 'allowToBeyondMaxPreferredOffset'
if 'false'
isSoftWrap
- identifies if current request is for virtual wrap (soft wrap) position(startOffset; endOffset]
interval where
target line should be wrapped, NO_ELEMENT_WRAP
if no wrapping
should be performed within the element OR NO_LINE_WRAP
if the
entire line wrapping is not allowed.