Added highlight of calls within condition statements of if/else blocks

This commit is contained in:
Bartek Kryza
2022-12-12 21:07:28 +01:00
parent b2396d7b44
commit d7c13edbf9
10 changed files with 93 additions and 9 deletions

View File

@@ -164,6 +164,22 @@ std::string get_source_text(
return get_source_text_raw(printable_range, sm);
}
bool is_subexpr_of(const clang::Stmt *parent_stmt, const clang::Stmt *sub_stmt)
{
if (parent_stmt == nullptr || sub_stmt == nullptr)
return false;
if (parent_stmt == sub_stmt)
return true;
for (const auto *e : parent_stmt->children()) {
if (is_subexpr_of(e, sub_stmt))
return true;
}
return false;
}
template <> id_t to_id(const std::string &full_name)
{
return std::hash<std::string>{}(full_name) >> 3;

View File

@@ -68,6 +68,8 @@ std::string get_source_text_raw(
std::string get_source_text(
clang::SourceRange range, const clang::SourceManager &sm);
bool is_subexpr_of(const clang::Stmt *parent_stmt, const clang::Stmt *sub_stmt);
template <typename T> id_t to_id(const T &declaration);
template <> id_t to_id(const std::string &full_name);

View File

@@ -39,6 +39,7 @@ enum class relationship_t {
kDependency
};
/// Types of sequence diagram activity elements
enum class message_t {
kCall,
kReturn,
@@ -55,6 +56,13 @@ enum class message_t {
kNone
};
/// The scope of the call expression represented in the sequence diagram
enum class message_scope_t {
kNormal, // This is a regular call expression
kCondition // This is a call expression from within a control condition
// e.g if(a->is_valid()) { ... }
};
std::string to_string(relationship_t r);
std::string to_string(access_t r);