PsiLocalVariable (PsiElement element) { PsiLocalVariable variable = PsiTreeUtil.getNonStrictParentOfType(element, PsiLocalVariable.class); if (variable != null && variable.getParent() instanceof PsiDeclarationStatement && variable.getParent().getParent() instanceof PsiCodeBlock && rightType(variable.getType()) && validExpression(variable.getInitializer())) { return variable; } if (variable == null && element instanceof PsiWhiteSpace) { PsiElement sibling = element.getPrevSibling(); if (sibling instanceof PsiDeclarationStatement) { PsiElement lastVar = ArrayUtil.getLastElement(((PsiDeclarationStatement)sibling).getDeclaredElements()); if (lastVar instanceof PsiLocalVariable) { variable = (PsiLocalVariable)lastVar; if (rightType(variable.getType()) && validExpression(variable.getInitializer())) { return variable; } } } } return null; }