-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix id collision by adding DirectoryPath to modules Identity (#100)
- Loading branch information
Showing
6 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
plugin/core/src/main/kotlin/com/jetbrains/packagesearch/plugin/core/utils/DirectoryPath.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.jetbrains.packagesearch.plugin.core.utils | ||
|
||
import java.nio.file.Path | ||
import kotlin.io.path.isDirectory | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
fun Path.toDirectory() = DirectoryPath(this) | ||
|
||
@Serializable(with = DirectoryPath.Companion::class) | ||
class DirectoryPath(path: Path) : Path by path { | ||
init { | ||
require(path.isDirectory()) { "Path $path is not a directory" } | ||
} | ||
|
||
companion object : KSerializer<DirectoryPath> { | ||
override val descriptor: SerialDescriptor | ||
get() = NioPathSerializer.descriptor | ||
|
||
override fun deserialize(decoder: Decoder): DirectoryPath = | ||
NioPathSerializer.deserialize(decoder).toDirectory() | ||
|
||
override fun serialize(encoder: Encoder, value: DirectoryPath) { | ||
NioPathSerializer.serialize(encoder, value) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters