Skip to content

Commit c731c8c

Browse files
committed
Fixed compatibility with 211, split schema validation to a separate annotator
1 parent 374dbf8 commit c731c8c

File tree

10 files changed

+431
-363
lines changed

10 files changed

+431
-363
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pluginGroup = com.intellij.lang.jsgraphql
77
pluginName = JS GraphQL
88
pluginVersion = 2.7.0
99
pluginSinceBuild = 192.7142
10-
pluginUntilBuild = 203.*
10+
pluginUntilBuild = 211.*
1111

1212
platformType = IU
1313
platformVersion = IU-LATEST-EAP-SNAPSHOT

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<lang.syntaxHighlighterFactory language="GraphQL" implementationClass="com.intellij.lang.jsgraphql.ide.GraphQLSyntaxHighlighterFactory"/>
8080
<annotator language="GraphQL" implementationClass="com.intellij.lang.jsgraphql.ide.GraphQLSyntaxAnnotator" />
8181
<annotator language="GraphQL" implementationClass="com.intellij.lang.jsgraphql.ide.GraphQLValidationAnnotator" />
82+
<annotator language="GraphQL" implementationClass="com.intellij.lang.jsgraphql.ide.GraphQLSchemaValidationAnnotator" />
8283
<colorSettingsPage implementation="com.intellij.lang.jsgraphql.ide.GraphQLColorSettingsPage"/>
8384

8485
<!-- Formatting and folding -->

src/main/com/intellij/lang/jsgraphql/ide/GraphQLRelayModernAnnotationFilter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ public static GraphQLRelayModernAnnotationFilter getService(@NotNull Project pro
3434

3535

3636
public boolean errorIsIgnored(PsiElement errorPsiElement) {
37-
if (settings.isEnableRelayModernFrameworkSupport()) {
38-
final GraphQLArguments graphQLArguments = PsiTreeUtil.getParentOfType(errorPsiElement, GraphQLArguments.class);
39-
if (graphQLArguments != null) {
40-
final GraphQLDirective directive = PsiTreeUtil.getParentOfType(errorPsiElement, GraphQLDirective.class);
41-
if (directive != null) {
42-
final String directiveName = directive.getName();
43-
if ("argumentDefinitions".equals(directiveName) || "arguments".equals(directiveName)) {
44-
// ignore errors inside on the dynamically named arguments to @argumentDefinitions and @arguments
45-
// since the SDL can express this dynamic aspect
46-
return true;
47-
}
48-
}
37+
if (!settings.isEnableRelayModernFrameworkSupport()) {
38+
return false;
39+
}
40+
41+
final GraphQLArguments graphQLArguments = PsiTreeUtil.getParentOfType(errorPsiElement, GraphQLArguments.class);
42+
if (graphQLArguments != null) {
43+
final GraphQLDirective directive = PsiTreeUtil.getParentOfType(errorPsiElement, GraphQLDirective.class);
44+
if (directive != null) {
45+
final String directiveName = directive.getName();
46+
// ignore errors inside on the dynamically named arguments to @argumentDefinitions and @arguments
47+
// since the SDL can express this dynamic aspect
48+
return "argumentDefinitions".equals(directiveName) || "arguments".equals(directiveName);
4949
}
5050
}
5151
return false;

src/main/com/intellij/lang/jsgraphql/ide/GraphQLSchemaValidationAnnotator.java

Lines changed: 370 additions & 0 deletions
Large diffs are not rendered by default.

src/main/com/intellij/lang/jsgraphql/ide/GraphQLSyntaxAnnotator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ public void visitFieldDefinition(@NotNull GraphQLFieldDefinition fieldDefinition
8787

8888
@Override
8989
public void visitInputValueDefinition(@NotNull GraphQLInputValueDefinition element) {
90-
9190
// first reset the bold font display from keywords such as input/type being used as field name
92-
Annotation annotation = holder.createInfoAnnotation(element.getNameIdentifier(), null);
93-
annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
91+
resetAttributes(element.getNameIdentifier(), holder);
9492

9593
final GraphQLArgumentsDefinition arguments = PsiTreeUtil.getParentOfType(element, GraphQLArgumentsDefinition.class);
9694
if (arguments != null) {
@@ -104,10 +102,8 @@ public void visitInputValueDefinition(@NotNull GraphQLInputValueDefinition eleme
104102

105103
@Override
106104
public void visitArgument(@NotNull GraphQLArgument argument) {
107-
108105
// first reset the bold font display from keywords such as input/type being used as argument name
109-
Annotation annotation = holder.createInfoAnnotation(argument.getNameIdentifier(), null);
110-
annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
106+
resetAttributes(argument.getNameIdentifier(), holder);
111107

112108
// then apply argument font style
113109
applyTextAttributes(argument.getNameIdentifier(), ARGUMENT);
@@ -150,8 +146,7 @@ public void visitDirective(@NotNull GraphQLDirective directive) {
150146
@Override
151147
public void visitObjectField(@NotNull GraphQLObjectField objectField) {
152148
// first reset the bold font display from keywords such as input/type being used as object field name
153-
Annotation annotation = holder.createInfoAnnotation(objectField.getNameIdentifier(), null);
154-
annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
149+
resetAttributes(objectField.getNameIdentifier(), holder);
155150

156151
// then apply argument font style
157152
applyTextAttributes(objectField.getNameIdentifier(), ARGUMENT);
@@ -164,4 +159,9 @@ private void applyTextAttributes(@Nullable PsiElement element, @NotNull TextAttr
164159
}
165160
});
166161
}
162+
163+
private void resetAttributes(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
164+
Annotation annotation = holder.createInfoAnnotation(element, null);
165+
annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
166+
}
167167
}

0 commit comments

Comments
 (0)