Skip to content

Commit eaad8a7

Browse files
committed
[SymbolGraph] Serialize Location uri and position together
or not at all. This information comes as one unit from .swiftsourceinfo so the code should reflect that. rdar://60499122
1 parent d23082f commit eaad8a7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/SymbolGraphGen/Symbol.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,13 @@ void Symbol::serializeLocationMixin(llvm::json::OStream &OS) const {
297297
return;
298298
}
299299
auto FileName = VD->getASTContext().SourceMgr.getDisplayNameForLoc(Loc);
300+
if (FileName.empty()) {
301+
return;
302+
}
300303
OS.attributeObject("location", [&](){
301-
if (!FileName.empty()) {
302-
SmallString<1024> FileURI("file://");
303-
FileURI.append(FileName);
304-
OS.attribute("uri", FileURI.str());
305-
}
304+
SmallString<1024> FileURI("file://");
305+
FileURI.append(FileName);
306+
OS.attribute("uri", FileURI.str());
306307
serializePosition("position", Loc, Graph->M.getASTContext().SourceMgr, OS);
307308
});
308309
}

0 commit comments

Comments
 (0)