From 81fd763cf36b8c0815d85e706576012fd273d61b Mon Sep 17 00:00:00 2001 From: Jessie Jacobs Date: Tue, 19 Nov 2024 16:49:41 -0800 Subject: [PATCH 1/4] Fix compatibility with new 243 jsgraphql version --- build.gradle.kts | 2 +- gradle.properties | 12 ++++++------ .../internal/GraphQLSchemaRegistry.java | 17 +++++++++-------- .../plugin/hints/DgsInputArgumentInspector.kt | 3 ++- .../DgsInputArgumentValidationInspector.kt | 3 ++- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 304db1f..3fbcad7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ plugins { // Kotlin support id("org.jetbrains.kotlin.jvm") version "2.0.21" // Gradle IntelliJ Plugin - id("org.jetbrains.intellij.platform") version "2.0.1" + id("org.jetbrains.intellij.platform") version "2.1.0" // Gradle Changelog Plugin id("org.jetbrains.changelog") version "2.2.1" diff --git a/gradle.properties b/gradle.properties index 046ffce..c3e05d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,27 +19,27 @@ pluginGroup = com.netflix.graphql.dgs pluginName = DGS -pluginVersion = 1.4.2 +pluginVersion = 1.4.3 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild=242.1 +pluginSinceBuild=243 # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. -pluginVerifierIdeVersions = 2024.2.1 +pluginVerifierIdeVersions = 2024.3 platformType = IU -platformVersion = 2024.2.1 +platformVersion = 2024.3 platformDownloadSources = true # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = com.intellij.lang.jsgraphql:242.20224.155 +platformPlugins = com.intellij.lang.jsgraphql:243.21565.122 platformBundledPlugins = com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle # Java language level used to compile sources and to generate the files for - Java 17 is required since 2023.1 -javaVersion = 17 +javaVersion = 21 gradleVersion = 8.10.2 diff --git a/src/main/java/com/netflix/dgs/plugin/services/internal/GraphQLSchemaRegistry.java b/src/main/java/com/netflix/dgs/plugin/services/internal/GraphQLSchemaRegistry.java index 7d220b6..f4d4213 100644 --- a/src/main/java/com/netflix/dgs/plugin/services/internal/GraphQLSchemaRegistry.java +++ b/src/main/java/com/netflix/dgs/plugin/services/internal/GraphQLSchemaRegistry.java @@ -16,7 +16,8 @@ package com.netflix.dgs.plugin.services.internal; -import com.intellij.lang.jsgraphql.schema.GraphQLRegistryProvider; +import com.intellij.lang.jsgraphql.schema.GraphQLSchemaProvider; +import com.intellij.lang.jsgraphql.schema.GraphQLTypeDefinitionUtil; import com.intellij.lang.jsgraphql.types.language.*; import com.intellij.lang.jsgraphql.types.schema.idl.TypeDefinitionRegistry; import com.intellij.openapi.project.Project; @@ -45,19 +46,19 @@ Optional psiForSchemaType(@NotNull PsiElement psiElement, @Nullable Optional schemaField = objectTypes.stream().map(ObjectTypeDefinition::getFieldDefinitions).flatMap(Collection::stream) .filter(e -> e.getName().equals(field)).findAny(); if (schemaField.isPresent()) { - return Optional.ofNullable(schemaField.get().getSourceLocation().getElement()); + return Optional.ofNullable(GraphQLTypeDefinitionUtil.findElement(schemaField.get().getSourceLocation(), psiElement.getProject())).map(PsiElement::getParent); } } else if ("_entities".equals(parentType)) { Optional entitiesType = getTypeDefinition(registry, field); if (entitiesType.isPresent()) { - return Optional.ofNullable(entitiesType.get().getElement()); + return Optional.ofNullable(GraphQLTypeDefinitionUtil.findElement(entitiesType.get().getSourceLocation(), psiElement.getProject())); } } else { Optional interfaceType = getInterfaceTypeDefinition(registry, parentType); if (interfaceType.isPresent()) { Optional schemaField = interfaceType.get().getFieldDefinitions().stream().filter(f -> f.getName().equals(field)).findAny(); if (schemaField.isPresent()) { - return Optional.ofNullable(schemaField.get().getSourceLocation().getElement()); + return Optional.ofNullable(GraphQLTypeDefinitionUtil.findElement(schemaField.get().getSourceLocation(), psiElement.getProject())); } } } @@ -68,14 +69,14 @@ Optional psiForSchemaType(@NotNull PsiElement psiElement, @Nullable public Optional psiForDirective(@NotNull PsiElement psiElement, @NotNull String name) { TypeDefinitionRegistry registry = getRegistry(psiElement); Optional directiveDefinition = registry.getDirectiveDefinition(name); - return directiveDefinition.map(AbstractNode::getElement); + return directiveDefinition.map(definition -> GraphQLTypeDefinitionUtil.findElement(definition.getSourceLocation(), psiElement.getProject())); } public Optional psiForScalar(@NotNull PsiElement psiElement, @NotNull String name) { TypeDefinitionRegistry registry = getRegistry(psiElement); ScalarTypeDefinition scalarTypeDefinition = registry.scalars().get(name); if (scalarTypeDefinition != null) { - return Optional.ofNullable(scalarTypeDefinition.getElement()); + return Optional.ofNullable(GraphQLTypeDefinitionUtil.findElement(scalarTypeDefinition.getSourceLocation(), psiElement.getProject())); } else { return Optional.empty(); } @@ -120,7 +121,7 @@ private Optional getInterfaceTypeDefinition(TypeDefinit } private TypeDefinitionRegistry getRegistry(@NotNull PsiElement psiElement) { - return GraphQLRegistryProvider.getInstance(project) - .getRegistryInfo(psiElement).getTypeDefinitionRegistry(); + return GraphQLSchemaProvider.getInstance(project) + .getSchemaInfo(psiElement).getRegistry(); } } \ No newline at end of file diff --git a/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentInspector.kt b/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentInspector.kt index a2dbd68..f2d21e9 100644 --- a/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentInspector.kt +++ b/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentInspector.kt @@ -19,6 +19,7 @@ package com.netflix.dgs.plugin.hints import com.intellij.codeInspection.* import com.intellij.lang.jsgraphql.psi.impl.GraphQLFieldDefinitionImpl import com.intellij.lang.jsgraphql.schema.GraphQLRegistryProvider +import com.intellij.lang.jsgraphql.schema.GraphQLSchemaProvider import com.intellij.openapi.project.Project import com.intellij.psi.* import com.intellij.psi.util.parentOfType @@ -44,7 +45,7 @@ class DgsInputArgumentInspector : AbstractBaseUastLocalInspectionTool() { if (InputArgumentUtils.hasDgsAnnotation(node) ) { val dgsDataAnnotation = InputArgumentUtils.getDgsAnnotation(node) val dgsService = dgsDataAnnotation.project.getService(DgsService::class.java) - val typeDefinitionRegistry = GraphQLRegistryProvider.getInstance(dgsDataAnnotation.project).getRegistryInfo(node.navigationElement).typeDefinitionRegistry + val typeDefinitionRegistry = GraphQLSchemaProvider.getInstance(dgsDataAnnotation.project).getSchemaInfo(node.javaPsi).registry val dgsDataFetcher = dgsService.dgsComponentIndex.dataFetchers.find { it.psiAnnotation.toUElement() == dgsDataAnnotation.toUElement() } if (dgsDataFetcher?.schemaPsi != null) { diff --git a/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentValidationInspector.kt b/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentValidationInspector.kt index 7f2fa4f..f18f017 100644 --- a/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentValidationInspector.kt +++ b/src/main/kotlin/com/netflix/dgs/plugin/hints/DgsInputArgumentValidationInspector.kt @@ -21,6 +21,7 @@ import com.intellij.lang.jsgraphql.psi.GraphQLInputValueDefinition import com.intellij.lang.jsgraphql.psi.impl.GraphQLFieldDefinitionImpl import com.intellij.lang.jsgraphql.psi.impl.GraphQLIdentifierImpl import com.intellij.lang.jsgraphql.schema.GraphQLRegistryProvider +import com.intellij.lang.jsgraphql.schema.GraphQLSchemaProvider import com.intellij.lang.jsgraphql.types.schema.idl.TypeDefinitionRegistry import com.intellij.lang.jvm.annotation.JvmAnnotationConstantValue import com.intellij.openapi.project.Project @@ -47,7 +48,7 @@ class DgsInputArgumentValidationInspector : AbstractBaseUastLocalInspectionTool( if (InputArgumentUtils.hasDgsAnnotation(node) ) { val dgsDataAnnotation = InputArgumentUtils.getDgsAnnotation(node) val dgsService = dgsDataAnnotation.project.getService(DgsService::class.java) - val typeDefinitionRegistry = GraphQLRegistryProvider.getInstance(dgsDataAnnotation.project).getRegistryInfo(node.navigationElement).typeDefinitionRegistry + val typeDefinitionRegistry = GraphQLSchemaProvider.getInstance(dgsDataAnnotation.project).getSchemaInfo(node.javaPsi).registry val dgsDataFetcher = dgsService.dgsComponentIndex.dataFetchers.find { it.psiAnnotation.toUElement() == dgsDataAnnotation.toUElement() } if (dgsDataFetcher?.schemaPsi != null) { From d33fde6ac56b6e3a5ff8f1707f4f9fded53e4cdb Mon Sep 17 00:00:00 2001 From: Jessie Jacobs Date: Thu, 21 Nov 2024 16:25:23 -0800 Subject: [PATCH 2/4] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 544977f..67bcb18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ # dgs-intellij-plugin Changelog ## [Unreleased] +## [1.4.3] +### Fixed +* Fix loading of navigation markers for IntelliJ 2024.3 ## [1.4.2] ### Fixed From af0781951964d49c1366da0db89c3dff304b1d92 Mon Sep 17 00:00:00 2001 From: Jessie Jacobs Date: Thu, 21 Nov 2024 16:43:40 -0800 Subject: [PATCH 3/4] Update jdk for CI --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/run-ui-tests.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7138984..c0a326d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Set environment variables @@ -106,7 +106,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Set environment variables diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 919a1dc..cd3dbec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Publish the plugin to the Marketplace diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml index 796dc2f..3b71ee8 100644 --- a/.github/workflows/run-ui-tests.yml +++ b/.github/workflows/run-ui-tests.yml @@ -40,7 +40,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: zulu - java-version: 17 + java-version: 21 cache: gradle # Run IDEA prepared for UI testing From 18c9c13f435eab96726d83d7acd89796408862e0 Mon Sep 17 00:00:00 2001 From: Jessie Jacobs Date: Thu, 21 Nov 2024 18:43:09 -0800 Subject: [PATCH 4/4] Cleanup comments and upgrade gradle --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index c3e05d8..0431bf9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,10 +38,10 @@ platformDownloadSources = true platformPlugins = com.intellij.lang.jsgraphql:243.21565.122 platformBundledPlugins = com.intellij.java, org.jetbrains.kotlin, com.intellij.gradle -# Java language level used to compile sources and to generate the files for - Java 17 is required since 2023.1 +# Java language level used to compile sources and to generate the files for - https://plugins.jetbrains.com/docs/intellij/api-changes-list-2023.html javaVersion = 21 -gradleVersion = 8.10.2 +gradleVersion = 8.11.1 # Opt-out flag for bundling Kotlin standard library. # See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.