IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { HashSet<ParameterInfoImpl> newParams = new HashSet<>(); HashSet<ParameterInfoImpl> removedParams = new HashSet<>(); HashSet<ParameterInfoImpl> changedParams = new HashSet<>(); if (!(myTargetMethod.getContainingFile() instanceof PsiJavaFile)) return IntentionPreviewInfo.EMPTY; ParameterInfoImpl[] parameterInfos = getNewParametersInfo(myExpressions, myTargetMethod, mySubstitutor, new StringBuilder(), newParams, removedParams, changedParams); PsiParameterList parameterList = myTargetMethod.getParameterList(); PsiParameter[] oldParameters = parameterList.getParameters(); if (parameterInfos == null) return IntentionPreviewInfo.EMPTY; String params = "(" + StringUtil.join(parameterInfos, p -> { if (p.oldParameterIndex != ParameterInfo.NEW_PARAMETER && !changedParams.contains(p)) { PsiParameter parameter = oldParameters[p.oldParameterIndex]; PsiRecordComponent component = JavaPsiRecordUtil.getComponentForCanonicalConstructorParameter(parameter); return Objects.requireNonNullElse(component, parameter).getText(); } return p.getTypeText() + " " + p.getName(); }, ", ") + ")"; TextRange range; String methodText; PsiRecordHeader header = null; if (JavaPsiRecordUtil.isCanonicalConstructor(myTargetMethod) && !JavaPsiRecordUtil.isExplicitCanonicalConstructor(myTargetMethod)) { PsiClass recordClass = ObjectUtils.tryCast(myTargetMethod.getParent(), PsiClass.class); header = recordClass == null ? null : recordClass.getRecordHeader(); } if (header != null) { range = header.getTextRangeInParent(); methodText = header.getParent().getText(); } else { if (myTargetMethod instanceof SyntheticElement) return IntentionPreviewInfo.EMPTY; range = parameterList.getTextRangeInParent(); methodText = myTargetMethod.getText(); } String methodTextWithChangedParameters = methodText.substring(0, range.getStartOffset()) + params + methodText.substring(range.getEndOffset()); return new IntentionPreviewInfo.CustomDiff(JavaFileType.INSTANCE, myTargetMethod.getContainingFile() != myContext.getContainingFile() ? myTargetMethod.getContainingFile().getName() : null, methodText, methodTextWithChangedParameters); }