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

[IJ Plugin] Play nice with IDEs without Kotlin/Gradle #6358

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import com.apollographql.ijplugin.settings.ProjectSettingsService
import com.apollographql.ijplugin.studio.fieldinsights.FieldInsightsService
import com.apollographql.ijplugin.studio.sandbox.SandboxService
import com.apollographql.ijplugin.telemetry.TelemetryService
import com.apollographql.ijplugin.util.isGradlePluginPresent
import com.apollographql.ijplugin.util.isKotlinPluginPresent
import com.apollographql.ijplugin.util.isLspAvailable
import com.apollographql.ijplugin.util.logd
import com.intellij.openapi.components.service
Expand All @@ -23,15 +25,18 @@ internal class ApolloProjectManagerListener : ProjectManagerListener {

// Initialize all services on project open.
// But wait for 'smart mode' to do it.
// Most of these services can't operate without the Kotlin and Gradle plugins (e.g. in RustRover).
DumbService.getInstance(project).runWhenSmart {
logd("apolloVersion=" + project.apolloProjectService.apolloVersion)
project.service<ApolloCodegenService>()
project.service<GraphQLConfigService>()
project.service<GradleToolingModelService>()
project.service<ProjectSettingsService>()
project.service<SandboxService>()
project.service<FieldInsightsService>()
project.service<TelemetryService>()
if (isKotlinPluginPresent && isGradlePluginPresent) {
project.service<ApolloCodegenService>()
project.service<GraphQLConfigService>()
project.service<GradleToolingModelService>()
project.service<ProjectSettingsService>()
project.service<SandboxService>()
project.service<FieldInsightsService>()
project.service<TelemetryService>()
}
if (isLspAvailable) {
project.service<ApolloLspProjectService>()
application.service<ApolloLspAppService>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.apollographql.ijplugin.settings
import com.apollographql.ijplugin.ApolloBundle
import com.apollographql.ijplugin.project.apolloProjectService
import com.apollographql.ijplugin.settings.studio.ApiKeyDialog
import com.apollographql.ijplugin.util.isGradlePluginPresent
import com.apollographql.ijplugin.util.isKotlinPluginPresent
import com.intellij.openapi.observable.properties.PropertyGraph
import com.intellij.openapi.project.Project
import com.intellij.ui.AddEditRemovePanel
Expand Down Expand Up @@ -32,21 +34,22 @@ class SettingsComponent(private val project: Project) {
private var addEditRemovePanel: AddEditRemovePanel<ApolloKotlinServiceConfiguration>? = null

val panel: JPanel = panel {
// Some options are irrelevant without the Kotlin or Gradle plugins (e.g. in RustRover).
group(ApolloBundle.message("settings.codegen.title")) {
row {
chkAutomaticCodegenTriggering = checkBox(ApolloBundle.message("settings.codegen.automaticCodegenTriggering.text"))
.comment(ApolloBundle.message("settings.codegen.automaticCodegenTriggering.comment"))
.bindSelected(automaticCodegenTriggeringProperty)
.component
}
}
}.visible(isKotlinPluginPresent && isGradlePluginPresent)
group(ApolloBundle.message("settings.graphqlPlugin.title")) {
row {
checkBox(ApolloBundle.message("settings.graphqlPlugin.contributeConfigurationToGraphqlPlugin.text"))
.comment(ApolloBundle.message("settings.graphqlPlugin.contributeConfigurationToGraphqlPlugin.comment"))
.bindSelected(contributeConfigurationToGraphqlPluginProperty)
}
}
}.visible(isKotlinPluginPresent && isGradlePluginPresent)
group(ApolloBundle.message("settings.studio.title")) {
if (!project.apolloProjectService.apolloVersion.isAtLeastV4) {
row { label(ApolloBundle.message("settings.studio.apiKeys.needV4.message")) }
Expand Down Expand Up @@ -98,7 +101,7 @@ class SettingsComponent(private val project: Project) {
.comment(ApolloBundle.message("settings.studio.apiKeys.comment"))
}
}
}
}.visible(isKotlinPluginPresent && isGradlePluginPresent)

group(ApolloBundle.message("settings.telemetry.telemetryEnabled.title")) {
row {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ val isAndroidPluginPresent = runCatching { Class.forName("com.android.ddmlib.And
val isJavaPluginPresent = runCatching { Class.forName("com.intellij.psi.PsiJavaFile") }.isSuccess

val isKotlinPluginPresent = runCatching { Class.forName("org.jetbrains.kotlin.psi.KtFile") }.isSuccess

val isGradlePluginPresent = runCatching { Class.forName("org.jetbrains.plugins.gradle.util.GradleConstants") }.isSuccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<idea-plugin>
<!-- Add here declarations that only work in presence of the Gradle plugin -->

<extensions defaultExtensionNs="com.intellij">
<!-- Listen to Gradle sync -->
<externalSystemTaskNotificationListener implementation="com.apollographql.ijplugin.gradle.GradleListener" />

</extensions>
</idea-plugin>
Loading
Loading