PsiLocalVariable (@NotNull PsiElement elementAt) { if (elementAt instanceof PsiIdentifier && elementAt.getParent() instanceof PsiLocalVariable psiVariable && psiVariable.getTypeElement().isInferredType()) { return psiVariable; } if (elementAt instanceof PsiKeyword keyword && keyword.getTokenType() == JavaTokenType.VAR_KEYWORD && keyword.getParent() != null && keyword.getParent().getParent() instanceof PsiLocalVariable psiVariable) { return psiVariable; } return null; }