Skip to content

Commit

Permalink
Removed DirectoryPath class and replaced with SerializablePath
Browse files Browse the repository at this point in the history
The DirectoryPath class was deleted and all its usages were replaced by SerializablePath. This change is part of an effort to simplify the codebase by reducing redundancy and making serialization more straightforward. No functionality was compromised in this update.
  • Loading branch information
lamba92 committed May 23, 2024
1 parent 824896b commit 3a67d07
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package com.jetbrains.packagesearch.plugin.core.data

import com.jetbrains.packagesearch.plugin.core.utils.DirectoryPath
import com.jetbrains.packagesearch.plugin.core.utils.SerializablePath
import java.nio.file.Path
import kotlinx.serialization.Serializable
import org.jetbrains.packagesearch.api.v3.search.PackagesType
Expand Down Expand Up @@ -46,6 +46,6 @@ sealed interface PackageSearchModule : IconProvider, PackageSearchModuleEditor {
data class Identity(
val group: String,
val path: String,
val projectDir: DirectoryPath,
val projectDir: SerializablePath,
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.jetbrains.packagesearch.plugin.core.utils

import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
Expand All @@ -20,3 +20,5 @@ object NioPathSerializer : KSerializer<Path> {
}

}

typealias SerializablePath = @Serializable(with = NioPathSerializer::class) Path
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import com.intellij.openapi.module.Module
import com.jetbrains.packagesearch.plugin.core.PackageSearch
import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule
import com.jetbrains.packagesearch.plugin.core.extensions.PackageSearchModuleBuilderContext
import com.jetbrains.packagesearch.plugin.core.utils.toDirectory
import com.jetbrains.packagesearch.plugin.gradle.utils.getDeclaredDependencies
import com.jetbrains.packagesearch.plugin.gradle.utils.toGradle
import kotlinx.coroutines.flow.FlowCollector
import org.jetbrains.packagesearch.api.v3.ApiMavenRepository
import org.jetbrains.packagesearch.api.v3.search.androidPackages
import org.jetbrains.packagesearch.api.v3.search.buildPackageTypes
import org.jetbrains.packagesearch.api.v3.search.jvmGradlePackages
import org.jetbrains.packagesearch.packageversionutils.normalization.NormalizedVersion

class GradleModuleProvider : AbstractGradleModuleProvider() {

Expand Down Expand Up @@ -42,7 +40,7 @@ class GradleModuleProvider : AbstractGradleModuleProvider() {
identity = PackageSearchModule.Identity(
group = "gradle",
path = model.projectIdentityPath.fixBuildSrc(model),
projectDir = model.projectDir.toDirectory(),
projectDir = model.projectDir,
),
buildFilePath = model.buildFilePath,
declaredRepositories = model.declaredRepositories.toGradle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.intellij.packageSearch.mppDependencyUpdater.resolved.MppCompilationIn
import com.jetbrains.packagesearch.plugin.core.PackageSearch
import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule
import com.jetbrains.packagesearch.plugin.core.extensions.PackageSearchModuleBuilderContext
import com.jetbrains.packagesearch.plugin.core.utils.toDirectory
import com.jetbrains.packagesearch.plugin.gradle.utils.toGradle
import kotlinx.coroutines.flow.FlowCollector

Expand All @@ -33,7 +32,7 @@ class KotlinMultiplatformModuleProvider : AbstractGradleModuleProvider() {
identity = PackageSearchModule.Identity(
group = "gradle",
path = model.projectIdentityPath,
projectDir = model.projectDir.toDirectory(),
projectDir = model.projectDir,
),
buildFilePath = model.buildFilePath,
declaredRepositories = model.declaredRepositories.toGradle(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.jetbrains.packagesearch.plugin.gradle

import com.intellij.openapi.externalSystem.model.Key
import com.jetbrains.packagesearch.plugin.core.utils.NioPathSerializer
import java.nio.file.Path
import com.jetbrains.packagesearch.plugin.core.utils.SerializablePath
import kotlinx.serialization.Serializable

@Serializable
data class PackageSearchGradleModel(
@Serializable(with = NioPathSerializer::class) val projectDir: Path,
val projectDir: SerializablePath,
val configurations: List<Configuration>,
val declaredRepositories: List<DeclaredRepository>,
val isJavaApplied: Boolean,
Expand All @@ -17,8 +16,8 @@ data class PackageSearchGradleModel(
val projectIdentityPath: String,
val projectName: String,
val rootProjectName: String,
@Serializable(with = NioPathSerializer::class) val buildFilePath: Path?,
@Serializable(with = NioPathSerializer::class) val rootProjectPath: Path,
val buildFilePath: SerializablePath?,
val rootProjectPath: SerializablePath,
val gradleVersion: String,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.jetbrains.packagesearch.plugin.core.utils.icon
import com.jetbrains.packagesearch.plugin.core.utils.isSameFileAsSafe
import com.jetbrains.packagesearch.plugin.core.utils.mapUnit
import com.jetbrains.packagesearch.plugin.core.utils.smartModeFlow
import com.jetbrains.packagesearch.plugin.core.utils.toDirectory
import com.jetbrains.packagesearch.plugin.core.utils.watchExternalFileChanges
import java.io.File
import java.nio.file.Path
Expand Down Expand Up @@ -114,7 +113,7 @@ suspend fun Module.toPackageSearch(
identity = PackageSearchModule.Identity(
group = "maven",
path = ":",
projectDir = pomPath.parent.toDirectory(),
projectDir = pomPath.parent,
),
buildFilePath = pomPath,
declaredRepositories = getDeclaredRepositories(),
Expand Down

0 comments on commit 3a67d07

Please sign in to comment.