public class CodeEditUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addChild(ASTNode parent,
ASTNode child,
ASTNode anchorBefore) |
static ASTNode |
addChildren(ASTNode parent,
ASTNode first,
ASTNode last,
ASTNode anchorBefore) |
static void |
allowToMarkNodesForPostponedFormatting(boolean allow)
We allow to mark particular
AST nodes to be reformatted later (e.g. |
static PsiElement |
createLineFeed(PsiManager manager) |
static int |
getOldIndentation(ASTNode node) |
static boolean |
isMarkedToReformat(ASTNode node)
Allows to answer if given node is configured to be reformatted.
|
static boolean |
isMarkedToReformatBefore(TreeElement element) |
static boolean |
isNodeGenerated(ASTNode node) |
static boolean |
isSuspendedNodesReformattingAllowed() |
static void |
markToReformat(ASTNode node,
boolean value)
Allows to define if given element should be reformatted later.
|
static void |
markToReformatBefore(ASTNode right,
boolean value) |
static void |
removeChild(ASTNode parent,
ASTNode child) |
static void |
removeChildren(ASTNode parent,
ASTNode first,
ASTNode last) |
static void |
replaceChild(ASTNode parent,
ASTNode oldChild,
ASTNode newChild) |
static void |
saveWhitespacesInfo(ASTNode first) |
static void |
setAllowSuspendNodesReformatting(boolean allow)
There is a possible case that particular PSI tree node is
marked for reformatting . |
static void |
setNodeGenerated(ASTNode next,
boolean value) |
static void |
setNodeGeneratedRecursively(ASTNode next,
boolean value) |
static void |
setNodeReformatStrategy(NotNullFunction<? super ASTNode,java.lang.Boolean> strategy)
Allows to control the same process as
setAllowSuspendNodesReformatting(boolean) but on a node level. |
static void |
setOldIndentation(TreeElement treeElement,
int oldIndentation) |
public static ASTNode addChildren(ASTNode parent, ASTNode first, ASTNode last, ASTNode anchorBefore)
public static void saveWhitespacesInfo(ASTNode first)
public static int getOldIndentation(ASTNode node)
public static void markToReformatBefore(ASTNode right, boolean value)
public static boolean isNodeGenerated(ASTNode node)
public static void setNodeGenerated(ASTNode next, boolean value)
public static void setNodeGeneratedRecursively(ASTNode next, boolean value)
public static void setOldIndentation(TreeElement treeElement, int oldIndentation)
public static boolean isMarkedToReformatBefore(TreeElement element)
public static PsiElement createLineFeed(PsiManager manager)
public static boolean isMarkedToReformat(ASTNode node)
node
- node to checktrue
if given node is configured to be reformatted; false
otherwisepublic static void markToReformat(ASTNode node, boolean value)
node
- target element which 'reformat'
status should be changedvalue
- true
if the element should be reformatted; false
otherwisepublic static void allowToMarkNodesForPostponedFormatting(boolean allow)
AST nodes
to be reformatted later (e.g. we may want method definition and calls
to be reformatted when we perform 'change method signature'
refactoring. Hence, we mark corresponding expressions
to be reformatted).
For convenience that is made automatically on AST/PSI level, i.e. every time target element change it automatically marks itself
to be reformatted.
However, there is a possible case that particular element is changed because of formatting, hence, there is no need to mark
itself for postponed formatting one more time. This method allows to configure allowance of reformat markers processing
for the calling thread. I.e. this method may be called with 'false'
as an argument, hence, all further attempts
to mark node for postponed formatting
will have no effect until current method is
called with 'true'
as an argument. Hence, following usage scenario is expected:
'false'
argument;'try'
block;'false'
argument from 'finally'
section;allow
- flag that defines if new reformat markers can be added from the current threadmarkToReformat(ASTNode, boolean)
public static boolean isSuspendedNodesReformattingAllowed()
'allow suspended formatting'
flag valuesetAllowSuspendNodesReformatting(boolean)
public static void setAllowSuspendNodesReformatting(boolean allow)
marked for reformatting
.
That means that there is a big chance that the node will be re-formatted during corresponding document processing
(e.g. on call to PsiDocumentManager.doPostponedOperationsAndUnblockDocument(Document)
).
However, there is a possible case that particular activity that triggers such document processing is not ready to the
situation when the document is modified because of postponed formatting. Hence, it may ask to suspend postponed formatting
for a while. This method allows to do that at thread-local manner. I.e. it's expected to be called as follows:
- This method is called with
'false'
argument;- Document is processed at dedicated
'try'
block;- This method is called with
'true'
argument from'finally'
section;
public static void setNodeReformatStrategy(NotNullFunction<? super ASTNode,java.lang.Boolean> strategy)
setAllowSuspendNodesReformatting(boolean)
but on a node level. I.e. it allows
to answer if particular node can be reformatted if global reformatting is allowed
.strategy
- strategy to use; null
as an indication that no fine-grained checking should be performed