PsiRecordComponent (@NotNull PsiPattern pattern) { PsiDeconstructionList deconstructionList = ObjectUtils.tryCast(pattern.getParent(), PsiDeconstructionList.class); if (deconstructionList == null) return null; @NotNull PsiPattern @NotNull [] patterns = deconstructionList.getDeconstructionComponents(); int index = ArrayUtil.indexOf(patterns, pattern); PsiDeconstructionPattern deconstructionPattern = ObjectUtils.tryCast(deconstructionList.getParent(), PsiDeconstructionPattern.class); if (deconstructionPattern == null) return null; PsiClassType classType = ObjectUtils.tryCast(deconstructionPattern.getTypeElement().getType(), PsiClassType.class); if (classType == null) return null; PsiClass aClass = classType.resolve(); if (aClass == null) return null; PsiRecordComponent[] components = aClass.getRecordComponents(); if (components.length <= index) return null; return components[index]; }