mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Vend the localization key found in documentation comments
If a documentation comment has a - LocalizationKey: field, strip it out of the documentation body and report it in cursor/doc info with the key "key.localization_key". rdar://problem/30383329
This commit is contained in:
@@ -715,7 +715,17 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
|
||||
}
|
||||
unsigned GroupEnd = SS.size();
|
||||
|
||||
unsigned LocalizationBegin = SS.size();
|
||||
{
|
||||
llvm::raw_svector_ostream OS(SS);
|
||||
ide::getLocalizationKey(VD, OS);
|
||||
}
|
||||
unsigned LocalizationEnd = SS.size();
|
||||
|
||||
DelayedStringRetriever OverUSRsStream(SS);
|
||||
|
||||
SmallVector<std::pair<unsigned, unsigned>, 4> OverUSROffs;
|
||||
|
||||
ide::walkOverriddenDecls(VD,
|
||||
[&](llvm::PointerUnion<const ValueDecl*, const clang::NamedDecl*> D) {
|
||||
OverUSRsStream.startPiece();
|
||||
@@ -798,6 +808,8 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
|
||||
StringRef FullyAnnotatedDecl =
|
||||
StringRef(SS.begin() + FullDeclBegin, FullDeclEnd - FullDeclBegin);
|
||||
StringRef GroupName = StringRef(SS.begin() + GroupBegin, GroupEnd - GroupBegin);
|
||||
StringRef LocalizationKey = StringRef(SS.begin() + LocalizationBegin,
|
||||
LocalizationEnd - LocalizationBegin);
|
||||
|
||||
llvm::Optional<std::pair<unsigned, unsigned>> DeclarationLoc;
|
||||
StringRef Filename;
|
||||
@@ -837,6 +849,7 @@ static bool passCursorInfoForDecl(const ValueDecl *VD,
|
||||
Info.OverrideUSRs = OverUSRs;
|
||||
Info.AnnotatedRelatedDeclarations = AnnotatedRelatedDecls;
|
||||
Info.GroupName = GroupName;
|
||||
Info.LocalizationKey = LocalizationKey;
|
||||
Info.IsSystem = IsSystem;
|
||||
Info.TypeInterface = StringRef();
|
||||
Receiver(Info);
|
||||
|
||||
Reference in New Issue
Block a user