@@ -182,6 +182,10 @@ class CodeCompletionStringChunk {
182182 // / This chunk should not be inserted into the editor buffer.
183183 TypeAnnotation,
184184
185+ // / Structured group version of 'TypeAnnotation'.
186+ // / This grouped chunks should not be inserted into the editor buffer.
187+ TypeAnnotationBegin,
188+
185189 // / A brace statement -- left brace and right brace. The preferred
186190 // / position to put the cursor after the completion result is inserted
187191 // / into the editor buffer is between the braces.
@@ -195,7 +199,8 @@ class CodeCompletionStringChunk {
195199 return Kind == ChunkKind::CallParameterBegin ||
196200 Kind == ChunkKind::GenericParameterBegin ||
197201 Kind == ChunkKind::OptionalBegin ||
198- Kind == ChunkKind::CallParameterTypeBegin;
202+ Kind == ChunkKind::CallParameterTypeBegin ||
203+ Kind == ChunkKind::TypeAnnotationBegin;
199204 }
200205
201206 static bool chunkHasText (ChunkKind Kind) {
@@ -594,6 +599,7 @@ class CodeCompletionResult {
594599 unsigned SemanticContext : 3 ;
595600 unsigned NotRecommended : 1 ;
596601 unsigned NotRecReason : 3 ;
602+ unsigned IsSystem : 1 ;
597603
598604 // / The number of bytes to the left of the code completion point that
599605 // / should be erased first if this completion string is inserted in the
@@ -634,6 +640,7 @@ class CodeCompletionResult {
634640 assert (!isOperator () ||
635641 getOperatorKind () != CodeCompletionOperatorKind::None);
636642 AssociatedKind = 0 ;
643+ IsSystem = 0 ;
637644 }
638645
639646 // / Constructs a \c Keyword result.
@@ -651,6 +658,7 @@ class CodeCompletionResult {
651658 TypeDistance(TypeDistance) {
652659 assert (CompletionString);
653660 AssociatedKind = static_cast <unsigned >(Kind);
661+ IsSystem = 0 ;
654662 }
655663
656664 // / Constructs a \c Literal result.
@@ -667,6 +675,7 @@ class CodeCompletionResult {
667675 NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
668676 TypeDistance(TypeDistance) {
669677 AssociatedKind = static_cast <unsigned >(LiteralKind);
678+ IsSystem = 0 ;
670679 assert (CompletionString);
671680 }
672681
@@ -694,6 +703,7 @@ class CodeCompletionResult {
694703 TypeDistance(TypeDistance) {
695704 assert (AssociatedDecl && " should have a decl" );
696705 AssociatedKind = unsigned (getCodeCompletionDeclKind (AssociatedDecl));
706+ IsSystem = getDeclIsSystem (AssociatedDecl);
697707 assert (CompletionString);
698708 if (isOperator ())
699709 KnownOperatorKind =
@@ -706,8 +716,8 @@ class CodeCompletionResult {
706716 CodeCompletionResult (SemanticContextKind SemanticContext,
707717 unsigned NumBytesToErase,
708718 CodeCompletionString *CompletionString,
709- CodeCompletionDeclKind DeclKind, StringRef ModuleName ,
710- bool NotRecommended,
719+ CodeCompletionDeclKind DeclKind, bool IsSystem ,
720+ StringRef ModuleName, bool NotRecommended,
711721 CodeCompletionResult::NotRecommendedReason NotRecReason,
712722 StringRef BriefDocComment,
713723 ArrayRef<StringRef> AssociatedUSRs,
@@ -718,10 +728,10 @@ class CodeCompletionResult {
718728 KnownOperatorKind(unsigned (KnownOperatorKind)),
719729 SemanticContext(unsigned (SemanticContext)),
720730 NotRecommended(NotRecommended), NotRecReason(NotRecReason),
721- NumBytesToErase(NumBytesToErase ), CompletionString(CompletionString ),
722- ModuleName(ModuleName ), BriefDocComment(BriefDocComment ),
723- AssociatedUSRs(AssociatedUSRs ), DocWords(DocWords ),
724- TypeDistance(TypeDistance) {
731+ IsSystem(IsSystem ), NumBytesToErase(NumBytesToErase ),
732+ CompletionString(CompletionString ), ModuleName(ModuleName ),
733+ BriefDocComment(BriefDocComment ), AssociatedUSRs(AssociatedUSRs ),
734+ DocWords(DocWords), TypeDistance(TypeDistance) {
725735 AssociatedKind = static_cast <unsigned >(DeclKind);
726736 assert (CompletionString);
727737 assert (!isOperator () ||
@@ -763,6 +773,10 @@ class CodeCompletionResult {
763773 return static_cast <CodeCompletionOperatorKind>(KnownOperatorKind);
764774 }
765775
776+ bool isSystem () const {
777+ return static_cast <bool >(IsSystem);
778+ }
779+
766780 ExpectedTypeRelation getExpectedTypeRelation () const {
767781 return static_cast <ExpectedTypeRelation>(TypeDistance);
768782 }
@@ -810,6 +824,7 @@ class CodeCompletionResult {
810824 getCodeCompletionOperatorKind (StringRef name);
811825 static CodeCompletionOperatorKind
812826 getCodeCompletionOperatorKind (CodeCompletionString *str);
827+ static bool getDeclIsSystem (const Decl *D);
813828};
814829
815830struct CodeCompletionResultSink {
@@ -874,7 +889,7 @@ class CodeCompletionContext {
874889 : Cache(Cache) {}
875890
876891 void setAnnotateResult (bool flag) { CurrentResults.annotateResult = flag; }
877- bool getAnnnoateResult () { return CurrentResults.annotateResult ; }
892+ bool getAnnotateResult () { return CurrentResults.annotateResult ; }
878893
879894 // / Allocate a string owned by the code completion context.
880895 StringRef copyString (StringRef Str);
0 commit comments