8
8
import com .intellij .codeInspection .LocalInspectionTool ;
9
9
import com .intellij .codeInspection .ProblemHighlightType ;
10
10
import com .intellij .codeInspection .ProblemsHolder ;
11
- import com .intellij .lang .jsgraphql .psi .GraphQLArgument ;
12
- import com .intellij .lang .jsgraphql .psi .GraphQLArguments ;
13
- import com .intellij .psi .PsiElement ;
14
- import com .intellij .psi .PsiElementVisitor ;
11
+ import com .intellij .lang .jsgraphql .psi .GraphQLValue ;
12
+ import com .intellij .lang .jsgraphql .psi .GraphQLVisitor ;
15
13
import com .jetbrains .php .lang .psi .elements .PhpClass ;
16
14
import com .magento .idea .magento2plugin .util .GetPhpClassByFQN ;
17
15
import com .magento .idea .magento2plugin .util .magento .graphql .GraphQlUtil ;
@@ -23,43 +21,25 @@ public class SchemaResolverInspection extends LocalInspectionTool {
23
21
24
22
@ NotNull
25
23
@ Override
26
- public PsiElementVisitor buildVisitor (@ NotNull final ProblemsHolder holder , boolean isOnTheFly ) {
27
- return new PsiElementVisitor () {
24
+ public GraphQLVisitor buildVisitor (@ NotNull final ProblemsHolder holder , boolean isOnTheFly ) {
25
+ return new GraphQLVisitor () {
28
26
@ Override
29
- public void visitElement (PsiElement element ) {
30
- PsiElement [] directiveChildren = element .getChildren ();
31
-
32
- for (PsiElement directiveChild : directiveChildren ) {
33
- if (!(directiveChild instanceof GraphQLArguments )) {
34
- continue ;
35
- }
36
-
37
- PsiElement [] argumentsChildren = directiveChild .getChildren ();
38
- for (PsiElement argumentsChild : argumentsChildren ) {
39
- if (!(argumentsChild instanceof GraphQLArgument )) {
40
- continue ;
41
- }
42
-
43
- PsiElement argumentStringValue = GraphQlUtil .fetchResolverQuotedStringFromArgument (argumentsChild );
44
- if (argumentStringValue == null ) continue ;
45
-
46
- String resolverFQN = argumentStringValue .getText ();
47
- if (resolverFQN == null ) {
48
- continue ;
49
- }
27
+ public void visitValue (@ NotNull GraphQLValue element ) {
28
+ String getVisitedElementValue = element .getText ();
29
+ if (getVisitedElementValue == null ) {
30
+ return ;
31
+ }
50
32
51
- resolverFQN = GraphQlUtil .resolverStringToPhpFQN (resolverFQN );
52
- GetPhpClassByFQN getPhpClassByFQN = GetPhpClassByFQN .getInstance (holder .getProject ());
53
- PhpClass resolverClass = getPhpClassByFQN .execute (resolverFQN );
54
- if (resolverClass == null ) {
55
- continue ;
56
- }
57
- if (GraphQlUtil .isNotResolver (resolverClass )) {
58
- holder .registerProblem (argumentStringValue ,
59
- GraphQlResolverProblemDescription ,
60
- ProblemHighlightType .ERROR );
61
- }
62
- }
33
+ String resolverFQN = GraphQlUtil .resolverStringToPhpFQN (getVisitedElementValue );
34
+ GetPhpClassByFQN getPhpClassByFQN = GetPhpClassByFQN .getInstance (holder .getProject ());
35
+ PhpClass resolverClass = getPhpClassByFQN .execute (resolverFQN );
36
+ if (resolverClass == null ) {
37
+ return ;
38
+ }
39
+ if (GraphQlUtil .isNotResolver (resolverClass )) {
40
+ holder .registerProblem (element ,
41
+ GraphQlResolverProblemDescription ,
42
+ ProblemHighlightType .ERROR );
63
43
}
64
44
}
65
45
};
0 commit comments