@@ -600,20 +600,20 @@ class CodeCompletionResult {
600600 };
601601
602602 enum NotRecommendedReason {
603- Redundant,
603+ None = 0 ,
604+ RedundantImport,
604605 Deprecated,
605- InvalidContext ,
606+ InvalidAsyncContext ,
606607 CrossActorReference,
607- NoReason ,
608+ VariableUsedInOwnDefinition ,
608609 };
609610
610611private:
611612 unsigned Kind : 3 ;
612613 unsigned AssociatedKind : 8 ;
613614 unsigned KnownOperatorKind : 6 ;
614615 unsigned SemanticContext : 3 ;
615- unsigned NotRecommended : 1 ;
616- unsigned NotRecReason : 3 ;
616+ unsigned NotRecommended : 4 ;
617617 unsigned IsSystem : 1 ;
618618
619619 // / The number of bytes to the left of the code completion point that
@@ -644,11 +644,9 @@ class CodeCompletionResult {
644644 CodeCompletionOperatorKind::None,
645645 StringRef BriefDocComment = StringRef())
646646 : Kind(Kind), KnownOperatorKind(unsigned (KnownOperatorKind)),
647- SemanticContext (unsigned (SemanticContext)), NotRecommended(false ),
648- NotRecReason(NotRecommendedReason::NoReason),
647+ SemanticContext (unsigned (SemanticContext)), NotRecommended(None),
649648 NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
650- BriefDocComment(BriefDocComment),
651- TypeDistance(TypeDistance) {
649+ BriefDocComment(BriefDocComment), TypeDistance(TypeDistance) {
652650 assert (Kind != Declaration && " use the other constructor" );
653651 assert (CompletionString);
654652 if (isOperator () && KnownOperatorKind == CodeCompletionOperatorKind::None)
@@ -670,8 +668,7 @@ class CodeCompletionResult {
670668 ExpectedTypeRelation TypeDistance,
671669 StringRef BriefDocComment = StringRef())
672670 : Kind(Keyword), KnownOperatorKind(0 ),
673- SemanticContext(unsigned (SemanticContext)), NotRecommended(false ),
674- NotRecReason(NotRecommendedReason::NoReason),
671+ SemanticContext(unsigned (SemanticContext)), NotRecommended(None),
675672 NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
676673 BriefDocComment(BriefDocComment), TypeDistance(TypeDistance) {
677674 assert (CompletionString);
@@ -688,8 +685,7 @@ class CodeCompletionResult {
688685 CodeCompletionString *CompletionString,
689686 ExpectedTypeRelation TypeDistance)
690687 : Kind(Literal), KnownOperatorKind(0 ),
691- SemanticContext(unsigned (SemanticContext)), NotRecommended(false ),
692- NotRecReason(NotRecommendedReason::NoReason),
688+ SemanticContext(unsigned (SemanticContext)), NotRecommended(None),
693689 NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
694690 TypeDistance(TypeDistance) {
695691 AssociatedKind = static_cast <unsigned >(LiteralKind);
@@ -706,19 +702,17 @@ class CodeCompletionResult {
706702 unsigned NumBytesToErase,
707703 CodeCompletionString *CompletionString,
708704 const Decl *AssociatedDecl, StringRef ModuleName,
709- bool NotRecommended,
710705 CodeCompletionResult::NotRecommendedReason NotRecReason,
711706 StringRef BriefDocComment,
712707 ArrayRef<StringRef> AssociatedUSRs,
713708 ArrayRef<std::pair<StringRef, StringRef>> DocWords,
714709 enum ExpectedTypeRelation TypeDistance)
715710 : Kind(ResultKind::Declaration), KnownOperatorKind(0 ),
716711 SemanticContext(unsigned (SemanticContext)),
717- NotRecommended(NotRecommended), NotRecReason(NotRecReason),
718- NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
719- ModuleName(ModuleName), BriefDocComment(BriefDocComment),
720- AssociatedUSRs(AssociatedUSRs), DocWords(DocWords),
721- TypeDistance(TypeDistance) {
712+ NotRecommended(NotRecReason), NumBytesToErase(NumBytesToErase),
713+ CompletionString(CompletionString), ModuleName(ModuleName),
714+ BriefDocComment(BriefDocComment), AssociatedUSRs(AssociatedUSRs),
715+ DocWords(DocWords), TypeDistance(TypeDistance) {
722716 assert (AssociatedDecl && " should have a decl" );
723717 AssociatedKind = unsigned (getCodeCompletionDeclKind (AssociatedDecl));
724718 IsSystem = getDeclIsSystem (AssociatedDecl);
@@ -735,7 +729,7 @@ class CodeCompletionResult {
735729 unsigned NumBytesToErase,
736730 CodeCompletionString *CompletionString,
737731 CodeCompletionDeclKind DeclKind, bool IsSystem,
738- StringRef ModuleName, bool NotRecommended,
732+ StringRef ModuleName,
739733 CodeCompletionResult::NotRecommendedReason NotRecReason,
740734 StringRef BriefDocComment,
741735 ArrayRef<StringRef> AssociatedUSRs,
@@ -745,11 +739,11 @@ class CodeCompletionResult {
745739 : Kind(ResultKind::Declaration),
746740 KnownOperatorKind(unsigned (KnownOperatorKind)),
747741 SemanticContext(unsigned (SemanticContext)),
748- NotRecommended(NotRecommended ), NotRecReason(NotRecReason ),
749- IsSystem(IsSystem ), NumBytesToErase(NumBytesToErase ),
750- CompletionString(CompletionString ), ModuleName(ModuleName ),
751- BriefDocComment(BriefDocComment ), AssociatedUSRs(AssociatedUSRs ),
752- DocWords(DocWords), TypeDistance(TypeDistance) {
742+ NotRecommended(NotRecReason ), IsSystem(IsSystem ),
743+ NumBytesToErase(NumBytesToErase ), CompletionString(CompletionString ),
744+ ModuleName(ModuleName ), BriefDocComment(BriefDocComment ),
745+ AssociatedUSRs(AssociatedUSRs ), DocWords(DocWords ),
746+ TypeDistance(TypeDistance) {
753747 AssociatedKind = static_cast <unsigned >(DeclKind);
754748 assert (CompletionString);
755749 assert (!isOperator () ||
@@ -800,16 +794,14 @@ class CodeCompletionResult {
800794 }
801795
802796 NotRecommendedReason getNotRecommendedReason () const {
803- return static_cast <NotRecommendedReason>(NotRecReason );
797+ return static_cast <NotRecommendedReason>(NotRecommended );
804798 }
805799
806800 SemanticContextKind getSemanticContext () const {
807801 return static_cast <SemanticContextKind>(SemanticContext);
808802 }
809803
810- bool isNotRecommended () const {
811- return NotRecommended;
812- }
804+ bool isNotRecommended () const { return NotRecommended != None; }
813805
814806 unsigned getNumBytesToErase () const {
815807 return NumBytesToErase;
0 commit comments