Package diagram translation unit visitor. More...
Package diagram translation unit visitor.
This class implements the clang::RecursiveASTVisitor
interface for selected visitors relevant to generating package diagrams.
Definition at line 51 of file translation_unit_visitor.h.
#include <translation_unit_visitor.h>
Public Member Functions | |
translation_unit_visitor (clang::SourceManager &sm, clanguml::package_diagram::model::diagram &diagram, const clanguml::config::package_diagram &config) | |
Constructor. | |
~translation_unit_visitor () override=default | |
virtual bool | VisitNamespaceDecl (clang::NamespaceDecl *ns) |
virtual bool | VisitEnumDecl (clang::EnumDecl *decl) |
virtual bool | VisitCXXRecordDecl (clang::CXXRecordDecl *cls) |
virtual bool | VisitRecordDecl (clang::RecordDecl *cls) |
virtual bool | VisitClassTemplateDecl (clang::ClassTemplateDecl *decl) |
virtual bool | VisitFunctionDecl (clang::FunctionDecl *function_declaration) |
virtual bool | VisitObjCCategoryDecl (clang::ObjCCategoryDecl *decl) |
virtual bool | VisitObjCProtocolDecl (clang::ObjCProtocolDecl *decl) |
virtual bool | VisitObjCInterfaceDecl (clang::ObjCInterfaceDecl *decl) |
void | finalize () |
Finalize diagram model. | |
Public Member Functions inherited from clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT > | |
translation_unit_visitor (clang::SourceManager &sm, DiagramT &diagram, const ConfigT &config) | |
Constructor. | |
virtual | ~translation_unit_visitor ()=default |
void | set_tu_path (const std::string &translation_unit_path) |
const std::filesystem::path & | tu_path () const |
Return relative path to current translation unit. | |
common::visitor::ast_id_mapper & | id_mapper () const |
Get reference to Clang AST to clang-uml id mapper. | |
clang::SourceManager & | source_manager () const |
Get clang::SourceManager. | |
void | set_source_location (const clang::Decl &decl, clanguml::common::model::source_location &element) |
Set source location in diagram element. | |
void | set_source_location (const clang::Expr &expr, clanguml::common::model::source_location &element) |
Set source location in diagram element. | |
void | set_source_location (const clang::Stmt &stmt, clanguml::common::model::source_location &element) |
void | set_qualified_name (const clang::NamedDecl &decl, clanguml::common::model::element &element) |
void | set_source_location (const clang::SourceLocation &location, clanguml::common::model::source_location &element) |
Set source location in diagram element. | |
void | set_owning_module (const clang::Decl &decl, clanguml::common::model::element &element) |
virtual void | add_diagram_element (std::unique_ptr< common::model::template_element > element) |
void | process_comment (const clang::NamedDecl &decl, clanguml::common::model::decorated_element &e) |
Process comment directives in comment attached to a declaration. | |
std::string | process_comment (const clang::RawComment *comment, clang::DiagnosticsEngine &de, clanguml::common::model::decorated_element &e) |
Process comment directives in raw comment. | |
bool | skip_system_header_decl (const clang::NamedDecl *decl) const |
bool | should_include (const clang::NamedDecl *decl) const |
Check if the diagram should include a declaration. | |
DiagramT & | diagram () |
Get diagram model reference. | |
const DiagramT & | diagram () const |
Get diagram model reference. | |
const ConfigT & | config () const |
Get diagram config instance. | |
Private Member Functions | |
eid_t | get_package_id (const clang::Decl *cls) |
Get global package id for declaration. | |
void | process_class_declaration (const clang::CXXRecordDecl &cls, found_relationships_t &relationships) |
Process class declaration. | |
void | process_class_children (const clang::CXXRecordDecl &cls, found_relationships_t &relationships) |
Process class children. | |
void | process_record_children (const clang::RecordDecl &cls, found_relationships_t &relationships) |
Process record children. | |
void | process_objc_container_children (const clang::ObjCContainerDecl &cls, found_relationships_t &relationships) |
Process ObjC container children. | |
void | process_class_bases (const clang::CXXRecordDecl &cls, found_relationships_t &relationships) |
Process record bases. | |
void | process_method (const clang::CXXMethodDecl &method, found_relationships_t &relationships) |
Process method declaration. | |
void | process_objc_method (const clang::ObjCMethodDecl &mf, found_relationships_t &relationships) |
Process ObjC method declaration. | |
void | process_template_method (const clang::FunctionTemplateDecl &method, found_relationships_t &relationships) |
Process template method declaration. | |
void | process_field (const clang::FieldDecl &field_declaration, found_relationships_t &relationships) |
Process member field. | |
void | process_objc_property (const clang::ObjCPropertyDecl &property_declaration, found_relationships_t &relationships) |
Process ObjC property. | |
void | process_interface_protocol (const clang::ObjCProtocolDecl &protocol_declaration, found_relationships_t &relationships) |
Process ObjC protocol implemented by certain interface. | |
void | process_static_field (const clang::VarDecl &field_declaration, found_relationships_t &relationships) |
Process static member field. | |
void | process_friend (const clang::FriendDecl &friend_declaration, found_relationships_t &relationships) |
Process friend declaration. | |
bool | find_relationships (const clang::Decl *decl, const clang::QualType &type, found_relationships_t &relationships, common::model::relationship_t relationship_hint=common::model::relationship_t::kDependency) |
Process type. | |
void | add_relationships (clang::Decl *cls, found_relationships_t &relationships) |
Add discovered relationships for cls to the diagram. | |
std::vector< eid_t > | get_parent_package_ids (eid_t id) |
Additional Inherited Members | |
Public Types inherited from clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT > | |
using | config_t = ConfigT |
using | diagram_t = DiagramT |
Protected Member Functions inherited from clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT > | |
std::set< const clang::RawComment * > & | processed_comments () |
std::string | get_file_path (const std::string &file_location) const |
clanguml::package_diagram::visitor::translation_unit_visitor::translation_unit_visitor | ( | clang::SourceManager & | sm, |
clanguml::package_diagram::model::diagram & | diagram, | ||
const clanguml::config::package_diagram & | config | ||
) |
Constructor.
sm | Current source manager reference |
diagram | Diagram model |
config | Diagram configuration |
Definition at line 38 of file translation_unit_visitor.cc.
|
overridevirtualdefault |
Reimplemented from clanguml::common::visitor::translation_unit_visitor< ConfigT, DiagramT >.
|
private |
Add discovered relationships for cls
to the diagram.
cls | C/C++ entity declaration |
relationships | List of discovered relationships |
Definition at line 285 of file translation_unit_visitor.cc.
void clanguml::package_diagram::visitor::translation_unit_visitor::finalize | ( | ) |
|
private |
Process type.
type | Reference to some C++ type |
relationships | List of relationships discovered from this friend |
relationship_hint | Default relationship type for discovered relationships |
|
private |
Get global package id for declaration.
This method calculates package diagram id based on either the namespace of the provided declaration or filesystem path of the source file where it was declared - depending on the diagram configuration.
This is necessary to infer dependency relationships between packages.
cls | C++ entity declaration |
Definition at line 396 of file translation_unit_visitor.cc.
|
private |
Definition at line 852 of file translation_unit_visitor.cc.
|
private |
Process record bases.
cls | Class declaration |
relationships | List of relationships discovered from this class |
Definition at line 499 of file translation_unit_visitor.cc.
|
private |
Process class children.
cls | Class declaration |
relationships | List of relationships discovered from this class |
Definition at line 448 of file translation_unit_visitor.cc.
|
private |
Process class declaration.
cls | Class declaration |
relationships | List of relationships discovered from this class |
Definition at line 438 of file translation_unit_visitor.cc.
|
private |
Process member field.
field_declaration | Field declaration |
relationships | List of relationships discovered from this field |
Definition at line 625 of file translation_unit_visitor.cc.
|
private |
Process friend declaration.
friend_declaration | Field declaration |
relationships | List of relationships discovered from this friend |
Definition at line 670 of file translation_unit_visitor.cc.
|
private |
Process ObjC protocol implemented by certain interface.
protocol_declaration | Protocol declaration |
relationships | List of relationships discovered from this protocol |
Definition at line 633 of file translation_unit_visitor.cc.
|
private |
Process method declaration.
method | Method declaration |
relationships | List of relationships discovered from this method |
Definition at line 507 of file translation_unit_visitor.cc.
|
private |
Process ObjC container children.
ObjC container in Clang is a base class for any object (e.g. interface, protocol or category) that can contain methods.
cls | ObjC container declaration |
relationships | List of relationships discovered from this objc container |
Definition at line 567 of file translation_unit_visitor.cc.
|
private |
Process ObjC method declaration.
method | Method declaration |
relationships | List of relationships discovered from this method |
Definition at line 518 of file translation_unit_visitor.cc.
|
private |
Process ObjC property.
property_declaration | Property declaration |
relationships | List of relationships discovered from this property |
Definition at line 642 of file translation_unit_visitor.cc.
|
private |
Process record children.
cls | Record declaration |
relationships | List of relationships discovered from this class |
Definition at line 529 of file translation_unit_visitor.cc.
|
private |
Process static member field.
field_declaration | Field declaration |
relationships | List of relationships discovered from this field |
Definition at line 662 of file translation_unit_visitor.cc.
|
private |
Process template method declaration.
method | Method declaration |
relationships | List of relationships discovered from this method |
Definition at line 605 of file translation_unit_visitor.cc.