@@ -137,7 +137,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
137137 bool IsUnwrappedOptional = false ;
138138 SourceLoc DotLoc;
139139 bool NeedLeadingDot = false ;
140- bool NeedLeadingMacroPound = false ;
141140
142141 bool NeedOptionalUnwrap = false ;
143142 unsigned NumBytesToEraseForOptionalUnwrap = 0 ;
@@ -186,53 +185,27 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
186185public:
187186 struct RequestedResultsTy {
188187 const ModuleDecl *TheModule;
189- bool OnlyTypes;
190- bool OnlyPrecedenceGroups;
191- bool OnlyMacros;
188+ CodeCompletionFilter Filter;
192189 bool NeedLeadingDot;
193- bool NeedPound;
194- bool IncludeModuleQualifier;
195190
196- static RequestedResultsTy fromModule (const ModuleDecl *TheModule) {
197- return {TheModule, false , false , false , false , false , true };
191+ static RequestedResultsTy fromModule (const ModuleDecl *mod,
192+ CodeCompletionFilter filter) {
193+ return {mod, filter, /* NeedLeadingDot=*/ false };
198194 }
199195
200- RequestedResultsTy onlyTypes () const {
201- return {TheModule, true , false , false , NeedLeadingDot, false ,
202- IncludeModuleQualifier};
196+ static RequestedResultsTy topLevelResults (CodeCompletionFilter filter) {
197+ return {nullptr , filter, /* NeedLeadingDot=*/ false };
203198 }
204199
205- RequestedResultsTy onlyPrecedenceGroups () const {
206- assert (!OnlyTypes && " onlyTypes() already includes precedence groups" );
207- return {TheModule, false , true , false , false , false , true };
208- }
209-
210- RequestedResultsTy onlyMacros (bool needPound) const {
211- return {TheModule, false , false , true , false , needPound, false };
212- }
213-
214- RequestedResultsTy needLeadingDot (bool NeedDot) const {
215- return {TheModule, OnlyTypes, OnlyPrecedenceGroups, OnlyMacros, NeedDot,
216- NeedPound, IncludeModuleQualifier};
217- }
218-
219- RequestedResultsTy withModuleQualifier (bool IncludeModule) const {
220- return {TheModule, OnlyTypes, OnlyPrecedenceGroups, OnlyMacros,
221- NeedLeadingDot, NeedPound, IncludeModule};
222- }
223-
224- static RequestedResultsTy toplevelResults () {
225- return {nullptr , false , false , false , false , true , true };
200+ RequestedResultsTy needLeadingDot (bool needDot) const {
201+ return {TheModule, Filter, needDot};
226202 }
227203
228204 friend bool operator ==(const RequestedResultsTy &LHS,
229205 const RequestedResultsTy &RHS) {
230- return LHS.TheModule == RHS.TheModule && LHS.OnlyTypes == RHS.OnlyTypes &&
231- LHS.OnlyPrecedenceGroups == RHS.OnlyPrecedenceGroups &&
232- LHS.OnlyMacros == RHS.OnlyMacros &&
233- LHS.NeedLeadingDot == RHS.NeedLeadingDot &&
234- LHS.NeedPound == RHS.NeedPound &&
235- LHS.IncludeModuleQualifier == RHS.IncludeModuleQualifier ;
206+ return LHS.TheModule == RHS.TheModule &&
207+ LHS.Filter .containsOnly (RHS.Filter ) &&
208+ LHS.NeedLeadingDot == RHS.NeedLeadingDot ;
236209 }
237210 };
238211
@@ -524,7 +497,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
524497 Type ExprType, const ValueDecl *VD,
525498 Optional<SemanticContextKind> SemanticContext = None);
526499
527- bool tryModuleCompletions (Type ExprType, bool TypesOnly = false );
500+ bool tryModuleCompletions (Type ExprType, CodeCompletionFilter Filter );
528501
529502 // / If the given ExprType is optional, this adds completions for the unwrapped
530503 // / type.
@@ -562,7 +535,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
562535
563536 void addObjCPoundKeywordCompletions (bool needPound);
564537
565- void getMacroCompletions (bool needPound );
538+ void getMacroCompletions (CodeCompletionMacroRoles roles );
566539
567540 struct FilteredDeclConsumer : public swift ::VisibleDeclConsumer {
568541 swift::VisibleDeclConsumer &Consumer;
@@ -626,7 +599,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
626599 void getTypeCompletionsInDeclContext (SourceLoc Loc,
627600 bool ModuleQualifier = true );
628601
629- void getToplevelCompletions (bool OnlyTypes, bool OnlyMacros );
602+ void getToplevelCompletions (CodeCompletionFilter Filter );
630603
631604 void lookupExternalModuleDecls (const ModuleDecl *TheModule,
632605 ArrayRef<std::string> AccessPath,
@@ -645,18 +618,15 @@ using RequestedResultsTy = swift::ide::CompletionLookup::RequestedResultsTy;
645618template <>
646619struct DenseMapInfo <RequestedResultsTy> {
647620 static inline RequestedResultsTy getEmptyKey () {
648- return {DenseMapInfo<swift::ModuleDecl *>::getEmptyKey (), false , false ,
649- false , false , false , false };
621+ return {DenseMapInfo<swift::ModuleDecl *>::getEmptyKey (), {}, false };
650622 }
651623 static inline RequestedResultsTy getTombstoneKey () {
652- return {DenseMapInfo<swift::ModuleDecl *>::getTombstoneKey (), false , false ,
653- false , false , false , false };
624+ return {DenseMapInfo<swift::ModuleDecl *>::getTombstoneKey (), {}, false };
654625 }
655626 static unsigned getHashValue (const RequestedResultsTy &Val) {
656627 return hash_combine (
657628 DenseMapInfo<swift::ModuleDecl *>::getHashValue (Val.TheModule ),
658- Val.OnlyTypes , Val.OnlyPrecedenceGroups , Val.OnlyMacros ,
659- Val.NeedLeadingDot , Val.NeedPound , Val.IncludeModuleQualifier );
629+ Val.Filter .toRaw (), Val.NeedLeadingDot );
660630 }
661631 static bool isEqual (const RequestedResultsTy &LHS,
662632 const RequestedResultsTy &RHS) {
0 commit comments