@@ -1016,15 +1016,16 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
1016
1016
*ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
1017
1017
*CompletionTUInfo,
1018
1018
/* IncludeBriefComments*/ false );
1019
- std::string Documentation =
1020
- formatDocumentation (*CCS, getDocComment (Ctx, SymbolCompletion,
1021
- /* CommentsFromHeaders= */ true ) );
1019
+ std::string DocComment = getDocComment (Ctx, SymbolCompletion,
1020
+ /* CommentsFromHeaders= */ true );
1021
+ std::string Documentation = formatDocumentation (*CCS, DocComment );
1022
1022
if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
1023
1023
if (Opts.StoreAllDocumentation )
1024
1024
S.Documentation = Documentation;
1025
1025
Symbols.insert (S);
1026
1026
return Symbols.find (S.ID );
1027
1027
}
1028
+ S.DocComment = DocComment;
1028
1029
S.Documentation = Documentation;
1029
1030
std::string Signature;
1030
1031
std::string SnippetSuffix;
@@ -1065,6 +1066,26 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
1065
1066
Symbol S = DeclSym;
1066
1067
// FIXME: use the result to filter out symbols.
1067
1068
S.Definition = *DefLoc;
1069
+
1070
+ std::string DocComment;
1071
+ std::string Documentation;
1072
+ if (S.DocComment .empty () &&
1073
+ (llvm::isa<FunctionDecl>(ND) || llvm::isa<CXXMethodDecl>(ND))) {
1074
+ CodeCompletionResult SymbolCompletion (&getTemplateOrThis (ND), 0 );
1075
+ const auto *CCS = SymbolCompletion.CreateCodeCompletionString (
1076
+ *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
1077
+ *CompletionTUInfo,
1078
+ /* IncludeBriefComments*/ false );
1079
+ DocComment = getDocComment (ND.getASTContext (), SymbolCompletion,
1080
+ /* CommentsFromHeaders=*/ true );
1081
+ if (!S.Documentation .empty ())
1082
+ Documentation = S.Documentation .str () + ' \n ' + DocComment;
1083
+ else
1084
+ Documentation = formatDocumentation (*CCS, DocComment);
1085
+ S.DocComment = DocComment;
1086
+ S.Documentation = Documentation;
1087
+ }
1088
+
1068
1089
Symbols.insert (S);
1069
1090
}
1070
1091
0 commit comments