Skip to content

Commit

Permalink
[IJ Plugin] Bump pluginUntilBuild to 242 and pluginSinceBuild to 241 (#…
Browse files Browse the repository at this point in the history
…6111)

* Bump pluginUntilBuild to 242

* Bump pluginSinceBuild to 241 and platformVersion to 2024.1.4

* Fix ApolloGraphQLConfigFilePresentInspectionTest

* Fix indentation discrepancies in test fixtures

* Fix Readme

* Workaround on a reformatting crashing in certain circumstances
  • Loading branch information
BoD authored Aug 14, 2024
1 parent 1808948 commit 98562e7
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 51 deletions.
4 changes: 2 additions & 2 deletions docs/source/testing/android-studio-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ The plugin is available on the JetBrains plugin repository. To install it from t

At the time of writing, the plugin is supported on:

- IntelliJ 2023.2 and above
- Android Studio 2023.2 (Iguana) and above
- IntelliJ 2024.1 and above
- Android Studio 2024.1 (Koala) and above

Please check the [plugin page](https://plugins.jetbrains.com/plugin/20645-apollo-graphql) for up to date information.

Expand Down
4 changes: 2 additions & 2 deletions intellij-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ This plugin for Android Studio and IntelliJ helps you work with the

The plugin is supported on:

- IntelliJ 2023.2 and above
- Android Studio 2023.2 (Iguana) and above
- IntelliJ 2024.1 and above
- Android Studio 2024.1 (Koala) and above

## Installation instructions

Expand Down
18 changes: 9 additions & 9 deletions intellij-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ pluginRepositoryUrl=https://github.com/apollographql/apollo-kotlin
# XXX Do update the supported versions in the README.md, and in docs/source/testing/android-studio-plugin.mdx file when updating these values!
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild=232
# This can be kept empty to mean no upper bound, but it's recommended to set it to whatever was tested
pluginUntilBuild=241.*
pluginSinceBuild=241
# Upper bound: it's mandatory set it, and the plugin must be tested with this version
pluginUntilBuild=242.*
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
# Corresponds to AS Iguana 2023.2.1 -> https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
# Corresponds to AS Koala 2024.1.1 Patch 1 -> https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
# and https://developer.android.com/studio/archive (more up to date)
# See also https://plugins.jetbrains.com/docs/intellij/android-studio.html
platformVersion=2023.2.5

platformVersion=2024.1.4

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
platformBundledPlugins=com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle, org.toml.lang
# To find the version of a plugin relative to the platform version, see the plugin's page on the Marketplace,
# e.g. for the toml plugin: https://plugins.jetbrains.com/plugin/8195-toml/versions/stable
platformBundledPlugins=com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle, org.jetbrains.android, org.toml.lang
platformPlugins=com.intellij.lang.jsgraphql:4.0.2
# e.g. for the GraphQL plugin: https://plugins.jetbrains.com/plugin/8097-graphql/versions/stable
# Note: to run wih AS 2024.1.1, use org.jetbrains.android:241.14494.17
platformPlugins=com.intellij.lang.jsgraphql:241.14494.150, org.jetbrains.android:241.17011.79

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.apollographql.ijplugin.util.lambdaBlockExpression
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiMigration
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
import org.jetbrains.kotlin.psi.KtExpression
Expand All @@ -34,7 +33,7 @@ object EncloseInService : MigrationItem() {
val statements = blockExpression.statements
// If there's already a service call, we can't automatically refactor
if (statements.none { it.isMethodCall("service") }) {
usages.add(blockExpression.toMigrationItemUsageInfo())
usages.add(expression.toMigrationItemUsageInfo())
}
}
}
Expand Down Expand Up @@ -71,20 +70,24 @@ object EncloseInService : MigrationItem() {
}

override fun performRefactoring(project: Project, migration: PsiMigration, usage: MigrationItemUsageInfo) {
val blockExpression = usage.element as KtBlockExpression
val apolloCallExpression = usage.element as KtCallExpression
val blockExpression = apolloCallExpression.lambdaBlockExpression()!!
val nonServiceStatements = blockExpression.statements.filter { !it.isApolloServiceExpression() }
val nonServiceStatementsText = nonServiceStatements.map { it.text }
nonServiceStatements.forEach { it.delete() }
val ktFactory = KtPsiFactory(project)
val newBlockExpression = ktFactory.createEmptyBody()
for (statement in nonServiceStatementsText) {
newBlockExpression.add(ktFactory.createNewLine())
newBlockExpression.add(ktFactory.createExpression(statement))
val replacementExpression = buildString {
append("apollo {\n")
for (it in nonServiceStatementsText) {
append("$it\n")
}
append("service(\"service\") {\n")
append(blockExpression.text)
append("\n}\n")
append("}")
}
newBlockExpression.add(ktFactory.createNewLine())
newBlockExpression.add(ktFactory.createExpression("service(\"service\") {\n${blockExpression.text}\n}"))
newBlockExpression.lBrace?.delete()
newBlockExpression.rBrace?.delete()
blockExpression.replace(newBlockExpression)
val ktFactory = KtPsiFactory(project)
val newApolloCallExpression = ktFactory.createExpression(replacementExpression)
apolloCallExpression.parent.addAfter(newApolloCallExpression, apolloCallExpression)
apolloCallExpression.delete()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.TestDataPath
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
import com.intellij.util.ui.UIUtil
import junit.framework.AssertionFailedError
import org.jetbrains.kotlin.idea.KotlinLanguage
Expand Down Expand Up @@ -60,6 +61,7 @@ abstract class ApolloTestCase : LightJavaCodeInsightFixtureTestCase() {
val codeStyleSettings = CodeStyle.getSettings(project)
val kotlinSettings = codeStyleSettings.getCommonSettings(KotlinLanguage.INSTANCE)
kotlinSettings.indentOptions!!.INDENT_SIZE = 2
kotlinSettings.WRAP_LONG_LINES = false
val graphQLSettings = codeStyleSettings.getCommonSettings(GraphQLLanguage.INSTANCE)
graphQLSettings.indentOptions!!.INDENT_SIZE = 2

Expand Down Expand Up @@ -108,6 +110,7 @@ abstract class ApolloTestCase : LightJavaCodeInsightFixtureTestCase() {

protected fun doHighlighting(): List<HighlightInfo> {
// Hack: sometimes doHighlighting fails with "AssertionError: PSI/document/model changes are not allowed during highlighting"
(myFixture as? CodeInsightTestFixtureImpl)?.canChangeDocumentDuringHighlighting(true)
// Wait a bit for project to settle and try again
return attempt(3) { myFixture.doHighlighting() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ApolloGraphQLConfigFilePresentInspectionTest : ApolloTestCase() {
@Test
fun testGraphqlConfigPresenceError() {
myFixture.configureByFile("graphql.config.yml")
checkHighlighting()
assertTrue(doHighlighting().any { it.description == "The Apollo plugin retrieves the GraphQL configuration from Gradle and doesn't use the GraphQL config file" })
// checkHighlighting()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<warning descr="The Apollo plugin retrieves the GraphQL configuration from Gradle and doesn't use the GraphQL config file" textAttributesKey="WARNING_ATTRIBUTES"><warning descr="The Apollo plugin retrieves the GraphQL configuration from Gradle and doesn't use the GraphQL config file" textAttributesKey="WARNING_ATTRIBUTES">
projects:
main:
schema: src/main/graphql/schema.graphqls
Expand All @@ -7,5 +6,3 @@ projects:
endpoints:
main: "https://apollo-fullstack-tutorial.herokuapp.com/graphql"
apollo-key: ${APOLLO_KEY}

</warning></warning>
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public class FruitListQuery() : Query<FruitListQuery.Data> {
)

public data class List(
public val __typename: String,
public val id: String,
/**
public val __typename: String,
public val id: String,
/**
* Synthetic field for inline fragment on Cherry
*/
public val asCherry: OnCherry?,
/**
/**
* Synthetic field for inline fragment on Apple
*/
public val asApple: OnApple?,
Expand All @@ -51,14 +51,14 @@ public class FruitListQuery() : Query<FruitListQuery.Data> {
)

public data class AsApple(
public val __typename: String,
public val id: String,
public val color: String,
/**
public val __typename: String,
public val id: String,
public val color: String,
/**
* Synthetic field for inline fragment on Golden
*/
public val asGolden: OnGolden?,
/**
/**
* Synthetic field for inline fragment on Granny
*/
public val asGranny: OnGranny?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ enum class CustomType : ScalarType {

suspend fun main() {
val apolloClient = ApolloClient.Builder()
// TODO: Use addCustomScalarAdapter instead. See https://www.apollographql.com/docs/kotlin/migration/3.0/#custom-scalar-adapters
.addCustomTypeAdapter(DateTime.type, DateTimeAdapter())
// TODO: Use addCustomScalarAdapter instead. See https://www.apollographql.com/docs/kotlin/migration/3.0/#custom-scalar-adapters
.addCustomTypeAdapter(Url.type, UrlAdapter())
// TODO: Use addCustomScalarAdapter instead. See https://www.apollographql.com/docs/kotlin/migration/3.0/#custom-scalar-adapters
.addCustomTypeAdapter(DateTime.type, DateTimeAdapter())
// TODO: Use addCustomScalarAdapter instead. See https://www.apollographql.com/docs/kotlin/migration/3.0/#custom-scalar-adapters
.addCustomTypeAdapter(Url.type, UrlAdapter())
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ suspend fun main() {

val cacheFactory1 = MemoryCacheFactory(maxSizeBytes = 10 * 1024 * 1024)
val cacheFactory2 = MemoryCacheFactory(maxSizeBytes = 10 * 1024 * 1024)
val cacheFactory3 = MemoryCacheFactory(maxSizeBytes = 10 * 1024 * 1024, expireAfterMillis = TimeUnit.MILLISECONDS.toMillis(10))
val cacheFactory4 = MemoryCacheFactory(maxSizeBytes = 10 * 1024 * 1024, expireAfterMillis = TimeUnit.MILLISECONDS.toMillis(10))
val cacheFactory3 =
MemoryCacheFactory(maxSizeBytes = 10 * 1024 * 1024, expireAfterMillis = TimeUnit.MILLISECONDS.toMillis(10))
val cacheFactory4 =
MemoryCacheFactory(maxSizeBytes = 10 * 1024 * 1024, expireAfterMillis = TimeUnit.MILLISECONDS.toMillis(10))
val cacheFactory5 = MemoryCacheFactory(expireAfterMillis = TimeUnit.HOURS.toMillis(10))

val apolloClient = ApolloClient.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ dependencies {
apollo {
service("service1") {
packageName.set("com.example.service1")
dependsOn(project(":schema"))
dependsOn(project(":schema"))
}

service("service2") {
packageName.set("com.example.service2")
dependsOn(project(":schema"))
dependsOn(project(":schema"))
}
}


apollo {
service("service") {
packageName.set("com.example.service1")
dependsOn(project(":schema"))
}
service("service") {
packageName.set("com.example.service1")
dependsOn(project(":schema"))
}
}

0 comments on commit 98562e7

Please sign in to comment.