PsiArrayAccessExpression (PsiForStatement forStatement) { PsiStatement body = forStatement.getBody(); while (body instanceof PsiBlockStatement blockStatement) { final PsiCodeBlock codeBlock = blockStatement.getCodeBlock(); final PsiStatement[] statements = codeBlock.getStatements(); if (statements.length == 2) { body = statements[1]; } else if (statements.length == 1) { body = statements[0]; } else { return null; } } if (!(body instanceof PsiExpressionStatement expressionStatement)) { return null; } final PsiExpression expression = expressionStatement.getExpression(); if (!(expression instanceof PsiAssignmentExpression assignmentExpression)) { return null; } final PsiExpression lhs = assignmentExpression.getLExpression(); final PsiExpression deparenthesizedExpression = PsiUtil.skipParenthesizedExprDown(lhs); if (!(deparenthesizedExpression instanceof PsiArrayAccessExpression)) { return null; } return (PsiArrayAccessExpression)deparenthesizedExpression; }