-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Inside the snapshot-lib project you will see these folders:
commonMain- compiles for all platformsjvmMain- compiles only on the JVMjsMain- compiles only to JScommonTest- these tests run on all platformsjvmTest- these tests only run on JVM- etc.
Good example
We want as much code as possible to live in common. A good example of multiplatform is this:
- a simple
internal expect funto wrap a platform-specific API - all the logic of
ArrayMaplives incommon
Then we implement the "expect" for both jvm and js with "actual"
- https://github.com/diffplug/spotless-snapshot/blob/f63192a84390901a3d3543066d095ea23bf81d21/snapshot-lib/src/jvmMain/kotlin/com/diffplug/snapshot/FastMap.jvm.kt#L25-L26
- https://github.com/diffplug/spotless-snapshot/blob/f63192a84390901a3d3543066d095ea23bf81d21/snapshot-lib/src/jsMain/kotlin/com/diffplug/snapshot/FastMap.js.kt#L20-L31
Work to be done.
In this case, we have JVM-only code. It should be pretty easy to move it into common, but there are a few tricky parts, which I don't want to deal with right now. So I move only the public API into common.
Leave the implementation as jvm only, and the js just throws TODO exceptions for now
- https://github.com/diffplug/spotless-snapshot/blob/f63192a84390901a3d3543066d095ea23bf81d21/snapshot-lib/src/jvmMain/kotlin/com/diffplug/snapshot/PerCharacterEscaper.jvm.kt#L18-L171
- https://github.com/diffplug/spotless-snapshot/blob/f63192a84390901a3d3543066d095ea23bf81d21/snapshot-lib/src/jsMain/kotlin/com/diffplug/snapshot/PerCharacterEscaper.js.kt#L18-L21
To implement this I would
- move
PerCharacterEscaperTestout ofjvmTestand intocommonTestgradlew jvmTestwill still be passing, butgradlew jsTestwill now be failing
- remove the
expect actualstuff and just put the whole JVM implementation into common - fix compile errors with as little platform-specific code as possible
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request