Skip to content

Commit

Permalink
Add coroutine support and refactor Gradle module construction
Browse files Browse the repository at this point in the history
Introduced coroutine support in PackageSearchPackageList using `rememberCoroutineScope` and `async`. Refactored GradleModuleProvider to improve clarity by breaking down the construction of PackageSearchGradleModule.
  • Loading branch information
fscarponi committed Oct 23, 2024
1 parent 9d5e81f commit 035dacd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
7 changes: 5 additions & 2 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ dependencies {
intellijIdeaCommunity(INTELLIJ_VERSION)
bundledPlugins(
"org.jetbrains.idea.reposearch",
"com.jetbrains.performancePlugin"
"com.jetbrains.performancePlugin",
)
bundledModule(
"intellij.platform.compose"
)
}

implementation(compose.desktop.currentOs) {
exclude(group = "org.jetbrains.compose.material")
exclude(group = "org.jetbrains.kotlinx")
}
implementation(packageSearchCatalog.jewel.bridge.ij243)
implementation(packageSearchCatalog.jewel.bridge.ij243) //compileonly???
implementation(packageSearchCatalog.kotlinx.serialization.core)
implementation(packageSearchCatalog.compose.desktop.components.splitpane) {
exclude(group = "org.jetbrains.compose.runtime")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,43 @@ class GradleModuleProvider : AbstractGradleModuleProvider() {
val declaredDependencies = model.buildFilePath
?.let { module.getDeclaredDependencies(context) }
?: emptyList()
val packageSearchGradleModule = PackageSearchGradleModule(
name = model.projectName,
identity = PackageSearchModule.Identity(
group = "gradle",
path = model.projectIdentityPath.fixBuildSrc(model),
projectDir = Path(model.projectDir),
),
buildFilePath = model.buildFilePath?.let{Path(it)},
declaredRepositories = model.declaredRepositories.toGradle(context),
val packageTypes = buildPackageTypes {
mavenPackages()
when {
model.isKotlinAndroidApplied -> androidPackages()
model.isJavaApplied -> jvmGradlePackages("jar")
else -> gradlePackages {
isRootPublication = true
}
}
}
val identity = PackageSearchModule.Identity(
group = "gradle",
path = model.projectIdentityPath.fixBuildSrc(model),
projectDir = Path(model.projectDir),
)
val buildFilePath = model.buildFilePath?.let { Path(it) }
val declaredRepositories = model.declaredRepositories.toGradle(context)
val defaultScope = "implementation".takeIf { it in configurationNames } ?: configurationNames.firstOrNull()
val projectName = model.projectName
val packageSearchGradleModule: PackageSearchGradleModule = PackageSearchGradleModule(
name = projectName,
identity = identity,
buildFilePath = buildFilePath,
declaredRepositories = declaredRepositories,
declaredDependencies = declaredDependencies,
availableKnownRepositories = availableKnownRepositories,
packageSearchModel = model,
defaultScope = "implementation".takeIf { it in configurationNames } ?: configurationNames.firstOrNull(),
defaultScope = defaultScope,
availableScopes = configurationNames,
compatiblePackageTypes = buildPackageTypes {
mavenPackages()
when {
model.isKotlinAndroidApplied -> androidPackages()
model.isJavaApplied -> jvmGradlePackages("jar")
else -> gradlePackages {
isRootPublication = true
}
}
},
compatiblePackageTypes = packageTypes,
nativeModule = module,
)
emit(packageSearchGradleModule)
}
}



}

private fun String.fixBuildSrc(model: PackageSearchGradleJavaModel) = when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -32,6 +33,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.intellij.icons.AllIcons
import com.intellij.openapi.externalSystem.service.ui.completion.collector.TextCompletionCollector.Companion.async
import com.jetbrains.packagesearch.plugin.PackageSearchBundle.message
import com.jetbrains.packagesearch.plugin.core.data.IconProvider
import com.jetbrains.packagesearch.plugin.ui.LearnMoreLink
Expand All @@ -49,6 +51,8 @@ import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItemE
import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItemEvent.OnPackageAction.Install
import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItemEvent.OnPackageAction.Remove
import com.jetbrains.packagesearch.plugin.ui.panels.packages.items.PackageListHeader
import kotlinx.coroutines.awaitAll
import org.jetbrains.jewel.foundation.lazy.SelectableLazyColumn
import org.jetbrains.jewel.foundation.lazy.SelectableLazyItemScope
import org.jetbrains.jewel.foundation.lazy.SelectableLazyListState
import org.jetbrains.jewel.foundation.lazy.SelectionMode
Expand All @@ -58,7 +62,6 @@ import org.jetbrains.jewel.ui.component.CircularProgressIndicator
import org.jetbrains.jewel.ui.component.Divider
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.Link
import org.jetbrains.jewel.ui.component.SelectableLazyColumn
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.component.styling.LocalLazyTreeStyle
import org.jetbrains.jewel.ui.icon.PathIconKey
Expand Down

0 comments on commit 035dacd

Please sign in to comment.