Skip to content

Commit

Permalink
Merge pull request #100 from Netflix/fix/243-breaking-changes
Browse files Browse the repository at this point in the history
Fix loading of schema/datafetcher navigation markers for IntelliJ 2024.3
  • Loading branch information
jjacobs44 authored Nov 22, 2024
2 parents 12a6221 + 18c9c13 commit a056cbe
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle

# Set environment variables
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle

# Set environment variables
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@

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
# 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,19 +46,19 @@ Optional<PsiElement> psiForSchemaType(@NotNull PsiElement psiElement, @Nullable
Optional<FieldDefinition> 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<ObjectTypeDefinition> 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<InterfaceTypeDefinition> interfaceType = getInterfaceTypeDefinition(registry, parentType);
if (interfaceType.isPresent()) {
Optional<FieldDefinition> 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()));
}
}
}
Expand All @@ -68,14 +69,14 @@ Optional<PsiElement> psiForSchemaType(@NotNull PsiElement psiElement, @Nullable
public Optional<PsiElement> psiForDirective(@NotNull PsiElement psiElement, @NotNull String name) {
TypeDefinitionRegistry registry = getRegistry(psiElement);
Optional<DirectiveDefinition> directiveDefinition = registry.getDirectiveDefinition(name);
return directiveDefinition.map(AbstractNode::getElement);
return directiveDefinition.map(definition -> GraphQLTypeDefinitionUtil.findElement(definition.getSourceLocation(), psiElement.getProject()));
}

public Optional<PsiElement> 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();
}
Expand Down Expand Up @@ -120,7 +121,7 @@ private Optional<InterfaceTypeDefinition> getInterfaceTypeDefinition(TypeDefinit
}

private TypeDefinitionRegistry getRegistry(@NotNull PsiElement psiElement) {
return GraphQLRegistryProvider.getInstance(project)
.getRegistryInfo(psiElement).getTypeDefinitionRegistry();
return GraphQLSchemaProvider.getInstance(project)
.getSchemaInfo(psiElement).getRegistry();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit a056cbe

Please sign in to comment.