55 */
66package org .mapstruct .intellij .inspection ;
77
8+ import java .util .Set ;
9+
810import com .intellij .codeInspection .LocalQuickFixOnPsiElement ;
911import com .intellij .codeInspection .ProblemsHolder ;
1012import com .intellij .codeInspection .util .IntentionFamilyName ;
2325import org .mapstruct .intellij .util .MapStructVersion ;
2426import org .mapstruct .intellij .util .MapstructUtil ;
2527
26- import java .util .Set ;
27-
2828import static com .intellij .psi .PsiElementFactory .getInstance ;
2929import static org .mapstruct .intellij .util .MapstructUtil .getSourceParameters ;
3030import static org .mapstruct .intellij .util .SourceUtils .findAllDefinedMappingSources ;
@@ -63,21 +63,21 @@ private MyJavaElementVisitor(ProblemsHolder holder, MapStructVersion mapStructVe
6363 public void visitMethod (@ NotNull PsiMethod method ) {
6464 super .visitMethod ( method );
6565
66- if (!MapstructUtil .isMapper ( method .getContainingClass () ) ) {
66+ if ( !MapstructUtil .isMapper ( method .getContainingClass () ) ) {
6767 return ;
6868 }
6969
7070 PsiType targetType = getTargetType ( method );
71- if (targetType == null ) {
71+ if ( targetType == null ) {
7272 return ;
7373 }
7474
7575 PsiParameter fromMapMappingParameter = getFromMapMappingParameter ( method );
76- if (fromMapMappingParameter == null ) {
76+ if ( fromMapMappingParameter == null ) {
7777 return ;
7878 }
7979 PsiType [] parameters = getGenericTypes ( fromMapMappingParameter );
80- if (parameters == null ) {
80+ if ( parameters == null ) {
8181 return ;
8282 }
8383 Set <String > allTargetProperties = findAllTargetProperties (
@@ -93,13 +93,13 @@ public void visitMethod(@NotNull PsiMethod method) {
9393 .anyMatch ( source -> fromMapMappingParameter .getName ().equals ( source ) ) ) {
9494 return ;
9595 }
96- if (parameters .length == 0 ) {
96+ if ( parameters .length == 0 ) {
9797 // handle raw type
9898 holder .registerProblem ( fromMapMappingParameter ,
9999 MapStructBundle .message ( "inspection.wrong.map.mapping.map.type.raw" ),
100100 new ReplaceByStringStringMapTypeFix ( fromMapMappingParameter ) );
101101 }
102- else if (parameters .length == 2 ) {
102+ else if ( parameters .length == 2 ) {
103103 // only if both parameters of the map are set
104104 PsiType keyParameter = parameters [0 ];
105105 if ( !keyParameter .equalsToText ( "java.lang.String" ) ) {
@@ -114,9 +114,9 @@ else if (parameters.length == 2) {
114114 @ Nullable
115115 private static PsiParameter getFromMapMappingParameter (@ NotNull PsiMethod method ) {
116116 PsiParameter [] sourceParameters = getSourceParameters ( method );
117- if (sourceParameters .length == 1 ) {
117+ if ( sourceParameters .length == 1 ) {
118118 PsiParameter parameter = sourceParameters [0 ];
119- if (parameter != null && PsiType .getTypeByName ( "java.util.Map" , method .getProject (),
119+ if ( parameter != null && PsiType .getTypeByName ( "java.util.Map" , method .getProject (),
120120 method .getResolveScope () ).isAssignableFrom ( parameter .getType () ) ) {
121121 return parameter ;
122122 }
@@ -142,10 +142,10 @@ private ReplaceByStringStringMapTypeFix(@NotNull PsiParameter element) {
142142 @ Override
143143 public boolean isAvailable (@ NotNull Project project , @ NotNull PsiFile file ,
144144 @ NotNull PsiElement startElement , @ NotNull PsiElement endElement ) {
145- if (!super .isAvailable ( project , file , startElement , endElement ) ) {
145+ if ( !super .isAvailable ( project , file , startElement , endElement ) ) {
146146 return false ;
147147 }
148- if (startElement instanceof PsiParameter parameter ) {
148+ if ( startElement instanceof PsiParameter parameter ) {
149149 PsiType [] parameters = getGenericTypes ( parameter );
150150 return parameters != null && parameters .length == 0 ;
151151 }
@@ -155,7 +155,7 @@ public boolean isAvailable(@NotNull Project project, @NotNull PsiFile file,
155155 @ Override
156156 public void invoke (@ NotNull Project project , @ NotNull PsiFile psiFile , @ NotNull PsiElement psiElement ,
157157 @ NotNull PsiElement psiElement1 ) {
158- if (psiElement instanceof PsiParameter ) {
158+ if ( psiElement instanceof PsiParameter ) {
159159 String mapText = psiElement .getText ();
160160 String prefix = mapText .substring ( 0 , mapText .indexOf ( ' ' ) );
161161 String end = mapText .substring ( mapText .lastIndexOf ( ' ' ) );
@@ -187,12 +187,12 @@ private ReplaceMapKeyByStringTypeFix(@NotNull PsiParameter element) {
187187 @ Override
188188 public boolean isAvailable (@ NotNull Project project , @ NotNull PsiFile file ,
189189 @ NotNull PsiElement startElement , @ NotNull PsiElement endElement ) {
190- if (!super .isAvailable ( project , file , startElement , endElement ) ) {
190+ if ( !super .isAvailable ( project , file , startElement , endElement ) ) {
191191 return false ;
192192 }
193- if (startElement instanceof PsiParameter parameter ) {
193+ if ( startElement instanceof PsiParameter parameter ) {
194194 PsiType [] parameters = getGenericTypes ( parameter );
195- if (parameters == null || parameters .length != 2 ) {
195+ if ( parameters == null || parameters .length != 2 ) {
196196 return false ;
197197 }
198198 return !parameters [0 ].equalsToText ( "java.lang.String" );
@@ -203,7 +203,7 @@ public boolean isAvailable(@NotNull Project project, @NotNull PsiFile file,
203203 @ Override
204204 public void invoke (@ NotNull Project project , @ NotNull PsiFile psiFile , @ NotNull PsiElement psiElement ,
205205 @ NotNull PsiElement psiElement1 ) {
206- if (psiElement instanceof PsiParameter ) {
206+ if ( psiElement instanceof PsiParameter ) {
207207 String mapText = psiElement .getText ();
208208 String prefix = mapText .substring ( 0 , mapText .indexOf ( '<' ) + 1 );
209209 String end = mapText .substring ( mapText .indexOf ( ',' ) );
0 commit comments