void (PsiVariable variable, PsiMethodCallExpression call, CommentTracker ct) { PsiMethod method = call.resolveMethod(); if(method != null) { PsiExpression[] args = call.getArgumentList().getExpressions(); @NonNls String name = method.getName(); switch (name) { case "length", "chars", "codePoints", "charAt", "codePointAt", "codePointBefore", "codePointAfter", "codePointCount", "offsetByCodePoints", "substring", "subSequence" -> { return; } case "getChars" -> { if (args.length == 4) return; } case "indexOf", "lastIndexOf" -> { if (args.length >= 1 && args.length <= 2 && TypeUtils.isJavaLangString(args[0].getType())) return; } case "isEmpty" -> { String sign = "=="; PsiExpression negation = BoolUtils.findNegation(call); PsiElement toReplace = call; if (negation != null) { sign = ">"; toReplace = negation; } PsiElementFactory factory = JavaPsiFacade.getElementFactory(variable.getProject()); PsiExpression emptyCheck = factory.createExpressionFromText(variable.getName() + ".length()" + sign + "0", call); PsiElement callParent = toReplace.getParent(); if (callParent instanceof PsiExpression && ParenthesesUtils.areParenthesesNeeded(emptyCheck, (PsiExpression)callParent, true)) { emptyCheck = factory.createExpressionFromText("(" + emptyCheck.getText() + ")", call); } ct.replace(toReplace, emptyCheck); return; } default -> { } } } PsiExpression qualifier = Objects.requireNonNull(call.getMethodExpression().getQualifierExpression()); ct.replace(qualifier, variable.getName() + ".toString()"); }