public override void VisitCatchClause(CatchClause catchClause) { base.VisitCatchClause(catchClause); var exceptionResolveResult = ctx.Resolve(catchClause.VariableNameToken) as LocalResolveResult; if (exceptionResolveResult == null) { return; } var catchVisitor = new CatchClauseVisitor(ctx, exceptionResolveResult.Variable); catchClause.Body.AcceptVisitor(catchVisitor); foreach (var throwStatement in catchVisitor.OffendingThrows) { var localThrowStatement = throwStatement; var title = ctx.TranslateString("The exception is rethrown with explicit usage of the variable"); var action = new CodeAction(ctx.TranslateString("Change to 'throw;'"), script => { script.Replace(localThrowStatement, new ThrowStatement()); }, catchClause); AddDiagnosticAnalyzer(new CodeIssue(localThrowStatement, title, action)); } }
public override void VisitCatchClause(CatchClause catchClause) { base.VisitCatchClause(catchClause); var exceptionResolveResult = ctx.Resolve(catchClause.VariableNameToken) as LocalResolveResult; if (exceptionResolveResult == null) return; var catchVisitor = new CatchClauseVisitor(ctx, exceptionResolveResult.Variable); catchClause.Body.AcceptVisitor(catchVisitor); foreach (var throwStatement in catchVisitor.OffendingThrows) { var localThrowStatement = throwStatement; var title = ctx.TranslateString("The exception is rethrown with explicit usage of the variable"); var action = new CodeAction(ctx.TranslateString("Change to 'throw;'"), script => { script.Replace(localThrowStatement, new ThrowStatement()); }); AddIssue(localThrowStatement, title, new [] { action }); } }