boolean (PsiVariable var, PsiStatement nextStatement) { PsiElement declaration = var.getParent(); PsiElement nextStatementParent = nextStatement.getParent(); if(nextStatementParent instanceof PsiLabeledStatement) { nextStatement = (PsiStatement)nextStatementParent; } if(declaration instanceof PsiDeclarationStatement) { PsiElement[] elements = ((PsiDeclarationStatement)declaration).getDeclaredElements(); if (ArrayUtil.getLastElement(elements) == var && nextStatement.equals( PsiTreeUtil.skipWhitespacesAndCommentsForward(declaration))) { return true; } } return false; }