use of org.jetbrains.plugins.groovy.lang.psi.api.statements.GrForStatement 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.GrForStatement in project intellij-community by JetBrains.
the class ForToEachPredicate method satisfiedBy.
@Override
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof GrForStatement)) {
return false;
}
final GrForStatement statement = (GrForStatement) element;
final GrForClause clause = statement.getClause();
if (!(clause instanceof GrForInClause) || ((GrForInClause) clause).getIteratedExpression() == null) {
return false;
}
return !ErrorUtil.containsError(element);
}
Aggregations