Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Jun 29, 2025

For: bitfireAT/davx5-ose#1554


Currently iCalendar parsing and UID/RECURRENCE-ID splitting is done in the Event data class, where it does not belong to. This PR

  • makes iCalendar parsing explicit and moves it to ICalendarParser (+ tests),
  • makes UID/RECURRENCE-ID splitting explicit and moves it to CalendarUidSplitter (+ tests),
  • introduces AssociatedComponents to associate a main event and its exceptions (+ tests).

There's a FIXME in the code, but it keeps current behavior and fixing that is not in the scope of this PR. I just added the comment to mark that code as bad.

CC @sunkup: Please have a look and comment especially if the "whole thing" that it does is unclear. I tried to add as good KDoc as possible. I however understand that it's hard to review this PR when its taken out of the whole refactoring context.

@rfc2822 rfc2822 added the refactoring Quality improvement of existing functions label Jun 29, 2025
@rfc2822 rfc2822 self-assigned this Jun 29, 2025
@rfc2822 rfc2822 force-pushed the explicit-parser branch 2 times, most recently from ba1052c to f8d18db Compare June 29, 2025 10:03
@rfc2822 rfc2822 marked this pull request as ready for review June 29, 2025 10:03
@rfc2822 rfc2822 requested a review from Copilot June 29, 2025 10:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request centralizes iCalendar parsing and makes UID/RECURRENCE-ID handling explicit across the library and tests.

  • Introduces ICalendarParser for preprocessing and wrapping parse errors.
  • Adds CalendarUidSplitter and AssociatedComponents to group and validate events by UID and RECURRENCE-ID.
  • Refactors higher-level consumers (ICalendar, Event, AndroidEvent) to use the new parser and splitter, and standardizes exception types.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ICalendarParser.kt New parser class applying ICalPreprocessor with explicit error wrapping.
CalendarUidSplitter.kt Splits components by UID/RECURRENCE-ID and filters by highest sequence.
AssociatedComponents.kt Data class enforcing main/exception UID constraints.
Ical4jHelpers.kt Helper factories and extension properties for CalendarComponent.
ICalendar.kt Switched to ICalendarParser and unified exception types.
Event.kt & AndroidEvent.kt Updated to use new parser/splitter and InvalidLocalResourceException.
lib/src/test/... (multiple) New unit tests covering parser, splitter, and associated components.
build.gradle.kts & libs.versions.toml Added MockK dependency for new parser tests.
Comments suppressed due to low confidence (1)

lib/src/main/kotlin/at/bitfire/synctools/icalendar/Ical4jHelpers.kt:18

  • [nitpick] Add KDoc describing the purpose and expected usage of this helper function to improve discoverability and maintenance.
fun<T: CalendarComponent> componentListOf(vararg components: T) =

sunkup
sunkup previously approved these changes Jul 1, 2025
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a while to understand, but I think the functionality from the original Event.eventsFromReader is preserved and it's a lot cleaner and safer now!

@rfc2822 rfc2822 merged commit 7bd154b into main Jul 1, 2025
9 checks passed
@rfc2822 rfc2822 deleted the explicit-parser branch July 1, 2025 13:58
@github-project-automation github-project-automation bot moved this from Todo to Done in DAVx⁵ Releases Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Quality improvement of existing functions

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants