@@ -284,8 +284,8 @@ void TuIndexer::saveEnumConstantDecl(
284
284
auto symbol = optSymbol.value ();
285
285
286
286
scip::SymbolInformation symbolInfo;
287
- for (auto &docComment : this ->tryGetDocComment (enumConstantDecl)) {
288
- *symbolInfo.add_documentation () = std::move (docComment. Text );
287
+ for (auto &docComment : this ->tryGetDocComment (enumConstantDecl). lines ) {
288
+ *symbolInfo.add_documentation () = std::move (docComment);
289
289
}
290
290
291
291
ENFORCE (enumConstantDecl.getBeginLoc () == enumConstantDecl.getLocation ());
@@ -307,8 +307,8 @@ void TuIndexer::saveFieldDecl(const clang::FieldDecl &fieldDecl) {
307
307
return ;
308
308
}
309
309
scip::SymbolInformation symbolInfo{};
310
- for (auto &docComment : this ->tryGetDocComment (fieldDecl)) {
311
- *symbolInfo.add_documentation () = std::move (docComment. Text );
310
+ for (auto &docComment : this ->tryGetDocComment (fieldDecl). lines ) {
311
+ *symbolInfo.add_documentation () = std::move (docComment);
312
312
}
313
313
this ->saveDefinition (optSymbol.value (), fieldDecl.getLocation (), symbolInfo);
314
314
}
@@ -329,8 +329,8 @@ void TuIndexer::saveFunctionDecl(const clang::FunctionDecl &functionDecl) {
329
329
330
330
if (functionDecl.isPure () || functionDecl.isThisDeclarationADefinition ()) {
331
331
scip::SymbolInformation symbolInfo{};
332
- for (auto &docComment : this ->tryGetDocComment (functionDecl)) {
333
- *symbolInfo.add_documentation () = std::move (docComment. Text );
332
+ for (auto &docComment : this ->tryGetDocComment (functionDecl). lines ) {
333
+ *symbolInfo.add_documentation () = std::move (docComment);
334
334
}
335
335
if (auto *cxxMethodDecl =
336
336
llvm::dyn_cast<clang::CXXMethodDecl>(&functionDecl)) {
@@ -493,8 +493,8 @@ void TuIndexer::saveTagDecl(const clang::TagDecl &tagDecl) {
493
493
}
494
494
495
495
scip::SymbolInformation symbolInfo;
496
- for (auto &docComment : this ->tryGetDocComment (tagDecl)) {
497
- *symbolInfo.add_documentation () = std::move (docComment. Text );
496
+ for (auto &docComment : this ->tryGetDocComment (tagDecl). lines ) {
497
+ *symbolInfo.add_documentation () = std::move (docComment);
498
498
}
499
499
500
500
if (auto *cxxRecordDecl = llvm::dyn_cast<clang::CXXRecordDecl>(&tagDecl)) {
@@ -579,8 +579,8 @@ void TuIndexer::saveTypedefNameDecl(
579
579
return ;
580
580
}
581
581
scip::SymbolInformation symbolInfo{};
582
- for (auto &docComment : this ->tryGetDocComment (typedefNameDecl)) {
583
- *symbolInfo.add_documentation () = std::move (docComment. Text );
582
+ for (auto &docComment : this ->tryGetDocComment (typedefNameDecl). lines ) {
583
+ *symbolInfo.add_documentation () = std::move (docComment);
584
584
}
585
585
this ->saveDefinition (*optSymbol, typedefNameDecl.getLocation (),
586
586
std::move (symbolInfo));
@@ -606,8 +606,8 @@ void TuIndexer::saveVarDecl(const clang::VarDecl &varDecl) {
606
606
return ;
607
607
}
608
608
scip::SymbolInformation symbolInfo{};
609
- for (auto &docComment : this ->tryGetDocComment (varDecl)) {
610
- *symbolInfo.add_documentation () = std::move (docComment. Text );
609
+ for (auto &docComment : this ->tryGetDocComment (varDecl). lines ) {
610
+ *symbolInfo.add_documentation () = std::move (docComment);
611
611
}
612
612
this ->saveDefinition (optSymbol.value (), varDecl.getLocation (), symbolInfo);
613
613
}
@@ -763,17 +763,20 @@ checkIfCommentBelongsToPreviousEnumCase(const clang::Decl &decl,
763
763
764
764
namespace scip_clang {
765
765
766
- std::vector<clang::RawComment::CommentLine>
767
- TuIndexer::tryGetDocComment (const clang::Decl &decl) const {
766
+ DocComment TuIndexer::tryGetDocComment (const clang::Decl &decl) const {
768
767
auto &astContext = decl.getASTContext ();
769
768
// FIXME(def: hovers, issue:
770
769
// https://github.com/sourcegraph/scip-clang/issues/96)
771
770
if (auto *rawComment = astContext.getRawCommentForAnyRedecl (&decl)) {
772
771
if (::checkIfCommentBelongsToPreviousEnumCase (decl, *rawComment)) {
773
772
return {};
774
773
}
775
- return rawComment->getFormattedLines (this ->sourceManager ,
776
- astContext.getDiagnostics ());
774
+ DocComment out{};
775
+ for (auto &line : rawComment->getFormattedLines (
776
+ this ->sourceManager , astContext.getDiagnostics ())) {
777
+ out.lines .emplace_back (std::move (line.Text ));
778
+ }
779
+ return out;
777
780
}
778
781
return {};
779
782
}
0 commit comments