|
25 | 25 | import com.intellij.lang.jsgraphql.psi.*; |
26 | 26 | import com.intellij.lang.jsgraphql.psi.impl.GraphQLDescriptionAware; |
27 | 27 | import com.intellij.lang.jsgraphql.psi.impl.GraphQLDirectivesAware; |
28 | | -import com.intellij.lang.jsgraphql.schema.GraphQLSchemaWithErrors; |
29 | | -import com.intellij.lang.jsgraphql.schema.GraphQLTypeDefinitionRegistryServiceImpl; |
| 28 | +import com.intellij.lang.jsgraphql.schema.GraphQLSchemaProvider; |
30 | 29 | import com.intellij.lang.jsgraphql.schema.GraphQLTypeScopeProvider; |
| 30 | +import com.intellij.lang.jsgraphql.schema.GraphQLValidatedSchema; |
31 | 31 | import com.intellij.lang.jsgraphql.utils.GraphQLUtil; |
32 | 32 | import com.intellij.openapi.components.ServiceManager; |
33 | 33 | import com.intellij.openapi.editor.Editor; |
@@ -151,12 +151,12 @@ public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder a |
151 | 151 | if (!fixes.isEmpty()) { |
152 | 152 | final InspectionManager inspectionManager = InspectionManager.getInstance(psiElement.getProject()); |
153 | 153 | final ProblemDescriptor problemDescriptor = inspectionManager.createProblemDescriptor( |
154 | | - psiElement, |
155 | | - psiElement, |
156 | | - message, |
157 | | - ProblemHighlightType.ERROR, |
158 | | - true, |
159 | | - LocalQuickFix.EMPTY_ARRAY |
| 154 | + psiElement, |
| 155 | + psiElement, |
| 156 | + message, |
| 157 | + ProblemHighlightType.ERROR, |
| 158 | + true, |
| 159 | + LocalQuickFix.EMPTY_ARRAY |
160 | 160 | ); |
161 | 161 | fixes.forEach(fix -> annotation.get().registerFix(fix, null, null, problemDescriptor)); |
162 | 162 | } |
@@ -192,20 +192,20 @@ public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder a |
192 | 192 | if (userData == null) { |
193 | 193 |
|
194 | 194 | try { |
195 | | - final GraphQLSchemaWithErrors schema = GraphQLTypeDefinitionRegistryServiceImpl.getService(project).getSchemaWithErrors(psiElement); |
| 195 | + final GraphQLValidatedSchema schema = GraphQLSchemaProvider.getInstance(project).getValidatedSchema(psiElement); |
196 | 196 | if (!schema.isErrorsPresent()) { |
197 | 197 | // adjust source locations for injected GraphQL since the annotator works on the entire editor buffer (e.g. tsx with graphql tagged templates) |
198 | 198 | int lineDelta = 0; |
199 | | - int firsteLineColumDelta = 0; |
| 199 | + int firstLineColumnDelta = 0; |
200 | 200 | if (containingFile.getContext() != null) { |
201 | 201 | final LogicalPosition logicalPosition = getLogicalPositionFromOffset(containingFile, containingFile.getContext().getTextOffset()); |
202 | 202 | if (logicalPosition.line > 0 || logicalPosition.column > 0) { |
203 | 203 | // logical positions can be used as deltas between graphql-java and intellij since graphql-java is 1-based and intellij is 0-based |
204 | 204 | lineDelta = logicalPosition.line; |
205 | | - firsteLineColumDelta = logicalPosition.column; |
| 205 | + firstLineColumnDelta = logicalPosition.column; |
206 | 206 | } |
207 | 207 | } |
208 | | - final Document document = GraphQLUtil.parseDocument(replacePlaceholdersWithValidGraphQL(containingFile), lineDelta, firsteLineColumDelta); |
| 208 | + final Document document = GraphQLUtil.parseDocument(replacePlaceholdersWithValidGraphQL(containingFile), lineDelta, firstLineColumnDelta); |
209 | 209 | userData = new Validator().validateDocument(schema.getSchema(), document); |
210 | 210 | } else { |
211 | 211 | final String currentFileName = GraphQLPsiUtil.getFileName(containingFile); |
@@ -314,7 +314,7 @@ public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder a |
314 | 314 | continue; |
315 | 315 | } |
316 | 316 | } |
317 | | - if(validationErrorType == ValidationErrorType.SubSelectionRequired) { |
| 317 | + if (validationErrorType == ValidationErrorType.SubSelectionRequired) { |
318 | 318 | // apollo client 2.5 doesn't require sub selections for client fields |
319 | 319 | final GraphQLDirectivesAware directivesAware = PsiTreeUtil.getParentOfType(errorPsiElement, GraphQLDirectivesAware.class); |
320 | 320 | if (directivesAware != null) { |
@@ -352,8 +352,8 @@ public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder a |
352 | 352 | */ |
353 | 353 | boolean isInsideTemplateElement(PsiElement psiElement) { |
354 | 354 | return PsiTreeUtil.findFirstParent( |
355 | | - psiElement, false, |
356 | | - el -> el instanceof GraphQLTemplateDefinition || el instanceof GraphQLTemplateSelection || el instanceof GraphQLTemplateVariable |
| 355 | + psiElement, false, |
| 356 | + el -> el instanceof GraphQLTemplateDefinition || el instanceof GraphQLTemplateSelection || el instanceof GraphQLTemplateVariable |
357 | 357 | ) != null; |
358 | 358 | } |
359 | 359 |
|
@@ -435,7 +435,9 @@ public void visitElement(PsiElement element) { |
435 | 435 | return buffer.toString(); |
436 | 436 | } |
437 | 437 |
|
438 | | - private Optional<Annotation> createErrorAnnotation(@NotNull AnnotationHolder annotationHolder, PsiElement errorPsiElement, String message) { |
| 438 | + private Optional<Annotation> createErrorAnnotation(@NotNull AnnotationHolder annotationHolder, |
| 439 | + PsiElement errorPsiElement, |
| 440 | + String message) { |
439 | 441 | if (GraphQLRelayModernAnnotationFilter.getService(errorPsiElement.getProject()).errorIsIgnored(errorPsiElement)) { |
440 | 442 | return Optional.empty(); |
441 | 443 | } |
@@ -514,10 +516,10 @@ private List<String> getFieldNameSuggestions(String fieldName, graphql.schema.Gr |
514 | 516 | @NotNull |
515 | 517 | private List<String> getSuggestions(String text, List<String> candidates) { |
516 | 518 | return candidates.stream() |
517 | | - .map(suggestion -> new Pair<>(suggestion, EditDistance.optimalAlignment(text, suggestion, false))) |
518 | | - .filter(p -> p.second <= 2) |
519 | | - .sorted(Comparator.comparingInt(p -> p.second)) |
520 | | - .map(p -> p.first).collect(Collectors.toList()); |
| 519 | + .map(suggestion -> new Pair<>(suggestion, EditDistance.optimalAlignment(text, suggestion, false))) |
| 520 | + .filter(p -> p.second <= 2) |
| 521 | + .sorted(Comparator.comparingInt(p -> p.second)) |
| 522 | + .map(p -> p.first).collect(Collectors.toList()); |
521 | 523 |
|
522 | 524 | } |
523 | 525 |
|
|
0 commit comments