Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Jun 15, 2024
1 parent 5b2d0a6 commit b83a526
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ private void AnalyzeOperation(OperationAnalysisContext context)
if (type.RemoveNullableIfPresent() is not { SpecialType: SpecialType.System_Boolean })
return default;

// If the switch already has a default case, then we don't have to offer the user anything.
if (HasDefaultCase(operation))
return default;

// Doesn't have a default. We don't want to offer that if they're already complete.
var hasAllCases = HasConstantCase(operation, true) && HasConstantCase(operation, false);
if (type.IsNullable())
hasAllCases = hasAllCases && HasConstantCase(operation, null);

return (missingCases: !hasAllCases, missingDefaultCase: false);
// If the switch already has a default case or already has all cases, then we don't have to offer the user anything.
if (HasDefaultCase(operation) || hasAllCases)
return default;

return (missingCases: true, missingDefaultCase: true);
}

private (bool missingCases, bool missingDefaultCase) AnalyzeEnumSwitch(TSwitchOperation operation, ITypeSymbol type)
Expand All @@ -121,9 +121,7 @@ private void AnalyzeOperation(OperationAnalysisContext context)

var missingEnumMembers = GetMissingEnumMembers(operation);

var missingCases = missingEnumMembers.Count > 0;
var missingDefaultCase = !HasDefaultCase(operation);
return (missingCases, missingDefaultCase);
return (missingCases: missingEnumMembers.Count > 0, missingDefaultCase: !HasDefaultCase(operation));
}

protected static bool ConstantValueEquals(Optional<object?> constantValue, object? value)
Expand Down

0 comments on commit b83a526

Please sign in to comment.