PsiStatement (PsiStatement statement) { PsiStatement next = firstStatement(PsiTreeUtil.getNextSiblingOfType(statement, PsiStatement.class)); if (next == null) { PsiElement parent = statement.getParent(); if (parent instanceof PsiCodeBlock) { PsiElement gParent = parent.getParent(); if (gParent instanceof PsiBlockStatement || gParent instanceof PsiSwitchStatement) { return nextExecutedStatement((PsiStatement)gParent); } } else if (parent instanceof PsiLabeledStatement || parent instanceof PsiIfStatement || parent instanceof PsiSwitchLabelStatement || parent instanceof PsiSwitchStatement) { return nextExecutedStatement((PsiStatement)parent); } } return next; }