void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiElement element = startElement.getParent(); if (!(element instanceof PsiNewExpression expression)) { return; } final PsiExpressionList argumentList = expression.getArgumentList(); if (argumentList == null) { return; } final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length != 1) { return; } final PsiExpression argument = arguments[0]; final String text = argument.getText(); final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(expression); CommentTracker tracker = new CommentTracker(); @NonNls final String newExpression; if (PsiKeyword.TRUE.equals(text) || TRUE.equalsIgnoreCase(text)) { newExpression = "java.lang.Boolean.TRUE"; } else if (PsiKeyword.FALSE.equals(text) || FALSE.equalsIgnoreCase(text)) { newExpression = "java.lang.Boolean.FALSE"; } else if (languageLevel.equals(LanguageLevel.JDK_1_3)) { newExpression = buildText(tracker.markUnchanged(argument), false); } else { final PsiClass booleanClass = ClassUtils.findClass(CommonClassNames.JAVA_LANG_BOOLEAN, argument); boolean methodFound = false; if (booleanClass != null) { final PsiMethod[] methods = booleanClass.findMethodsByName("valueOf", false); for (PsiMethod method : methods) { final PsiParameterList parameterList = method.getParameterList(); final PsiParameter[] parameters = parameterList.getParameters(); if (parameters.length == 0) { continue; } final PsiParameter parameter = parameters[0]; final PsiType type = parameter.getType(); if (PsiTypes.booleanType().equals(type)) { methodFound = true; break; } } } newExpression = buildText(tracker.markUnchanged(argument), methodFound); } PsiReplacementUtil.replaceExpression(expression, newExpression, tracker); }