Search in sources :

Example 6 with GrWhileStatement

use of org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement in project intellij-community by JetBrains.

the class WhileSurrounder method getSurroundSelectionRange.

@Override
protected TextRange getSurroundSelectionRange(GroovyPsiElement element) {
    assert element instanceof GrWhileStatement;
    GrCondition condition = ((GrWhileStatement) element).getCondition();
    int endOffset = element.getTextRange().getEndOffset();
    if (condition != null) {
        endOffset = condition.getTextRange().getStartOffset();
        condition.getParent().getNode().removeChild(condition.getNode());
    }
    return new TextRange(endOffset, endOffset);
}
Also used : GrWhileStatement(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement) TextRange(com.intellij.openapi.util.TextRange) GrCondition(org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition)

Aggregations

GrWhileStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement)6 GrStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)3 Document (com.intellij.openapi.editor.Document)2 TextRange (com.intellij.openapi.util.TextRange)2 PsiElement (com.intellij.psi.PsiElement)2 GrCondition (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition)2 GrBlockStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrBlockStatement)2 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)1