Skip to content

Commit

Permalink
[IJ plugin] Don't suggest v4 migration until it is stable (#5477)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD committed Dec 15, 2023
1 parent 690ec85 commit 54a1864
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.apollographql.ijplugin.inspection
import com.apollographql.ijplugin.ApolloBundle
import com.apollographql.ijplugin.action.ApolloV3ToV4MigrationAction
import com.apollographql.ijplugin.project.apolloProjectService
import com.apollographql.ijplugin.refactoring.migration.v3tov4.ApolloV3ToV4MigrationProcessor
import com.apollographql.ijplugin.telemetry.TelemetryEvent
import com.apollographql.ijplugin.telemetry.telemetryService
import com.apollographql.ijplugin.util.getMethodName
Expand Down Expand Up @@ -36,11 +37,15 @@ class Apollo4AvailableInspection : LocalInspectionTool() {
// XXX kts files are not highlighted in tests
private val buildGradleFileName = if (isUnitTestMode()) "build.gradle.kt" else "build.gradle.kts"

// Do not warn until 4.0 is stable (but keep enabled always in unit tests)
private val isEnabled = isUnitTestMode() || !ApolloV3ToV4MigrationProcessor.apollo4LatestVersion.contains('-')

override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
return object : PsiElementVisitor() {
private val registeredTomlVersionValues = mutableSetOf<PsiElement>()

override fun visitElement(element: PsiElement) {
if (!isEnabled) return
if (!element.project.apolloProjectService.apolloVersion.isAtLeastV3) return
when {
element.containingFile.name.endsWith(".versions.toml") && element is TomlLiteral -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import com.apollographql.ijplugin.refactoring.migration.v3tov4.item.UpdateThrowA
import com.apollographql.ijplugin.refactoring.migration.v3tov4.item.UpdateWebSocketReconnectWhen
import com.intellij.openapi.project.Project

private const val apollo4LatestVersion = "4.0.0-beta.4"

/**
* Migrations of Apollo Kotlin v3 to v4.
*/
class ApolloV3ToV4MigrationProcessor(project: Project) : ApolloMigrationRefactoringProcessor(project) {
companion object {
const val apollo4LatestVersion = "4.0.0-beta.4"
}

override val refactoringName = ApolloBundle.message("ApolloV3ToV4MigrationProcessor.title")

override val noUsageMessage = ApolloBundle.message("ApolloV3ToV4MigrationProcessor.noUsage")
Expand Down

0 comments on commit 54a1864

Please sign in to comment.