File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
src/com/magento/idea/magento2plugin/inspections/php Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 12
12
import com .jetbrains .php .lang .inspections .PhpInspection ;
13
13
import com .jetbrains .php .lang .psi .elements .PhpClass ;
14
14
import com .jetbrains .php .lang .psi .visitors .PhpElementVisitor ;
15
+ import com .magento .idea .magento2plugin .inspections .php .fix .PhpImplementResolverClassQuickFix ;
15
16
import com .magento .idea .magento2plugin .util .magento .graphql .GraphQlUsagesCollector ;
16
17
import com .magento .idea .magento2plugin .util .magento .graphql .GraphQlUtil ;
17
18
import org .jetbrains .annotations .NotNull ;
20
21
21
22
public class GraphQlResolverInspection extends PhpInspection {
22
23
24
+ public static final String GraphQlResolverProblemDescription = "Class must implements \\ Magento\\ Framework\\ GraphQl\\ Query\\ ResolverInterface" ;
25
+
23
26
@ NotNull
24
27
@ Override
25
28
public PsiElementVisitor buildVisitor (@ NotNull ProblemsHolder problemsHolder , boolean b ) {
@@ -33,8 +36,9 @@ public void visitPhpClass(PhpClass resolverClass) {
33
36
PsiElement currentClassNameIdentifier = resolverClass .getNameIdentifier ();
34
37
assert currentClassNameIdentifier != null ;
35
38
problemsHolder .registerProblem (currentClassNameIdentifier ,
36
- "Must implements Magento\\ Framework\\ GraphQl\\ Query\\ ResolverInterface" ,
37
- ProblemHighlightType .ERROR );
39
+ GraphQlResolverProblemDescription ,
40
+ ProblemHighlightType .ERROR ,
41
+ new PhpImplementResolverClassQuickFix ());
38
42
}
39
43
}
40
44
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ package com .magento .idea .magento2plugin .inspections .php .fix ;
7
+
8
+ import com .intellij .codeInspection .LocalQuickFix ;
9
+ import com .intellij .codeInspection .ProblemDescriptor ;
10
+ import com .intellij .openapi .project .Project ;
11
+ import com .intellij .psi .PsiElement ;
12
+ import com .jetbrains .php .lang .psi .PhpPsiElementFactory ;
13
+ import com .jetbrains .php .lang .psi .elements .PhpClass ;
14
+ import org .jetbrains .annotations .NotNull ;
15
+
16
+ public class PhpImplementResolverClassQuickFix implements LocalQuickFix {
17
+ @ NotNull
18
+ @ Override
19
+ public String getFamilyName () {
20
+ return "Implements Resolver interface" ;
21
+ }
22
+
23
+ @ Override
24
+ public void applyFix (@ NotNull Project project , @ NotNull ProblemDescriptor descriptor ) {
25
+ PsiElement correctInterface = PhpPsiElementFactory .createImplementsList (project , "\\ Magento\\ Framework\\ GraphQl\\ Query\\ ResolverInterface" );
26
+ PhpClass GraphQlResolverclass = (PhpClass ) descriptor .getPsiElement ().getParent ();
27
+ GraphQlResolverclass .getImplementsList ().replace (correctInterface );
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments