diff --git a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/project/ApolloProjectManagerListener.kt b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/project/ApolloProjectManagerListener.kt index 831ba6ecc7d..3ba45f6ead4 100644 --- a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/project/ApolloProjectManagerListener.kt +++ b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/project/ApolloProjectManagerListener.kt @@ -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 @@ -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() - project.service() - project.service() - project.service() - project.service() - project.service() - project.service() + if (isKotlinPluginPresent && isGradlePluginPresent) { + project.service() + project.service() + project.service() + project.service() + project.service() + project.service() + project.service() + } if (isLspAvailable) { project.service() application.service() diff --git a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/settings/SettingsComponent.kt b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/settings/SettingsComponent.kt index 35f08a46af8..2c7c265f314 100644 --- a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/settings/SettingsComponent.kt +++ b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/settings/SettingsComponent.kt @@ -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 @@ -32,6 +34,7 @@ class SettingsComponent(private val project: Project) { private var addEditRemovePanel: AddEditRemovePanel? = 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")) @@ -39,14 +42,14 @@ class SettingsComponent(private val project: Project) { .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")) } @@ -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 { diff --git a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/util/Environment.kt b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/util/Environment.kt index 0b9a033c4f8..eac89549cae 100644 --- a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/util/Environment.kt +++ b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/util/Environment.kt @@ -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 diff --git a/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-gradle.xml b/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-gradle.xml new file mode 100644 index 00000000000..42baca1cd04 --- /dev/null +++ b/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-gradle.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-kotlin.xml b/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-kotlin.xml index f362e9f8a45..7b72a27815c 100644 --- a/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-kotlin.xml +++ b/intellij-plugin/src/main/resources/META-INF/com.apollographql.ijplugin-kotlin.xml @@ -1,3 +1,336 @@ - + + + messages.ApolloBundle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + kotlin + com.apollographql.ijplugin.intention.ApolloInputConstructorChangeToBuilderIntention + + Apollo Kotlin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/intellij-plugin/src/main/resources/META-INF/plugin.xml b/intellij-plugin/src/main/resources/META-INF/plugin.xml index fa53b83ed2a..3e4f21ce686 100644 --- a/intellij-plugin/src/main/resources/META-INF/plugin.xml +++ b/intellij-plugin/src/main/resources/META-INF/plugin.xml @@ -10,7 +10,7 @@ com.intellij.modules.platform com.intellij.modules.java org.jetbrains.kotlin - com.intellij.gradle + com.intellij.gradle com.intellij.lang.jsgraphql org.toml.lang com.intellij.modules.json @@ -37,28 +37,6 @@ nonDefaultProject="true" /> - - - - - - - - - - - - - - - - - - - @@ -69,127 +47,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - kotlin - com.apollographql.ijplugin.intention.ApolloInputConstructorChangeToBuilderIntention - - Apollo Kotlin - - - - - - - - - - + - - + + - + @@ -318,15 +127,6 @@ - - - - - - @@ -349,34 +149,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/intellij-plugin/src/main/resources/inspectionDescriptions/Apollo4AvailableKotlin.html b/intellij-plugin/src/main/resources/inspectionDescriptions/Apollo4AvailableKotlin.html new file mode 100644 index 00000000000..192587234a5 --- /dev/null +++ b/intellij-plugin/src/main/resources/inspectionDescriptions/Apollo4AvailableKotlin.html @@ -0,0 +1,5 @@ + + +Suggests to migrate to Apollo Kotlin 4 on projects using an older version. + + diff --git a/intellij-plugin/src/main/resources/inspectionDescriptions/ApolloGraphQLConfigFilePresent.html b/intellij-plugin/src/main/resources/inspectionDescriptions/ApolloGraphQLConfigFilePresentYaml.html similarity index 94% rename from intellij-plugin/src/main/resources/inspectionDescriptions/ApolloGraphQLConfigFilePresent.html rename to intellij-plugin/src/main/resources/inspectionDescriptions/ApolloGraphQLConfigFilePresentYaml.html index 0a6bf4ada3a..3374826b82f 100644 --- a/intellij-plugin/src/main/resources/inspectionDescriptions/ApolloGraphQLConfigFilePresent.html +++ b/intellij-plugin/src/main/resources/inspectionDescriptions/ApolloGraphQLConfigFilePresentYaml.html @@ -9,7 +9,8 @@ Note: the Apollo plugin uses the Gradle tooling API to retrieve the project's GraphQL configuration.

- More information + More + information