@@ -1254,24 +1254,38 @@ private boolean similar(String target, String hunk, char lineType)
12541254 }
12551255 String [] t = target .split (" " );
12561256 String [] h = hunk .split (" " );
1257- if ( t . length != h . length )
1258- {
1259- return false ;
1260- }
1261- for ( int x = 0 ; x < t .length ; x ++ )
1257+
1258+ //don't check length, changing any modifier to default (removing it) will change length
1259+ int targetIndex = 0 ;
1260+ int hunkIndex = 0 ;
1261+ while ( targetIndex < t . length && hunkIndex < h .length )
12621262 {
1263- if (isAccess (t [x ]) && isAccess (h [x ]))
1263+ boolean isTargetAccess = isAccess (t [targetIndex ]);
1264+ boolean isHunkAccess = isAccess (h [hunkIndex ]);
1265+ if (isTargetAccess || isHunkAccess )
12641266 {
1267+ //Skip access modifiers
1268+ if (isTargetAccess )
1269+ {
1270+ targetIndex ++;
1271+ }
1272+ if (isHunkAccess )
1273+ {
1274+ hunkIndex ++;
1275+ }
12651276 continue ;
12661277 }
1267- else if (!t [x ].equals (h [x ]))
1278+ String hunkPart = h [hunkIndex ];
1279+ String targetPart = t [targetIndex ];
1280+ boolean labels = isLabel (targetPart ) && isLabel (hunkPart );
1281+ if (!labels && !targetPart .equals (hunkPart ))
12681282 {
1269- if (isLabel (t [x ]) && isLabel (h [x ]))
1270- continue ;
12711283 return false ;
12721284 }
1285+ hunkIndex ++;
1286+ targetIndex ++;
12731287 }
1274- return true ;
1288+ return h . length == hunkIndex && t . length == targetIndex ;
12751289 }
12761290 if (c14nWhitespace )
12771291 {
@@ -1287,11 +1301,12 @@ private boolean isAccess(String data)
12871301 {
12881302 return data .equalsIgnoreCase ("public" ) ||
12891303 data .equalsIgnoreCase ("private" ) ||
1290- data .equalsIgnoreCase ("protected" );
1304+ data .equalsIgnoreCase ("protected" ) ||
1305+ data .equalsIgnoreCase ("final" );
12911306 }
12921307
12931308 private boolean isLabel (String data ) //Damn FernFlower
12941309 {
12951310 return data .startsWith ("label" );
12961311 }
1297- }
1312+ }
0 commit comments