1212import com .intellij .lang .jsgraphql .psi .GraphQLVisitor ;
1313import com .jetbrains .php .lang .psi .elements .PhpClass ;
1414import com .magento .idea .magento2plugin .bundles .InspectionBundle ;
15+ import com .magento .idea .magento2plugin .inspections .graphqls .fix .CreateResolverClassQuickFix ;
1516import com .magento .idea .magento2plugin .util .GetPhpClassByFQN ;
1617import com .magento .idea .magento2plugin .util .magento .graphql .GraphQlUtil ;
1718import org .jetbrains .annotations .NotNull ;
@@ -22,32 +23,39 @@ public class SchemaResolverInspection extends LocalInspectionTool {
2223
2324 @ NotNull
2425 @ Override
25- public GraphQLVisitor buildVisitor (@ NotNull final ProblemsHolder holder , boolean isOnTheFly ) {
26+ public GraphQLVisitor buildVisitor (
27+ @ NotNull final ProblemsHolder holder ,
28+ final boolean isOnTheFly
29+ ) {
2630 return new GraphQLVisitor () {
2731 @ Override
28- public void visitValue (@ NotNull GraphQLValue element ) {
29- String getVisitedElementValue = element .getText ();
32+ public void visitValue (@ NotNull final GraphQLValue element ) {
33+ final String getVisitedElementValue = element .getText ();
3034 if (getVisitedElementValue == null ) {
3135 return ;
3236 }
3337
34- String resolverFQN = GraphQlUtil .resolverStringToPhpFQN (getVisitedElementValue );
35- GetPhpClassByFQN getPhpClassByFQN = GetPhpClassByFQN .getInstance (holder .getProject ());
36- PhpClass resolverClass = getPhpClassByFQN .execute (resolverFQN );
38+ final String resolverFQN
39+ = GraphQlUtil .resolverStringToPhpFQN (getVisitedElementValue );
40+ final GetPhpClassByFQN getPhpClassByFQN
41+ = GetPhpClassByFQN .getInstance (holder .getProject ());
42+ final PhpClass resolverClass = getPhpClassByFQN .execute (resolverFQN );
3743 if (resolverClass == null ) {
38- holder .registerProblem (element ,
39- inspectionBundle .message (
40- "inspection.graphql.resolver.notExist"
41- ),
42- ProblemHighlightType .ERROR );
43- return ;
44- }
45- if (!GraphQlUtil .isResolver (resolverClass )) {
46- holder .registerProblem (element ,
47- inspectionBundle .message (
48- "inspection.graphql.resolver.mustImplement"
49- ),
50- ProblemHighlightType .ERROR );
44+ holder .registerProblem (
45+ element ,
46+ inspectionBundle .message (
47+ "inspection.graphql.resolver.notExist"
48+ ),
49+ ProblemHighlightType .ERROR ,
50+ new CreateResolverClassQuickFix ());
51+ } else if (!GraphQlUtil .isResolver (resolverClass )) {
52+ holder .registerProblem (
53+ element ,
54+ inspectionBundle .message (
55+ "inspection.graphql.resolver.mustImplement"
56+ ),
57+ ProblemHighlightType .ERROR
58+ );
5159 }
5260 }
5361 };
0 commit comments