void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement element = descriptor.getPsiElement(); UCallExpression uExpression = UastContextKt.toUElement(element, UCallExpression.class); if (uExpression == null) return; @NonNls String methodName = null; List<UExpression> paramValues = new ArrayList<>(); switch (uExpression.getValueArgumentCount()) { case 1 -> methodName = getEmptyFactoryMethodName(); case 2 -> { List<UExpression> params = uExpression.getValueArguments(); UExpression topAndBottom = params.get(0); UExpression leftAndRight = params.get(1); if (isZero(topAndBottom, leftAndRight)) { methodName = getEmptyFactoryMethodName(); } else if (areSame(topAndBottom, leftAndRight)) { methodName = getAllSameFactoryMethodName(); paramValues.add(topAndBottom); } } case 4 -> { List<UExpression> params = uExpression.getValueArguments(); UExpression top = params.get(0); UExpression left = params.get(1); UExpression bottom = params.get(2); UExpression right = params.get(3); if (isZero(top, left, bottom, right)) { methodName = getEmptyFactoryMethodName(); } else if (isZero(left, bottom, right)) { methodName = getTopFactoryMethodName(); paramValues.add(top); } else if (isZero(top, bottom, right)) { methodName = getLeftFactoryMethodName(); paramValues.add(left); } else if (isZero(top, left, right)) { methodName = getBottomFactoryMethodName(); paramValues.add(bottom); } else if (isZero(top, left, bottom)) { methodName = getRightFactoryMethodName(); paramValues.add(right); } else if (areSame(top, left, bottom, right)) { methodName = getAllSameFactoryMethodName(); paramValues.add(top); } else if (areSame(top, bottom) && areSame(right, left)) { methodName = getTopBottomAndLeftRightSameFactoryMethodName(); paramValues.add(top); paramValues.add(left); } else { methodName = getAllDifferentFactoryMethodName(); paramValues.add(top); paramValues.add(left); paramValues.add(bottom); paramValues.add(right); } } } if (methodName == null) return; UastCodeGenerationPlugin generationPlugin = UastCodeGenerationPlugin.byLanguage(element.getLanguage()); if (generationPlugin == null) return; UastElementFactory pluginElementFactory = generationPlugin.getElementFactory(project); UCallExpression emptyBorderFactoryMethodCall = pluginElementFactory.createCallExpression( getReceiverIfNeeded(pluginElementFactory, uExpression, element), methodName, paramValues, null, UastCallKind.METHOD_CALL, element ); if (emptyBorderFactoryMethodCall == null) return; generationPlugin.replace(UastUtils.getQualifiedParentOrThis(uExpression), emptyBorderFactoryMethodCall, UCallExpression.class); }