Esempio n. 1
0
 public override void VisitEmptyStatement(EmptyStatement emptyStatement)
 {
     if (UseAsAndNullCheckAction.IsEmbeddedStatement(emptyStatement))
     {
         return;
     }
     if (emptyStatement.GetPrevSibling(s => s.Role == BlockStatement.StatementRole) is LabelStatement)
     {
         return;
     }
     AddIssue(new CodeIssue(
                  emptyStatement,
                  ctx.TranslateString("Empty statement is redundant"),
                  ctx.TranslateString("Remove ';'"),
                  s => s.Remove(emptyStatement)
                  )
     {
         IssueMarker = IssueMarker.GrayOut
     });
 }
Esempio n. 2
0
            public override void VisitIfElseStatement(IfElseStatement ifElseStatement)
            {
                base.VisitIfElseStatement(ifElseStatement);

                IsExpression isExpression;
                int          foundCastCount;

                if (UseAsAndNullCheckAction.ScanIfElse(ctx, ifElseStatement, out isExpression, out foundCastCount) == null)
                {
                    return;
                }
                if (foundCastCount == 0)
                {
                    return;
                }

                AddIssue(new CodeIssue(
                             isExpression.IsToken,
                             ctx.TranslateString("Type check and casts can be replaced with 'as' and null check")
                             )
                {
                    ActionProvider = { typeof(UseAsAndNullCheckAction) }
                });
            }