@@ -630,21 +630,36 @@ enum class CodeCompletionDiagnosticSeverity : uint8_t {
630
630
MAX_VALUE = Note
631
631
};
632
632
633
+ // / Reasons why a code completion item might not be recommended in a certain
634
+ // / context.
635
+ enum class NotRecommendedReason : uint8_t {
636
+ None = 0 , // both contextual and context-free
637
+ RedundantImport, // contextual
638
+ RedundantImportIndirect, // contextual
639
+ Deprecated, // context-free
640
+ SoftDeprecated, // context-free
641
+ InvalidAsyncContext, // contextual
642
+ CrossActorReference, // contextual
643
+ VariableUsedInOwnDefinition, // contextual
644
+
645
+ MAX_VALUE = VariableUsedInOwnDefinition
646
+ };
647
+
648
+ enum class CodeCompletionResultKind : uint8_t {
649
+ Declaration,
650
+ Keyword,
651
+ Pattern,
652
+ Literal,
653
+ BuiltinOperator,
654
+
655
+ MAX_VALUE = BuiltinOperator
656
+ };
657
+
633
658
// / A single code completion result.
634
659
class CodeCompletionResult {
635
660
friend class CodeCompletionResultBuilder ;
636
661
637
662
public:
638
- enum class ResultKind : uint8_t {
639
- Declaration,
640
- Keyword,
641
- Pattern,
642
- Literal,
643
- BuiltinOperator,
644
-
645
- MAX_VALUE = BuiltinOperator
646
- };
647
-
648
663
// / Describes the relationship between the type of the completion results and
649
664
// / the expected type at the code completion position.
650
665
enum class ExpectedTypeRelation : uint8_t {
@@ -670,21 +685,9 @@ class CodeCompletionResult {
670
685
MAX_VALUE = Identical
671
686
};
672
687
673
- enum class NotRecommendedReason : uint8_t {
674
- None = 0 ,
675
- RedundantImport,
676
- RedundantImportIndirect,
677
- Deprecated,
678
- SoftDeprecated,
679
- InvalidAsyncContext,
680
- CrossActorReference,
681
- VariableUsedInOwnDefinition,
682
-
683
- MAX_VALUE = VariableUsedInOwnDefinition
684
- };
685
688
686
689
private:
687
- ResultKind Kind : 3 ;
690
+ CodeCompletionResultKind Kind : 3 ;
688
691
unsigned AssociatedKind : 8 ;
689
692
CodeCompletionOperatorKind KnownOperatorKind : 6 ;
690
693
SemanticContextKind SemanticContext : 3 ;
@@ -710,7 +713,7 @@ class CodeCompletionResult {
710
713
StringRef DiagnosticMessage;
711
714
712
715
// Assertions for limiting max values of enums.
713
- static_assert (int (ResultKind ::MAX_VALUE) < 1 << 3 , " " );
716
+ static_assert (int (CodeCompletionResultKind ::MAX_VALUE) < 1 << 3 , " " );
714
717
static_assert (int (CodeCompletionOperatorKind::MAX_VALUE) < 1 << 6 , " " );
715
718
static_assert (int (SemanticContextKind::MAX_VALUE) < 1 << 3 , " " );
716
719
static_assert (int (NotRecommendedReason::MAX_VALUE) < 1 << 4 , " " );
@@ -721,7 +724,8 @@ class CodeCompletionResult {
721
724
// / Constructs a \c Pattern, \c Keyword or \c BuiltinOperator result.
722
725
// /
723
726
// / \note The caller must ensure \c CodeCompletionString outlives this result.
724
- CodeCompletionResult (ResultKind Kind, SemanticContextKind SemanticContext,
727
+ CodeCompletionResult (CodeCompletionResultKind Kind,
728
+ SemanticContextKind SemanticContext,
725
729
CodeCompletionFlair Flair, unsigned NumBytesToErase,
726
730
CodeCompletionString *CompletionString,
727
731
ExpectedTypeRelation TypeDistance,
@@ -733,7 +737,8 @@ class CodeCompletionResult {
733
737
NotRecommended(NotRecommendedReason::None),
734
738
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
735
739
BriefDocComment(BriefDocComment), TypeDistance(TypeDistance) {
736
- assert (Kind != ResultKind::Declaration && " use the other constructor" );
740
+ assert (Kind != CodeCompletionResultKind::Declaration &&
741
+ " use the other constructor" );
737
742
assert (CompletionString);
738
743
if (isOperator () && KnownOperatorKind == CodeCompletionOperatorKind::None)
739
744
this ->KnownOperatorKind = getCodeCompletionOperatorKind (CompletionString);
@@ -753,7 +758,7 @@ class CodeCompletionResult {
753
758
CodeCompletionString *CompletionString,
754
759
ExpectedTypeRelation TypeDistance,
755
760
StringRef BriefDocComment = StringRef())
756
- : Kind(ResultKind ::Keyword),
761
+ : Kind(CodeCompletionResultKind ::Keyword),
757
762
KnownOperatorKind(CodeCompletionOperatorKind::None),
758
763
SemanticContext(SemanticContext), Flair(Flair.toRaw()),
759
764
NotRecommended(NotRecommendedReason::None),
@@ -773,7 +778,7 @@ class CodeCompletionResult {
773
778
CodeCompletionFlair Flair, unsigned NumBytesToErase,
774
779
CodeCompletionString *CompletionString,
775
780
ExpectedTypeRelation TypeDistance)
776
- : Kind(ResultKind ::Literal),
781
+ : Kind(CodeCompletionResultKind ::Literal),
777
782
KnownOperatorKind(CodeCompletionOperatorKind::None),
778
783
SemanticContext(SemanticContext), Flair(Flair.toRaw()),
779
784
NotRecommended(NotRecommendedReason::None),
@@ -794,11 +799,11 @@ class CodeCompletionResult {
794
799
CodeCompletionFlair Flair, unsigned NumBytesToErase,
795
800
CodeCompletionString *CompletionString,
796
801
const Decl *AssociatedDecl, StringRef ModuleName,
797
- CodeCompletionResult:: NotRecommendedReason NotRecReason,
802
+ NotRecommendedReason NotRecReason,
798
803
StringRef BriefDocComment,
799
804
ArrayRef<StringRef> AssociatedUSRs,
800
805
ExpectedTypeRelation TypeDistance)
801
- : Kind(ResultKind ::Declaration),
806
+ : Kind(CodeCompletionResultKind ::Declaration),
802
807
KnownOperatorKind(CodeCompletionOperatorKind::None),
803
808
SemanticContext(SemanticContext), Flair(Flair.toRaw()),
804
809
NotRecommended(NotRecReason), NumBytesToErase(NumBytesToErase),
@@ -821,16 +826,15 @@ class CodeCompletionResult {
821
826
CodeCompletionFlair Flair, unsigned NumBytesToErase,
822
827
CodeCompletionString *CompletionString,
823
828
CodeCompletionDeclKind DeclKind, bool IsSystem,
824
- StringRef ModuleName,
825
- CodeCompletionResult::NotRecommendedReason NotRecReason,
829
+ StringRef ModuleName, NotRecommendedReason NotRecReason,
826
830
CodeCompletionDiagnosticSeverity diagSeverity,
827
831
StringRef DiagnosticMessage, StringRef BriefDocComment,
828
832
ArrayRef<StringRef> AssociatedUSRs,
829
833
ExpectedTypeRelation TypeDistance,
830
834
CodeCompletionOperatorKind KnownOperatorKind)
831
- : Kind(ResultKind ::Declaration), KnownOperatorKind(KnownOperatorKind ),
832
- SemanticContext(SemanticContext ), Flair(Flair.toRaw() ),
833
- NotRecommended(NotRecReason), IsSystem(IsSystem),
835
+ : Kind(CodeCompletionResultKind ::Declaration),
836
+ KnownOperatorKind(KnownOperatorKind ), SemanticContext(SemanticContext ),
837
+ Flair(Flair.toRaw()), NotRecommended(NotRecReason), IsSystem(IsSystem),
834
838
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
835
839
ModuleName(ModuleName), BriefDocComment(BriefDocComment),
836
840
AssociatedUSRs(AssociatedUSRs), TypeDistance(TypeDistance),
@@ -847,26 +851,26 @@ class CodeCompletionResult {
847
851
CodeCompletionResult *withFlair (CodeCompletionFlair newFlair,
848
852
CodeCompletionResultSink &Sink);
849
853
850
- ResultKind getKind () const { return Kind; }
854
+ CodeCompletionResultKind getKind () const { return Kind; }
851
855
852
856
CodeCompletionDeclKind getAssociatedDeclKind () const {
853
- assert (getKind () == ResultKind ::Declaration);
857
+ assert (getKind () == CodeCompletionResultKind ::Declaration);
854
858
return static_cast <CodeCompletionDeclKind>(AssociatedKind);
855
859
}
856
860
857
861
CodeCompletionLiteralKind getLiteralKind () const {
858
- assert (getKind () == ResultKind ::Literal);
862
+ assert (getKind () == CodeCompletionResultKind ::Literal);
859
863
return static_cast <CodeCompletionLiteralKind>(AssociatedKind);
860
864
}
861
865
862
866
CodeCompletionKeywordKind getKeywordKind () const {
863
- assert (getKind () == ResultKind ::Keyword);
867
+ assert (getKind () == CodeCompletionResultKind ::Keyword);
864
868
return static_cast <CodeCompletionKeywordKind>(AssociatedKind);
865
869
}
866
870
867
871
bool isOperator () const {
868
- if (getKind () != ResultKind ::Declaration)
869
- return getKind () == ResultKind ::BuiltinOperator;
872
+ if (getKind () != CodeCompletionResultKind ::Declaration)
873
+ return getKind () == CodeCompletionResultKind ::BuiltinOperator;
870
874
switch (getAssociatedDeclKind ()) {
871
875
case CodeCompletionDeclKind::PrefixOperatorFunction:
872
876
case CodeCompletionDeclKind::PostfixOperatorFunction:
0 commit comments