Skip to content

Commit c54aed6

Browse files
committed
Added three versions of finishLookups.
1 parent 6c603c4 commit c54aed6

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

include/swift/AST/DebuggerClient.h

+17-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,23 @@ class DebuggerClient {
6161
SourceLoc Loc, bool IsTypeLookup,
6262
ResultVector &RV) = 0;
6363

64-
/// Allows the DebuggerClient to prune the results of a name lookup before
65-
/// returning to the caller. (See finishLookup in NameLookup.cpp.)
66-
virtual void finishLookup(const DeclContext *dc, NLOptions options,
67-
SmallVectorImpl<ValueDecl *> &decls) {}
64+
/// The following functions allow the debugger to prune the results of a a
65+
/// qualfied lookup as needed. See the corresponding finishLookupInXYZ
66+
/// functions defined in NameLookup.cpp.
67+
///
68+
69+
virtual void finishLookupInNominals(const DeclContext *dc,
70+
ArrayRef<NominalTypeDecl *> types,
71+
DeclName member, NLOptions options,
72+
SmallVectorImpl<ValueDecl *> &decls) {}
73+
74+
virtual void finishLookupInModule(const DeclContext *dc, ModuleDecl *module,
75+
DeclName member, NLOptions options,
76+
SmallVectorImpl<ValueDecl *> &decls) {}
77+
78+
virtual void finishLookupInAnyObject(const DeclContext *dc, DeclName member,
79+
NLOptions options,
80+
SmallVectorImpl<ValueDecl *> &decls) {}
6881

6982
/// When evaluating an expression in the context of an existing source file,
7083
/// we may want to prefer declarations from that source file.

lib/AST/NameLookup.cpp

+34-3
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,38 @@ bool namelookup::finishLookup(const DeclContext *dc, NLOptions options,
13691369
removeShadowedDecls(decls, M);
13701370

13711371
filterForDiscriminator(decls, M->getDebugClient());
1372+
}
1373+
1374+
static bool finishLookupInNominals(const DeclContext *dc,
1375+
ArrayRef<NominalTypeDecl *> types,
1376+
DeclName member, NLOptions options,
1377+
SmallVectorImpl<ValueDecl *> &decls) {
1378+
finishLookup(dc, options, decls);
1379+
if (auto *debugClient = dc->getParentModule()->getDebugClient()) {
1380+
debugClient->finishLookupInNominals(dc, types, member, options, decls);
1381+
}
1382+
// We're done. Report success/failure.
1383+
return !decls.empty();
1384+
}
13721385

1386+
static bool finishLookupInModule(const DeclContext *dc, ModuleDecl *module,
1387+
DeclName member, NLOptions options,
1388+
SmallVectorImpl<ValueDecl *> &decls) {
1389+
finishLookup(dc, options, decls);
1390+
if (auto *debugClient = dc->getParentModule()->getDebugClient()) {
1391+
debugClient->finishLookupInModule(dc, module, member, options, decls);
1392+
}
1393+
// We're done. Report success/failure.
1394+
return !decls.empty();
1395+
}
1396+
1397+
static bool finishLookupInAnyObject(const DeclContext *dc, DeclName member,
1398+
NLOptions options,
1399+
SmallVectorImpl<ValueDecl *> &decls) {
1400+
finishLookup(dc, options, decls);
1401+
if (auto *debugClient = dc->getParentModule()->getDebugClient()) {
1402+
debugClient->finishLookupInAnyObject(dc, member, options, decls);
1403+
}
13731404
// We're done. Report success/failure.
13741405
return !decls.empty();
13751406
}
@@ -1575,7 +1606,7 @@ bool DeclContext::lookupQualified(ArrayRef<NominalTypeDecl *> typeDecls,
15751606
}
15761607
}
15771608

1578-
return finishLookup(this, options, decls);
1609+
return finishLookupInNominals(this, typeDecls, member, options, decls);
15791610
}
15801611

15811612
bool DeclContext::lookupQualified(ModuleDecl *module, DeclName member,
@@ -1627,7 +1658,7 @@ bool DeclContext::lookupQualified(ModuleDecl *module, DeclName member,
16271658
return !knownDecls.insert(vd).second;
16281659
}), decls.end());
16291660

1630-
return finishLookup(this, options, decls);
1661+
return finishLookupInModule(this, module, member, options, decls);
16311662
}
16321663

16331664
bool DeclContext::lookupAnyObject(DeclName member, NLOptions options,
@@ -1682,7 +1713,7 @@ bool DeclContext::lookupAnyObject(DeclName member, NLOptions options,
16821713
decls.push_back(decl);
16831714
}
16841715

1685-
return finishLookup(this, options, decls);
1716+
return finishLookupInAnyObject(this, member, options, decls);
16861717
}
16871718

16881719
void DeclContext::lookupAllObjCMethods(

0 commit comments

Comments
 (0)