-
-
Notifications
You must be signed in to change notification settings - Fork 21
Separate data classes and parser #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 PR refactors the WebDAV XML parsing logic in the ktor package by separating parser methods from data classes. Previously, parsing logic was implemented as companion object methods on data classes (Response.parse, PropStat.parse). Now, dedicated parser classes (ResponseParser, PropStatParser, MultiStatusParser) handle the parsing logic, leaving data classes focused purely on data representation. This separation clarifies the code structure and makes it clearer where tests should be placed.
Key Changes:
- Created three new parser classes:
ResponseParser,PropStatParser, andMultiStatusParser - Removed companion objects with parsing logic from
ResponseandPropStatdata classes - Updated
DavResourceto use the newMultiStatusParserinstead of the privateparseMultiStatusmethod
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/kotlin/at/bitfire/dav4jvm/ktor/ResponseParser.kt | New parser class for WebDAV response XML elements, extracted from Response companion object |
| src/main/kotlin/at/bitfire/dav4jvm/ktor/PropStatParser.kt | New parser class for propstat XML elements, extracted from PropStat companion object |
| src/main/kotlin/at/bitfire/dav4jvm/ktor/MultiStatusParser.kt | New parser class for multistatus XML responses, extracted from DavResource.parseMultiStatus |
| src/main/kotlin/at/bitfire/dav4jvm/ktor/Response.kt | Removed companion object with parsing logic; kept as pure data class |
| src/main/kotlin/at/bitfire/dav4jvm/ktor/PropStat.kt | Removed companion object with parsing logic; kept as pure data class |
| src/main/kotlin/at/bitfire/dav4jvm/ktor/DavResource.kt | Updated to use MultiStatusParser and removed private parseMultiStatus method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Move `PropStatParser` to object-based implementation - Update `MultiStatusParser` and `ResponseParser` to use callback directly - Remove redundant parameters from parsing functions
ccf65a2 to
8229a31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Separate data classes and parser methods so that it's clear where tests have to be