Skip to content

Commit 5b33dd1

Browse files
committed
Fixed semantic highlighting (#383)
1 parent 3bbd44d commit 5b33dd1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
package com.intellij.lang.jsgraphql.ide.highlighting;
99

10+
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
1011
import com.intellij.lang.annotation.Annotation;
1112
import com.intellij.lang.annotation.AnnotationHolder;
1213
import com.intellij.lang.annotation.Annotator;
@@ -88,7 +89,7 @@ public void visitFieldDefinition(@NotNull GraphQLFieldDefinition fieldDefinition
8889
@Override
8990
public void visitInputValueDefinition(@NotNull GraphQLInputValueDefinition element) {
9091
// first reset the bold font display from keywords such as input/type being used as field name
91-
resetAttributes(element.getNameIdentifier(), holder);
92+
resetAttributes(element.getNameIdentifier());
9293

9394
final GraphQLArgumentsDefinition arguments = PsiTreeUtil.getParentOfType(element, GraphQLArgumentsDefinition.class);
9495
if (arguments != null) {
@@ -103,7 +104,7 @@ public void visitInputValueDefinition(@NotNull GraphQLInputValueDefinition eleme
103104
@Override
104105
public void visitArgument(@NotNull GraphQLArgument argument) {
105106
// first reset the bold font display from keywords such as input/type being used as argument name
106-
resetAttributes(argument.getNameIdentifier(), holder);
107+
resetAttributes(argument.getNameIdentifier());
107108

108109
// then apply argument font style
109110
applyTextAttributes(argument.getNameIdentifier(), ARGUMENT);
@@ -146,22 +147,27 @@ public void visitDirective(@NotNull GraphQLDirective directive) {
146147
@Override
147148
public void visitObjectField(@NotNull GraphQLObjectField objectField) {
148149
// first reset the bold font display from keywords such as input/type being used as object field name
149-
resetAttributes(objectField.getNameIdentifier(), holder);
150+
resetAttributes(objectField.getNameIdentifier());
150151

151152
// then apply argument font style
152153
applyTextAttributes(objectField.getNameIdentifier(), ARGUMENT);
153154
}
154155

155156
private void applyTextAttributes(@Nullable PsiElement element, @NotNull TextAttributesKey attributes) {
156157
if (element == null) return;
157-
Annotation annotation = holder.createInfoAnnotation(element, null);
158+
159+
Annotation annotation =
160+
holder.createAnnotation(HighlightInfoType.SYMBOL_TYPE_SEVERITY, element.getTextRange(), null);
158161
annotation.setTextAttributes(attributes);
159162
}
160-
});
161-
}
162163

163-
private void resetAttributes(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
164-
Annotation annotation = holder.createInfoAnnotation(element, null);
165-
annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
164+
private void resetAttributes(@Nullable PsiElement element) {
165+
if (element == null) return;
166+
167+
Annotation annotation =
168+
holder.createAnnotation(HighlightInfoType.SYMBOL_TYPE_SEVERITY, element.getTextRange(), null);
169+
annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
170+
}
171+
});
166172
}
167173
}

0 commit comments

Comments
 (0)