0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | List of all members
clanguml::common::visitor::comment::plain_visitor Class Reference

Plain comment visitor which extracts raw and formatted comment. More...

Detailed Description

Plain comment visitor which extracts raw and formatted comment.

Definition at line 31 of file plain_visitor.h.

#include <plain_visitor.h>

Public Member Functions

 plain_visitor (clang::SourceManager &source_manager)
 
void visit (const clang::NamedDecl &decl, common::model::decorated_element &e) override
 
- Public Member Functions inherited from clanguml::common::visitor::comment::comment_visitor
 comment_visitor (clang::SourceManager &source_manager)
 
virtual ~comment_visitor ()=default
 
virtual void visit (const clang::NamedDecl &decl, common::model::decorated_element &e)=0
 
clang::SourceManager & source_manager ()
 

Constructor & Destructor Documentation

◆ plain_visitor()

clanguml::common::visitor::comment::plain_visitor::plain_visitor ( clang::SourceManager &  source_manager)

Definition at line 23 of file plain_visitor.cc.

Member Function Documentation

◆ visit()

void clanguml::common::visitor::comment::plain_visitor::visit ( const clang::NamedDecl &  decl,
common::model::decorated_element e 
)
overridevirtual

Extracts 'raw' and 'formatted' comment values from the Clang's parser.

Parameters
declClang's named declaration
eDiagram element

Implements clanguml::common::visitor::comment::comment_visitor.

Definition at line 28 of file plain_visitor.cc.

30{
31 const auto *comment =
32 decl.getASTContext().getRawCommentForDeclNoCache(&decl);
33
34 if (comment == nullptr) {
35 return;
36 }
37
38 auto raw_comment = comment->getRawText(source_manager());
39
40 auto formatted_comment = comment->getFormattedText(
41 source_manager(), decl.getASTContext().getDiagnostics());
42
43 common::model::comment_t cmt = inja::json::object();
44 cmt["raw"] = raw_comment;
45 cmt["formatted"] = formatted_comment;
46
47 e.set_comment(cmt);
48}

The documentation for this class was generated from the following files: