mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CursorInfo] Always add module name to response
To simplify clients, have the cursorinfo result be consistent whether requesting a symbol within the current module or not, ie. do not skip adding the module name. Resolves rdar://77003299
This commit is contained in:
@@ -753,26 +753,23 @@ getParamParentNameOffset(const ValueDecl *VD, SourceLoc Cursor) {
|
||||
return SM.getLocOffsetInBuffer(Loc, SM.findBufferContainingLoc(Loc));
|
||||
}
|
||||
|
||||
static StringRef
|
||||
getModuleName(const ValueDecl *VD, llvm::BumpPtrAllocator &Allocator,
|
||||
ModuleDecl *IgnoreModule = nullptr) {
|
||||
static StringRef getModuleName(const ValueDecl *VD,
|
||||
llvm::BumpPtrAllocator &Allocator) {
|
||||
ASTContext &Ctx = VD->getASTContext();
|
||||
ClangImporter *Importer =
|
||||
static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
|
||||
auto ClangNode = VD->getClangNode();
|
||||
if (ClangNode) {
|
||||
auto ClangMod = Importer->getClangOwningModule(ClangNode);
|
||||
if (ClangMod)
|
||||
if (auto ClangNode = VD->getClangNode()) {
|
||||
if (const auto *ClangMod = Importer->getClangOwningModule(ClangNode))
|
||||
return copyString(Allocator, ClangMod->getFullModuleName());
|
||||
} else if (VD->getModuleContext() != IgnoreModule) {
|
||||
ModuleDecl *MD = VD->getModuleContext();
|
||||
// If the decl is from a cross-import overlay module, report the
|
||||
// overlay's declaring module as the owning module.
|
||||
if (ModuleDecl *Declaring = MD->getDeclaringModuleIfCrossImportOverlay())
|
||||
MD = Declaring;
|
||||
return MD->getNameStr();
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
|
||||
ModuleDecl *MD = VD->getModuleContext();
|
||||
// If the decl is from a cross-import overlay module, report the
|
||||
// overlay's declaring module as the owning module.
|
||||
if (ModuleDecl *Declaring = MD->getDeclaringModuleIfCrossImportOverlay())
|
||||
MD = Declaring;
|
||||
return MD->getNameStr();
|
||||
}
|
||||
|
||||
struct DeclInfo {
|
||||
@@ -1044,9 +1041,7 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
|
||||
llvm::makeArrayRef(ReferencedDecls));
|
||||
}
|
||||
|
||||
Symbol.ModuleName = copyString(Allocator,
|
||||
getModuleName(DInfo.VD, Allocator,
|
||||
/*ModuleToIgnore=*/MainModule));
|
||||
Symbol.ModuleName = getModuleName(DInfo.VD, Allocator);
|
||||
if (auto IFaceGenRef =
|
||||
Lang.getIFaceGenContexts().find(Symbol.ModuleName, Invoc))
|
||||
Symbol.ModuleInterfaceName = IFaceGenRef->getDocumentName();
|
||||
|
||||
Reference in New Issue
Block a user