public class SurroundWithUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static TextRange |
getRangeToSelect(PsiCodeBlock block) |
static void |
indentCommentIfNecessary(PsiCodeBlock container,
PsiElement [] statements)
Performs indentation (if necessary) of the given code block that surrounds target statements.
|
static PsiElement[] |
moveDeclarationsOut(PsiElement block,
PsiElement[] statements,
boolean generateInitializers) |
public static PsiElement[] moveDeclarationsOut(PsiElement block, PsiElement[] statements, boolean generateInitializers)
public static TextRange getRangeToSelect(PsiCodeBlock block)
public static void indentCommentIfNecessary(PsiCodeBlock container, PsiElement [] statements)
void test() { // This is comment int i = 1; }The problem is that surround block doesn't contain any indent spaces, hence, the first statement is inserted to the zero column. But we have a dedicated code style setting
'keep comment at first column'
, i.e. the comment
will not be moved if that setting is checked.
Current method handles that situation.container
- code block that surrounds target statementsstatements
- target statements being surrounded