mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IDE][DocSupport] Fix DocInfo missing decls when generated for clang submodules.
Out handling of clang submodules was handled differently between DocInfo and InterfaceGen. For InterfaceGen submodules were mapped back to their top-level clang modules (or their Swift overlay if it had one) before being passed into printSubmoduleInterface, along with the dot separated name of the submodule. For DocInfo, they were not, and only the rightmost component of their name was passed. The call to retrieve the decls from a ModuleDecl doesn't work if the ModuleDecl wraps a clang submodule, so we were missing these decls. InterfaceGen for submodules also shouldn't have been mapping the module back to the overlay of top-level clang module, as that meant we ended up printing import decls from the Swift overlay in the submodule's interface. Resolves rdar://problem/57338105
This commit is contained in:
@@ -303,25 +303,6 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<StringRef> SplitModuleName;
|
||||
while (!ModuleName.empty()) {
|
||||
StringRef SubModuleName;
|
||||
std::tie(SubModuleName, ModuleName) = ModuleName.split('.');
|
||||
SplitModuleName.push_back(SubModuleName);
|
||||
}
|
||||
assert(!SplitModuleName.empty());
|
||||
|
||||
// FIXME: If this is a submodule, get its top-level module, which will be the
|
||||
// DeclContext for all of its Decls since we don't have first-class submodules.
|
||||
if (SplitModuleName.size() > 1) {
|
||||
Mod = getModuleByFullName(Ctx, SplitModuleName[0]);
|
||||
if (!Mod) {
|
||||
ErrMsg = "Could not load module: ";
|
||||
ErrMsg += ModuleName;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PrintOptions Options = PrintOptions::printModuleInterface();
|
||||
ModuleTraversalOptions TraversalOptions = None; // Don't print submodules.
|
||||
SmallString<128> Text;
|
||||
@@ -330,11 +311,11 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
|
||||
if (!Group && InterestedUSR) {
|
||||
Group = findGroupNameForUSR(Mod, InterestedUSR.getValue());
|
||||
}
|
||||
printSubmoduleInterface(Mod, SplitModuleName,
|
||||
Group.hasValue() ? llvm::makeArrayRef(Group.getValue()) : ArrayRef<StringRef>(),
|
||||
TraversalOptions,
|
||||
Printer, Options,
|
||||
Group.hasValue() && SynthesizedExtensions);
|
||||
printModuleInterface(Mod, Group.hasValue()
|
||||
? llvm::makeArrayRef(Group.getValue())
|
||||
: ArrayRef<StringRef>(),
|
||||
TraversalOptions, Printer, Options,
|
||||
Group.hasValue() && SynthesizedExtensions);
|
||||
|
||||
Info.Text = std::string(OS.str());
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user