java redundant cast: cleanup: simplify warning registering

GitOrigin-RevId: c04868bf236d1750cec6cc7546e1e3ea840a7d25
This commit is contained in:
Anna Kozlova
2020-05-11 08:33:17 +00:00
committed by intellij-monorepo-bot
parent 3871a0fca2
commit 8ddeb3ec76
@@ -76,10 +76,8 @@ public class RedundantCastUtil {
}
@Override
protected void addToResults(@NotNull PsiTypeCastExpression typeCast) {
if (!isTypeCastSemantic(typeCast)) {
myFoundCasts.add(typeCast);
}
protected void registerCast(@NotNull PsiTypeCastExpression typeCast) {
myFoundCasts.add(typeCast);
}
}
@@ -87,13 +85,17 @@ public class RedundantCastUtil {
private static class MyIsRedundantVisitor extends JavaRecursiveElementWalkingVisitor {
private PsiTypeCastExpression foundRedundantCast;
protected void addToResults(@NotNull PsiTypeCastExpression typeCast){
private void addToResults(@NotNull PsiTypeCastExpression typeCast){
if (!isTypeCastSemantic(typeCast)) {
foundRedundantCast = typeCast;
stopWalking();
registerCast(typeCast);
}
}
protected void registerCast(@NotNull PsiTypeCastExpression typeCast) {
foundRedundantCast = typeCast;
stopWalking();
}
@Override public void visitAssignmentExpression(PsiAssignmentExpression expression) {
processPossibleTypeCast(expression.getRExpression(), expression.getLExpression().getType());
super.visitAssignmentExpression(expression);