@@ -182,6 +182,10 @@ class CodeCompletionStringChunk {
182
182
// / This chunk should not be inserted into the editor buffer.
183
183
TypeAnnotation,
184
184
185
+ // / Structured group version of 'TypeAnnotation'.
186
+ // / This grouped chunks should not be inserted into the editor buffer.
187
+ TypeAnnotationBegin,
188
+
185
189
// / A brace statement -- left brace and right brace. The preferred
186
190
// / position to put the cursor after the completion result is inserted
187
191
// / into the editor buffer is between the braces.
@@ -195,7 +199,8 @@ class CodeCompletionStringChunk {
195
199
return Kind == ChunkKind::CallParameterBegin ||
196
200
Kind == ChunkKind::GenericParameterBegin ||
197
201
Kind == ChunkKind::OptionalBegin ||
198
- Kind == ChunkKind::CallParameterTypeBegin;
202
+ Kind == ChunkKind::CallParameterTypeBegin ||
203
+ Kind == ChunkKind::TypeAnnotationBegin;
199
204
}
200
205
201
206
static bool chunkHasText (ChunkKind Kind) {
@@ -594,6 +599,7 @@ class CodeCompletionResult {
594
599
unsigned SemanticContext : 3 ;
595
600
unsigned NotRecommended : 1 ;
596
601
unsigned NotRecReason : 3 ;
602
+ unsigned IsSystem : 1 ;
597
603
598
604
// / The number of bytes to the left of the code completion point that
599
605
// / should be erased first if this completion string is inserted in the
@@ -634,6 +640,7 @@ class CodeCompletionResult {
634
640
assert (!isOperator () ||
635
641
getOperatorKind () != CodeCompletionOperatorKind::None);
636
642
AssociatedKind = 0 ;
643
+ IsSystem = 0 ;
637
644
}
638
645
639
646
// / Constructs a \c Keyword result.
@@ -651,6 +658,7 @@ class CodeCompletionResult {
651
658
TypeDistance(TypeDistance) {
652
659
assert (CompletionString);
653
660
AssociatedKind = static_cast <unsigned >(Kind);
661
+ IsSystem = 0 ;
654
662
}
655
663
656
664
// / Constructs a \c Literal result.
@@ -667,6 +675,7 @@ class CodeCompletionResult {
667
675
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
668
676
TypeDistance(TypeDistance) {
669
677
AssociatedKind = static_cast <unsigned >(LiteralKind);
678
+ IsSystem = 0 ;
670
679
assert (CompletionString);
671
680
}
672
681
@@ -694,6 +703,7 @@ class CodeCompletionResult {
694
703
TypeDistance(TypeDistance) {
695
704
assert (AssociatedDecl && " should have a decl" );
696
705
AssociatedKind = unsigned (getCodeCompletionDeclKind (AssociatedDecl));
706
+ IsSystem = getDeclIsSystem (AssociatedDecl);
697
707
assert (CompletionString);
698
708
if (isOperator ())
699
709
KnownOperatorKind =
@@ -706,8 +716,8 @@ class CodeCompletionResult {
706
716
CodeCompletionResult (SemanticContextKind SemanticContext,
707
717
unsigned NumBytesToErase,
708
718
CodeCompletionString *CompletionString,
709
- CodeCompletionDeclKind DeclKind, StringRef ModuleName ,
710
- bool NotRecommended,
719
+ CodeCompletionDeclKind DeclKind, bool IsSystem ,
720
+ StringRef ModuleName, bool NotRecommended,
711
721
CodeCompletionResult::NotRecommendedReason NotRecReason,
712
722
StringRef BriefDocComment,
713
723
ArrayRef<StringRef> AssociatedUSRs,
@@ -718,10 +728,10 @@ class CodeCompletionResult {
718
728
KnownOperatorKind(unsigned (KnownOperatorKind)),
719
729
SemanticContext(unsigned (SemanticContext)),
720
730
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) {
725
735
AssociatedKind = static_cast <unsigned >(DeclKind);
726
736
assert (CompletionString);
727
737
assert (!isOperator () ||
@@ -763,6 +773,10 @@ class CodeCompletionResult {
763
773
return static_cast <CodeCompletionOperatorKind>(KnownOperatorKind);
764
774
}
765
775
776
+ bool isSystem () const {
777
+ return static_cast <bool >(IsSystem);
778
+ }
779
+
766
780
ExpectedTypeRelation getExpectedTypeRelation () const {
767
781
return static_cast <ExpectedTypeRelation>(TypeDistance);
768
782
}
@@ -810,6 +824,7 @@ class CodeCompletionResult {
810
824
getCodeCompletionOperatorKind (StringRef name);
811
825
static CodeCompletionOperatorKind
812
826
getCodeCompletionOperatorKind (CodeCompletionString *str);
827
+ static bool getDeclIsSystem (const Decl *D);
813
828
};
814
829
815
830
struct CodeCompletionResultSink {
@@ -874,7 +889,7 @@ class CodeCompletionContext {
874
889
: Cache(Cache) {}
875
890
876
891
void setAnnotateResult (bool flag) { CurrentResults.annotateResult = flag; }
877
- bool getAnnnoateResult () { return CurrentResults.annotateResult ; }
892
+ bool getAnnotateResult () { return CurrentResults.annotateResult ; }
878
893
879
894
// / Allocate a string owned by the code completion context.
880
895
StringRef copyString (StringRef Str);
0 commit comments