void (@NotNull PsiVariable var) { PsiExpression currentInitializer = var.getInitializer(); if (currentInitializer != null) return; PsiType type = var.getType(); String initializerText = PsiTypesUtil.getDefaultValueOfType(type); if (!PsiKeyword.NULL.equals(initializerText)) { WriteAction.run(() -> { PsiExpression initializer = JavaPsiFacade.getElementFactory(var.getProject()).createExpressionFromText(initializerText, var); var.setInitializer(initializer); }); } }