File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/main/java/org/mapstruct/intellij/inspection Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 7
7
8
8
import java .lang .reflect .InvocationTargetException ;
9
9
import java .lang .reflect .Method ;
10
+ import java .util .ArrayList ;
11
+ import java .util .Collection ;
10
12
11
13
import com .intellij .codeInsight .AnnotationUtil ;
12
14
import com .intellij .codeInsight .daemon .impl .quickfix .RemoveUnusedVariableFix ;
@@ -100,15 +102,22 @@ public void visitMethodCallExpression(PsiMethodCallExpression expression) {
100
102
PsiClass mapperClass = (PsiClass ) mapperElement ;
101
103
PsiAnnotation mapperAnnotation = mapperClass .getAnnotation ( MapstructUtil .MAPPER_ANNOTATION_FQN );
102
104
if ( mapperAnnotation == null ) {
103
- problemsHolder .registerProblem (
104
- expression ,
105
- MapStructBundle .message ( "inspection.wrong.usage.mappers.factory.non.mapstruct" ),
105
+ Collection <LocalQuickFix > fixes = new ArrayList <>( 2 );
106
+ fixes .add (
106
107
new AddAnnotationPsiFix (
107
108
MapstructUtil .MAPPER_ANNOTATION_FQN ,
108
109
mapperClass ,
109
110
PsiNameValuePair .EMPTY_ARRAY
110
- ),
111
- createRemoveMappersFix ( expression )
111
+ )
112
+ );
113
+ LocalQuickFix removeMappersFix = createRemoveMappersFix ( expression );
114
+ if ( removeMappersFix != null ) {
115
+ fixes .add ( removeMappersFix );
116
+ }
117
+ problemsHolder .registerProblem (
118
+ expression ,
119
+ MapStructBundle .message ( "inspection.wrong.usage.mappers.factory.non.mapstruct" ),
120
+ fixes .toArray ( LocalQuickFix []::new )
112
121
);
113
122
}
114
123
else {
You can’t perform that action at this time.
0 commit comments