@@ -756,13 +756,20 @@ TypeRepr *ASTGen::generate(const SILFunctionTypeSyntax &Type,
756
756
TypeRepr *ASTGen::generate (const CodeCompletionTypeSyntax &Type,
757
757
const SourceLoc Loc) {
758
758
auto base = Type.getBase ();
759
- if (!base)
759
+ if (!base) {
760
+ if (P.CodeCompletion )
761
+ P.CodeCompletion ->completeTypeSimpleBeginning ();
760
762
return nullptr ;
763
+ }
761
764
762
765
if (P.CodeCompletion ) {
763
- TypeRepr *parsedTyR = generate (*base, Loc);
764
- if (parsedTyR)
766
+ if (auto *parsedTyR = generate (*base, Loc)) {
765
767
P.CodeCompletion ->setParsedTypeLoc (parsedTyR);
768
+ if (Type.getPeriod ())
769
+ P.CodeCompletion ->completeTypeIdentifierWithDot ();
770
+ else
771
+ P.CodeCompletion ->completeTypeIdentifierWithoutDot ();
772
+ }
766
773
}
767
774
768
775
// Return nullptr to typecheck this TypeRepr independently in code completion.
@@ -810,13 +817,28 @@ TypeRepr *ASTGen::generate(const UnknownTypeSyntax &Type, const SourceLoc Loc) {
810
817
if (ChildrenCount >= 1 ) {
811
818
auto LParen = Type.getChild (0 )->getAs <TokenSyntax>();
812
819
if (LParen && LParen->getTokenKind () == tok::l_paren) {
820
+ // generate child 'TypeSyntax' anyway to trigger the side effects e.g.
821
+ // code-completion.
822
+ for (size_t i = 1 ; i != ChildrenCount; ++i) {
823
+ auto elem = *Type.getChild (i);
824
+ if (auto ty = elem.getAs <TypeSyntax>())
825
+ (void )generate (*ty, Loc);
826
+ }
813
827
auto LParenLoc = advanceLocBegin (Loc, *LParen);
814
828
auto EndLoc =
815
829
advanceLocBegin (Loc, *Type.getChild (Type.getNumChildren () - 1 ));
816
830
return TupleTypeRepr::createEmpty (Context, {LParenLoc, EndLoc});
817
831
}
818
832
}
819
833
834
+ // generate child 'TypeSyntax' anyway to trigger the side effects e.g.
835
+ // code-completion.
836
+ for (size_t i = 0 ; i != ChildrenCount; ++i) {
837
+ auto elem = *Type.getChild (i);
838
+ if (auto ty = elem.getAs <TypeSyntax>())
839
+ (void )generate (*ty, Loc);
840
+ }
841
+
820
842
// let's hope the main `generate` method can find this node in the type map
821
843
return nullptr ;
822
844
}
0 commit comments