boolean (PsiVariable myVariable) { PsiParameter myParameter = null; PsiMethod method = null; if (myVariable instanceof PsiParameter) { myParameter = (PsiParameter)myVariable; method = ObjectUtils.tryCast(((PsiParameter)myVariable).getDeclarationScope(), PsiMethod.class); } else if (myVariable instanceof PsiField) { PsiRecordComponent component = JavaPsiRecordUtil.getComponentForField((PsiField)myVariable); PsiClass aClass = ((PsiField)myVariable).getContainingClass(); if (component != null && aClass != null) { method = JavaPsiRecordUtil.findCanonicalConstructor(aClass); if (method != null) { int index = ArrayUtil.indexOf(aClass.getRecordComponents(), component); PsiParameter parameter = method.getParameterList().getParameter(index); if (parameter != null && parameter.getName().equals(myVariable.getName())) { myParameter = parameter; } } } } if (method == null || myParameter == null) return false; changeSignature(myVariable, myParameter, method); return true; }