use of org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause in project intellij-community by JetBrains.
the class ForSurrounder method getSurroundSelectionRange.
@Override
protected TextRange getSurroundSelectionRange(GroovyPsiElement element) {
assert element instanceof GrForStatement;
GrForClause clause = ((GrForStatement) element).getClause();
int endOffset = element.getTextRange().getEndOffset();
if (clause != null) {
endOffset = clause.getTextRange().getStartOffset();
clause.getParent().getNode().removeChild(clause.getNode());
}
return new TextRange(endOffset, endOffset);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause in project intellij-community by JetBrains.
the class ReplaceDelimiterFix method processIntention.
@Override
protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
final PsiFile file = element.getContainingFile();
PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());
GrForStatement forStatement = PsiTreeUtil.getParentOfType(at, GrForStatement.class);
if (forStatement == null)
return;
GrForClause clause = forStatement.getClause();
if (clause instanceof GrForInClause) {
GrForStatement stubFor = (GrForStatement) GroovyPsiElementFactory.getInstance(project).createStatementFromText("for (x in y){}");
PsiElement newDelimiter = ((GrForInClause) stubFor.getClause()).getDelimiter();
PsiElement delimiter = ((GrForInClause) clause).getDelimiter();
delimiter.replace(newDelimiter);
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause in project intellij-community by JetBrains.
the class RecursionUtils method forStatementDefinitelyRecurses.
private static boolean forStatementDefinitelyRecurses(GrForStatement forStatement, GrMethod method) {
final GrForClause clause = forStatement.getClause();
if (clause == null)
return false;
final GrVariable var = clause.getDeclaredVariable();
if (var != null) {
final GrExpression initializer = var.getInitializerGroovy();
if (expressionDefinitelyRecurses(initializer, method)) {
return true;
}
}
return false;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause in project intellij-community by JetBrains.
the class RecursionUtils method forStatementMayReturnBeforeRecursing.
private static boolean forStatementMayReturnBeforeRecursing(GrForStatement loopStatement, GrMethod method) {
final GrForClause forClause = loopStatement.getClause();
if (forClause != null) {
final GrVariable var = forClause.getDeclaredVariable();
if (var != null) {
final GrExpression initializer = var.getInitializerGroovy();
if (expressionDefinitelyRecurses(initializer, method)) {
return false;
}
}
}
final GrStatement body = loopStatement.getBody();
return statementMayReturnBeforeRecursing(body, method);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause in project intellij-community by JetBrains.
the class EquivalenceChecker method forInStatementsAreEquivalent.
private static boolean forInStatementsAreEquivalent(@NotNull GrForStatement statement1, @NotNull GrForStatement statement2) {
final GrForClause clause1 = statement1.getClause();
final GrForClause clause2 = statement2.getClause();
if (!forClausesAreEquivalent(clause1, clause2)) {
return false;
}
final GrStatement body1 = statement1.getBody();
final GrStatement body2 = statement2.getBody();
return statementsAreEquivalent(body1, body2);
}
Aggregations