@@ -59,6 +59,18 @@ public JSGraphQLAnnotationResult collectInformation(@NotNull PsiFile file, @NotN
59
59
if (buffer .length () > 0 ) {
60
60
final String environment = JSGraphQLLanguageInjectionUtil .getEnvironment (file );
61
61
final AnnotationsResponse annotations = JSGraphQLNodeLanguageServiceClient .getAnnotations (buffer .toString (), file .getProject (), environment );
62
+ if (annotations != null ) {
63
+ for (Annotation annotation : annotations .getAnnotations ()) {
64
+ LogicalPosition from = getLogicalPosition (annotation .getFrom ());
65
+ int fromOffset = editor .logicalPositionToOffset (from );
66
+ final PsiElement errorElement = getPsiElementAtErrorOffset (file , fromOffset );
67
+ if (errorElement instanceof JSGraphQLErrorContextAware ) {
68
+ final String message = StringUtils .substringBefore (annotation .getMessage (), "\n " );
69
+ final JSGraphQLErrorContextAware errorContextAware = (JSGraphQLErrorContextAware ) errorElement ;
70
+ annotation .setErrorInContext (errorContextAware .isErrorInContext (message ));
71
+ }
72
+ }
73
+ }
62
74
return new JSGraphQLAnnotationResult (annotations , editor );
63
75
}
64
76
} else if (file instanceof JSGraphQLSchemaFile ) {
@@ -108,19 +120,16 @@ public void visitElement(PsiElement element) {
108
120
return ;
109
121
}
110
122
for (Annotation annotation : annotationsReponse .getAnnotations ()) {
123
+ if (!annotation .isErrorInContext ()) {
124
+ continue ;
125
+ }
111
126
LogicalPosition from = getLogicalPosition (annotation .getFrom ());
112
127
LogicalPosition to = getLogicalPosition (annotation .getTo ());
113
128
int fromOffset = editor .logicalPositionToOffset (from );
114
129
int toOffset = editor .logicalPositionToOffset (to );
115
130
HighlightSeverity severity = "error" .equals (annotation .getSeverity ()) ? HighlightSeverity .ERROR : HighlightSeverity .WARNING ;
116
131
if (fromOffset < toOffset ) {
117
132
final String message = StringUtils .substringBefore (annotation .getMessage (), "\n " );
118
- final PsiElement errorElement = getPsiElementAtErrorOffset (file , fromOffset );
119
- if (errorElement instanceof JSGraphQLErrorContextAware ) {
120
- if (!((JSGraphQLErrorContextAware ) errorElement ).isErrorInContext (message )) {
121
- continue ;
122
- }
123
- }
124
133
holder .createAnnotation (severity , TextRange .create (fromOffset , toOffset ), message );
125
134
errors .add (new JSGraphQLErrorResult (message , fileName , annotation .getSeverity (), from .line +1 , from .column +1 )); // +1 is for UI lines/columns
126
135
}
0 commit comments