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] Don't suggest v4 migration until it is stable #5477

Merged
merged 1 commit into from
Dec 15, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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('-')
Comment on lines +40 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for SNAPSHOTs like 4.0.1-SNAPSHOT which is OK if you maintain apollo4LatestVersion manually. Alternative would be using something like https://github.com/swiftzer/semver to do proper semver but that's more involved. Your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep as-is to very slightly (debatable!) err on Bill's razor's side

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍 . Also, who's Bill? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our friend good ol' Bill Occam!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aahh William! Or is he known under 2 names? Which would be quite ironic 🙃


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"
Comment on lines +31 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use com.apollographql.apollo3.compiler.APOLLO_VERSION to have this match the published version automatically without having to bump this every time

}

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

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