PsiMethod (@NotNull PsiClass recordClass) { if (!recordClass.isRecord()) return null; PsiMethod[] constructors = recordClass.getConstructors(); if (constructors.length == 0) return null; PsiRecordComponent[] components = recordClass.getRecordComponents(); for (PsiMethod constructor : constructors) { if (isCompactConstructor(constructor) || hasCanonicalSignature(constructor, components)) { return constructor; } } return null; }