Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Mar 10, 2024
1 parent 444ebd7 commit 7f894ae
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;

import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableFix;
Expand Down Expand Up @@ -100,15 +102,22 @@ public void visitMethodCallExpression(PsiMethodCallExpression expression) {
PsiClass mapperClass = (PsiClass) mapperElement;
PsiAnnotation mapperAnnotation = mapperClass.getAnnotation( MapstructUtil.MAPPER_ANNOTATION_FQN );
if ( mapperAnnotation == null ) {
problemsHolder.registerProblem(
expression,
MapStructBundle.message( "inspection.wrong.usage.mappers.factory.non.mapstruct" ),
Collection<LocalQuickFix> fixes = new ArrayList<>( 2 );
fixes.add(
new AddAnnotationPsiFix(
MapstructUtil.MAPPER_ANNOTATION_FQN,
mapperClass,
PsiNameValuePair.EMPTY_ARRAY
),
createRemoveMappersFix( expression )
)
);
LocalQuickFix removeMappersFix = createRemoveMappersFix( expression );
if ( removeMappersFix != null ) {
fixes.add( removeMappersFix );
}
problemsHolder.registerProblem(
expression,
MapStructBundle.message( "inspection.wrong.usage.mappers.factory.non.mapstruct" ),
fixes.toArray( LocalQuickFix[]::new )
);
}
else {
Expand Down

0 comments on commit 7f894ae

Please sign in to comment.