@Override public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { final PsiElement forElement = descriptor.getPsiElement(); final PsiElement parent = forElement.getParent(); if (!(parent instanceof PsiForStatement)) { return; } final PsiForStatement forStatement = (PsiForStatement)parent; final String newExpression; if (isArrayLoopStatement(forStatement)) { newExpression = createArrayIterationText(forStatement); } else if (isCollectionLoopStatement(forStatement, ignoreUntypedCollections)) { newExpression = createCollectionIterationText(forStatement); } else if (isIndexedListLoopStatement(forStatement, ignoreUntypedCollections)) { newExpression = createListIterationText(forStatement); } else { return; } if (newExpression == null) { return; } replaceStatementAndShortenClassNames(forStatement, newExpression); }