private static bool RequiresInnerExceptionPassing(ThrowExpressionModel throwExpressionModel) { if (!throwExpressionModel.IsDirectExceptionInstantiation) { return(false); } if (throwExpressionModel.IsRethrow) { return(false); } var outerCatchClause = throwExpressionModel.FindOuterCatchClause(); if (outerCatchClause == null) { return(false); } if (!outerCatchClause.IsExceptionTypeSpecified) { return(true); } if (!outerCatchClause.HasVariable) { return(true); } return(!throwExpressionModel.IsInnerExceptionPassed(outerCatchClause.Variable.VariableName.Name)); }
/// <summary>Performs analyze of throw <paramref name="throwExpression"/>.</summary> /// <param name="throwExpression">Throw statement model to analyze.</param> public override void Visit(ThrowExpressionModel throwExpression) { if (throwExpression != null && RequiresInnerExceptionPassing(throwExpression)) { var highlighting = new ThrowFromCatchWithNoInnerExceptionHighlighting(throwExpression); ServiceLocator.StageProcess.AddHighlighting(highlighting, throwExpression.DocumentRange); } }
/// <summary>Initializes a new instance of the <see cref="ThrowFromCatchWithNoInnerExceptionHighlighting"/> class. </summary> /// <param name="throwExpression">The throw expression. </param> internal ThrowFromCatchWithNoInnerExceptionHighlighting(ThrowExpressionModel throwExpression) { ThrowExpression = throwExpression; }
/// <summary>Performs analyze of throw <paramref name="throwExpression"/>.</summary> /// <param name="throwExpression">Throw expression model to analyze.</param> public virtual void Visit(ThrowExpressionModel throwExpression) { }