Skip to content
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

Updated Kotlin to 2.0.10 #175

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Updated Kotlin to 2.0.10 #175

merged 1 commit into from
Aug 6, 2024

Conversation

arkivanov
Copy link
Owner

@arkivanov arkivanov commented Aug 6, 2024

Summary by CodeRabbit

  • New Features

    • Introduced an ExperimentalInstanceKeeperApi annotation to indicate potential changes in instance management features.
    • Added a save method to StateKeeperDispatcher for enhanced state persistence.
    • Introduced SerializableContainer class with methods for better management of serialized data.
    • Added inline functions like getOrCreate for more type-safe instance management.
  • Improvements

    • Refined the BackCallback and BackDispatcher interfaces for improved clarity and usability.
    • Enhanced the Lifecycle API for better organization and management of lifecycle events.
  • Dependency Updates

    • Upgraded Kotlin version from 2.0.0 to 2.0.10 for better compatibility and performance.

Copy link

coderabbitai bot commented Aug 6, 2024

Walkthrough

This update enhances several Kotlin APIs related to back handling, instance management, lifecycle events, and state management. Key changes include restructuring interfaces for improved clarity, reintroducing essential methods for object manipulation, and adding experimental annotations to signal future developments. The updates aim to streamline functionality, improve usability, and maintain compatibility while introducing new features for better lifecycle and state management.

Changes

File Path Change Summary
back-handler/api/... Restructured BackCallback and BackDispatcher, converting isEnabled from a method to an abstract property. BackEvent methods reinstated for object manipulation.
deps.versions.toml Updated Kotlin version from 2.0.0 to 2.0.10 and kotlinxBinaryCompatibilityValidator from 0.15.0-Beta.2 to 0.16.3, maintaining other dependency versions.
instance-keeper/api/... Added ExperimentalInstanceKeeperApi, introduced SimpleInstance for lifecycle management, and extended InstanceKeeperDispatcher with a new destroy method.
lifecycle/api/... Restructured Lifecycle interface and reintroduced valueOf and values in the State enum, improving state management capabilities.
settings.gradle.kts Updated Gradle setup plugin version from a82ef530e3 to 310f7f6b99, changing the resolution strategy.
state-keeper/api/... Introduced ExperimentalStateKeeperApi, extended StateKeeperDispatcher with a save method, and added methods for managing serialized data in SerializableContainer.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BackHandler
    participant StateKeeper

    User->>BackHandler: Trigger Back Navigation
    BackHandler->>StateKeeper: Save Current State
    StateKeeper-->>BackHandler: State Saved
    BackHandler->>User: Navigate Back
Loading

🐇 In the realm of code where the rabbits play,
New paths and features hop into the fray!
With interfaces sleek and states that gleam,
A joyful update, like a coder's dream!
Let's dance with the changes, let the code flow,
For a bright future, we’ll hop and we’ll grow! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f6d2dfb and ca8c464.

Files selected for processing (6)
  • back-handler/api/back-handler.klib.api (2 hunks)
  • deps.versions.toml (1 hunks)
  • instance-keeper/api/instance-keeper.klib.api (2 hunks)
  • lifecycle/api/lifecycle.klib.api (2 hunks)
  • settings.gradle.kts (1 hunks)
  • state-keeper/api/state-keeper.klib.api (2 hunks)
Files skipped from review due to trivial changes (1)
  • deps.versions.toml
Additional comments not posted (23)
settings.gradle.kts (1)

18-18: Verify the compatibility of the new plugin version.

Ensure that the new version 310f7f6b99 of the gradle-setup-plugin is compatible with your project and does not introduce any breaking changes.

instance-keeper/api/instance-keeper.klib.api (1)

9-11: LGTM! Verify the usage of the new annotation.

The addition of the ExperimentalInstanceKeeperApi annotation class looks good.

Ensure that this annotation is used consistently and appropriately across the codebase.

Verification successful

The usage of the ExperimentalInstanceKeeperApi annotation is consistent and appropriate.

The annotation is applied to convenience functions that extend or simplify the InstanceKeeper functionality, aligning with its intended purpose.

  • InstanceKeeperExt.kt: The annotation is used in functions like retainedInstance and retainedSimpleInstance.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `ExperimentalInstanceKeeperApi` annotation.

# Test: Search for the usage of the `ExperimentalInstanceKeeperApi` annotation.
# Expect: Consistent and appropriate usage.

rg --type kotlin '@ExperimentalInstanceKeeperApi'

Length of output: 557


Script:

#!/bin/bash
# Description: Extract and review the lines around the matches for `@ExperimentalInstanceKeeperApi` in the `InstanceKeeperExt.kt` file.

# Display 5 lines of context around each match to understand the usage.
rg --type kotlin '@ExperimentalInstanceKeeperApi' -A 5 -B 5 instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt

Length of output: 1411

state-keeper/api/state-keeper.klib.api (9)

19-23: LGTM! Verify the implementation of the new method.

The addition of the save method to the StateKeeperDispatcher interface looks good.

Ensure that this method is implemented correctly and review its usage across the codebase.

Verification successful

Implementation Verified:

The save method in the StateKeeperDispatcher interface is correctly implemented in the DefaultStateKeeperDispatcher class. It collects data from registered suppliers and returns a SerializableContainer with the saved state. The method is also well-tested in various test cases.

  • state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcher.kt
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new `save` method in `StateKeeperDispatcher`.

# Test: Search for the implementation of the `save` method.
# Expect: Correct implementation and usage.

rg --type kotlin 'StateKeeperDispatcher.*save'

Length of output: 2160


Script:

#!/bin/bash
# Description: Verify the implementation of the `save` method in `DefaultStateKeeperDispatcher`.

# Test: Search for the implementation of the `save` method.
# Expect: Correct implementation and usage.

rg --type kotlin 'fun save' --context 10

Length of output: 15202


40-40: LGTM! Verify the implementation of the new function.

The addition of the StateKeeperDispatcher function looks good.

Ensure that this function is implemented correctly and review its usage across the codebase.

Verification successful

The implementation of the StateKeeperDispatcher function is correct and its usage is adequately covered in the codebase.

  • The function is implemented in state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperDispatcher.kt.
  • It creates an instance of DefaultStateKeeperDispatcher.
  • The function is used in various test files, ensuring it is tested properly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new `StateKeeperDispatcher` function.

# Test: Search for the implementation of the `StateKeeperDispatcher` function.
# Expect: Correct implementation and usage.

rg --type kotlin 'StateKeeperDispatcher.*StateKeeperDispatcher'

Length of output: 253


Script:

#!/bin/bash
# Display the content of the file where the `StateKeeperDispatcher` function is implemented.
cat state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperDispatcher.kt

# Search for the usage of the `StateKeeperDispatcher` function in the codebase.
rg --type kotlin 'StateKeeperDispatcher'

Length of output: 4115


9-11: LGTM! Verify the usage of the new annotation.

The addition of the ExperimentalStateKeeperApi annotation class looks good.

Ensure that this annotation is used consistently and appropriately across the codebase.

Verification successful

Usage of @ExperimentalStateKeeperApi verified and appropriate.

The @ExperimentalStateKeeperApi annotation is used consistently and appropriately in the following files:

  • state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt
  • state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

These functions are related to experimental features in state management and serialization.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `ExperimentalStateKeeperApi` annotation.

# Test: Search for the usage of the `ExperimentalStateKeeperApi` annotation.
# Expect: Consistent and appropriate usage.

rg --type kotlin '@ExperimentalStateKeeperApi'

Length of output: 750


Script:

#!/bin/bash
# Extract the annotated sections from StateKeeperExt.kt and PolymorphicSerializer.kt for review.

# Extract sections with @ExperimentalStateKeeperApi annotation from StateKeeperExt.kt
rg --type kotlin -A 5 '@ExperimentalStateKeeperApi' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt

# Extract sections with @ExperimentalStateKeeperApi annotation from PolymorphicSerializer.kt
rg --type kotlin -A 5 '@ExperimentalStateKeeperApi' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

Length of output: 1652


40-40: LGTM! Verify the implementation of the new function.

The addition of the polymorphicSerializer function looks good.

Ensure that this function is implemented correctly and review its usage across the codebase.

Verification successful

Verification Successful!

The polymorphicSerializer function is correctly implemented and its usage in the test file confirms its functionality.

  • PolymorphicSerializer.kt contains both implementations of polymorphicSerializer.
  • The test file PolymorphicSerializerTest.kt demonstrates proper usage of the function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new `polymorphicSerializer` function.

# Test: Search for the implementation of the `polymorphicSerializer` function.
# Expect: Correct implementation and usage.

rg --type kotlin 'polymorphicSerializer'

Length of output: 764


Script:

#!/bin/bash
# Extract the implementation of the `polymorphicSerializer` functions.
rg --type kotlin -A 10 'fun <reified T : Any> polymorphicSerializer' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

rg --type kotlin -A 10 'fun <T : Any> polymorphicSerializer' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

# Extract the usage of the `polymorphicSerializer` function in the test file.
rg --type kotlin -A 10 'polymorphicSerializer' state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt

Length of output: 1760


40-40: LGTM! Verify the implementation of the new function.

The addition of the SerializableContainer function looks good.

Ensure that this function is implemented correctly and review its usage across the codebase.

Verification successful

Implementation of SerializableContainer verified.

The SerializableContainer class and its associated functions are correctly implemented.

  • The class provides necessary methods for setting, consuming, and clearing serialized data.
  • The additional functions SerializableContainer and consumeRequired offer convenience for creating and consuming instances.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new `SerializableContainer` function.

# Test: Search for the implementation of the `SerializableContainer` function.
# Expect: Correct implementation and usage.

rg --type kotlin 'SerializableContainer.*SerializableContainer'

Length of output: 1118


Script:

#!/bin/bash
# Description: Verify the implementation of the new `SerializableContainer` function.

# Test: Search for the definition of the `SerializableContainer` function.
# Expect: Correct implementation and usage.

rg --type kotlin 'fun SerializableContainer'

Length of output: 214


Script:

#!/bin/bash
# Description: Verify the definition of `SerializableContainer`.

# Test: Search for the class or interface definition of `SerializableContainer`.
# Expect: Correct implementation and usage.

rg --type kotlin 'class SerializableContainer|interface SerializableContainer'

Length of output: 355


Script:

#!/bin/bash
# Description: Retrieve the contents of the `SerializableContainer` class implementation.

# Test: Display the contents of `SerializableContainer.kt`.
# Expect: Review the implementation details.

cat state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/SerializableContainer.kt

Length of output: 3615


40-40: LGTM! Verify the implementation of the new function.

The addition of the saveable function looks good.

Ensure that this function is implemented correctly and review its usage across the codebase.

Verification successful

The implementation and usage of the saveable function are correct.

  • The saveable function is implemented in state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt.
  • It provides a property delegate that saves and restores state using a provided serializer.
  • The function is adequately tested in state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new `saveable` function.

# Test: Search for the implementation of the `saveable` function.
# Expect: Correct implementation and usage.

rg --type kotlin 'saveable'

Length of output: 1994


Script:

#!/bin/bash
# Extract the implementation details of the `saveable` function from `StateKeeperExt.kt`
ast-grep --lang kotlin --pattern 'inline fun <T : Any> StateKeeper.saveable($_) { $$$ }'

# Extract the usage of the `saveable` function in the test file `StateKeeperExtTest.kt`
rg --type kotlin 'saveable' -A 10 state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt

Length of output: 1505


Script:

#!/bin/bash
# Search for the `saveable` function definition in `StateKeeperExt.kt`
rg --type kotlin 'inline fun <T : Any> StateKeeper.saveable' -A 20 state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt

Length of output: 907


40-40: LGTM! Verify the implementation of the new function.

The addition of the polymorphicSerializer function looks good.

Ensure that this function is implemented correctly and review its usage across the codebase.

Verification successful

Implementation and Usage Verified

The implementation of the polymorphicSerializer function, including both the inline and regular versions, has been verified. The usage in the test file is also correct.

  • state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

    • Inline version: inline fun <reified T : Any> polymorphicSerializer(module: SerializersModule): KSerializer<T>
    • Regular version: fun <T : Any> polymorphicSerializer(baseClass: KClass<T>, module: SerializersModule): KSerializer<T>
  • state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt

    • Usage of polymorphicSerializer in tests
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new `polymorphicSerializer` function.

# Test: Search for the implementation of the `polymorphicSerializer` function.
# Expect: Correct implementation and usage.

rg --type kotlin 'polymorphicSerializer'

Length of output: 764


Script:

#!/bin/bash
# Extract the implementation of the inline version of the polymorphicSerializer function
ast-grep --lang kotlin --pattern $'inline fun <reified T : Any> polymorphicSerializer(module: SerializersModule): KSerializer<T> = {
  $$$
}' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

# Extract the implementation of the regular version of the polymorphicSerializer function
ast-grep --lang kotlin --pattern $'fun <T : Any> polymorphicSerializer(baseClass: KClass<T>, module: SerializersModule): KSerializer<T> = {
  $$$
}' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt

# Verify the usage of the polymorphicSerializer function in the test file
rg --type kotlin 'polymorphicSerializer' state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt -A 5

Length of output: 903


Script:

#!/bin/bash
# Adjust the pattern and search for the inline version of the polymorphicSerializer function
rg --type kotlin 'inline fun <reified T : Any> polymorphicSerializer' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt -A 10

# Adjust the pattern and search for the regular version of the polymorphicSerializer function
rg --type kotlin 'fun <T : Any> polymorphicSerializer' state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt -A 10

Length of output: 1325


40-40: LGTM! Verify the implementation of the new function.

The addition of the consumeRequired function to the SerializableContainer class looks good.

Ensure that this function is implemented correctly and review its usage across the codebase.


28-35: LGTM! Verify the implementation of the new methods.

The addition of the consume, set, clear methods, and the serializer method in the companion object to the SerializableContainer class looks good.

Ensure that these methods are implemented correctly and review their usage across the codebase.

lifecycle/api/lifecycle.klib.api (6)

15-16: Confirmed: Method signatures for subscribe and unsubscribe remain unchanged.

The methods are essential for managing lifecycle callbacks, and their unchanged signatures ensure compatibility.


28-29: Confirmed: Reintroduction of valueOf and values methods in State enum.

These methods are essential for retrieving enum constants dynamically, ensuring effective lifecycle state management.


24-27: Confirmed: Addition of entries property in State enum.

This property provides a structured way to access all enum entries, enhancing usability.


32-38: Confirmed: Method signatures in Callbacks interface remain unchanged.

The interface has been repositioned within the Lifecycle interface, but the method signatures remain unchanged, ensuring compatibility.


75-77: Confirmed: Changes in state property and getter method in ApplicationLifecycle class.

These changes align with the new structure of the Lifecycle interface.


77-77: Confirmed: Updated method signatures for subscribe and unsubscribe in ApplicationLifecycle class.

These updates ensure consistency with the Lifecycle interface.

back-handler/api/back-handler.klib.api (6)

10-11: Confirmed: Transformation of isEnabled from method to abstract property.

This change enhances clarity and usability by allowing direct access to the isEnabled state.


32-38: Confirmed: Redefinition of BackCallback class with explicit structure.

The inclusion of the isEnabled property and other refinements improve the organization and visibility of the class.


71-78: Confirmed: Reintroduction of essential methods in BackEvent class.

Methods like component1, component2, component3, component4, copy, equals, hashCode, and toString are essential for object manipulation and comparison.


80-90: Confirmed: Restructuring of SwipeEdge enum with reinstated methods and entries.

These changes are crucial for handling swipe gestures in back navigation.


12-12: Confirmed: Method signature for back remains unchanged.

The unchanged method signature ensures compatibility.


20-26: Confirmed: Method signatures for register and unregister remain unchanged.

The unchanged method signatures ensure compatibility.

@arkivanov arkivanov merged commit a8778a8 into master Aug 6, 2024
2 checks passed
@arkivanov arkivanov deleted the update-kotlin branch August 6, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant