@@ -452,6 +452,8 @@ enum class SemanticContextKind : uint8_t {
452
452
453
453
// / A declaration imported from other module.
454
454
OtherModule,
455
+
456
+ MAX_VALUE = OtherModule
455
457
};
456
458
457
459
enum class CodeCompletionFlairBit : uint8_t {
@@ -564,6 +566,8 @@ enum class CodeCompletionOperatorKind : uint8_t {
564
566
PipeEq, // |=
565
567
PipePipe, // ||
566
568
TildeEq, // ~=
569
+
570
+ MAX_VALUE = TildeEq
567
571
};
568
572
569
573
enum class CodeCompletionKeywordKind : uint8_t {
@@ -612,12 +616,14 @@ enum class CompletionKind : uint8_t {
612
616
TypeAttrBeginning,
613
617
};
614
618
615
- enum class CodeCompletionDiagnosticSeverity : uint8_t {
619
+ enum class CodeCompletionDiagnosticSeverity : uint8_t {
616
620
None,
617
621
Error,
618
622
Warning,
619
623
Remark,
620
624
Note,
625
+
626
+ MAX_VALUE = Note
621
627
};
622
628
623
629
// / A single code completion result.
@@ -631,6 +637,8 @@ class CodeCompletionResult {
631
637
Pattern,
632
638
Literal,
633
639
BuiltinOperator,
640
+
641
+ MAX_VALUE = BuiltinOperator
634
642
};
635
643
636
644
// / Describes the relationship between the type of the completion results and
@@ -654,6 +662,8 @@ class CodeCompletionResult {
654
662
655
663
// / The result's type is identical to the type of the expected.
656
664
Identical,
665
+
666
+ MAX_VALUE = Identical
657
667
};
658
668
659
669
enum class NotRecommendedReason : uint8_t {
@@ -665,6 +675,8 @@ class CodeCompletionResult {
665
675
InvalidAsyncContext,
666
676
CrossActorReference,
667
677
VariableUsedInOwnDefinition,
678
+
679
+ MAX_VALUE = VariableUsedInOwnDefinition
668
680
};
669
681
670
682
private:
@@ -693,6 +705,14 @@ class CodeCompletionResult {
693
705
CodeCompletionDiagnosticSeverity DiagnosticSeverity : 3 ;
694
706
StringRef DiagnosticMessage;
695
707
708
+ // Assertions for limiting max values of enums.
709
+ static_assert (int (ResultKind::MAX_VALUE) < 1 << 3 , " " );
710
+ static_assert (int (CodeCompletionOperatorKind::MAX_VALUE) < 1 << 6 , " " );
711
+ static_assert (int (SemanticContextKind::MAX_VALUE) < 1 << 3 , " " );
712
+ static_assert (int (NotRecommendedReason::MAX_VALUE) < 1 << 4 , " " );
713
+ static_assert (int (ExpectedTypeRelation::MAX_VALUE) < 1 << 3 , " " );
714
+ static_assert (int (CodeCompletionDiagnosticSeverity::MAX_VALUE) < 1 << 3 , " " );
715
+
696
716
public:
697
717
// / Constructs a \c Pattern, \c Keyword or \c BuiltinOperator result.
698
718
// /
0 commit comments