public void CombineOr(CasesAndOr cases) { if (cases == null) { throw new ArgumentNullException(nameof(cases)); } CasesAndOr.CombineOr(cases); }
private CasesAndOr ComputeAllCases(INamedTypeSymbol errorType) { var result = new CasesAndOr(); var values = GetAllValues(errorType); foreach (var pair in values) { result.CombineAnd(ComputeAllCases(pair.Key, pair.Value.Values)); } return(result); }
private static CasesAndOr ComputeAllCases(TestedParameter testedParameter, Dictionary <TestedParameter, CriteriaValues> .ValueCollection criteriaValues) { var result = new CasesAndOr(); foreach (var criteriaValue in criteriaValues) { var cases = new CasesAndOr(); foreach (var criterion in criteriaValue.Values) { cases.CombineOr(new CasesAndOr(testedParameter, criterion.Analysis, criterion.IsError)); } result.CombineAnd(cases); } return(result); }
public void CombineAnd(CasesAndOr cases) { if (CasesAnd.Count == 0) { // No criteria yet! // => Take it as it CasesAnd.AddRange(cases.CasesAnd); return; } var currentCriterias = CasesAnd.ToList(); CasesAnd.Clear(); var otherErrors = new HashSet <CasesAnd>(); foreach (var combinedCriterias in currentCriterias) { if (combinedCriterias.HasError) { // Do not combine it CasesAnd.Add(combinedCriterias); continue; } // Combine it foreach (var otherCriterias in cases.CasesAnd) { if (otherCriterias.HasError) { if (otherErrors.Add(otherCriterias)) { // Do not combine it CasesAnd.Add(otherCriterias); } continue; } CasesAnd.Add(combinedCriterias.CombineAnd(otherCriterias)); } } }
public override void VisitInvocationExpression(InvocationExpressionSyntax node) { node.Expression.Accept(this); // Should be a method from XTypeHelper var methodSymbol = _Model.GetSymbol(node) as IMethodSymbol; if (methodSymbol == null) { return; } if (_RangeVisitor != null) { _RangeVisitor.VisitInvocationExpression(node); if (_RangeVisitor.Root == null) { _Case = null; } return; } // Create Root if (!_Roots.TryGetValue(methodSymbol.ContainingType, out var rangeVisitorCreator)) { return; } _RangeVisitor = rangeVisitorCreator(); _RangeVisitor.VisitInvocationExpression(node); if (_RangeVisitor.Root != null) { _Case = new CasesAndOr(_Expression, new TestedParameter(_ParameterName, _ParameterPath), new RangeAnalysis(_RangeVisitor.Root, _IsError || _RangeVisitor.IsError), _IsError || _RangeVisitor.IsError); } }
public void CombineOr(CasesAndOr cases) => CasesAnd.AddRange(cases.CasesAnd);