Added support for switch statements in sequence diagrams
This commit is contained in:
@@ -144,6 +144,51 @@ std::string to_string(const clang::RecordType &type,
|
||||
return to_string(type.desugar(), ctx, try_canonical);
|
||||
}
|
||||
|
||||
std::string to_string(const clang::Expr *expr)
|
||||
{
|
||||
clang::LangOptions lang_options;
|
||||
std::string result;
|
||||
llvm::raw_string_ostream ostream(result);
|
||||
expr->printPretty(ostream, NULL, clang::PrintingPolicy(lang_options));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_string(const clang::Stmt *stmt)
|
||||
{
|
||||
clang::LangOptions lang_options;
|
||||
std::string result;
|
||||
llvm::raw_string_ostream ostream(result);
|
||||
stmt->printPretty(ostream, NULL, clang::PrintingPolicy(lang_options));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_string(const clang::FunctionTemplateDecl *decl)
|
||||
{
|
||||
std::vector<std::string> template_parameters;
|
||||
// Handle template function
|
||||
for (const auto *parameter : *decl->getTemplateParameters()) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter)) {
|
||||
const auto *template_type_parameter =
|
||||
clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter);
|
||||
|
||||
std::string template_parameter{
|
||||
template_type_parameter->getNameAsString()};
|
||||
|
||||
if (template_type_parameter->isParameterPack())
|
||||
template_parameter += "...";
|
||||
|
||||
template_parameters.emplace_back(std::move(template_parameter));
|
||||
}
|
||||
else {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
return fmt::format("{}<{}>({})", decl->getQualifiedNameAsString(),
|
||||
fmt::join(template_parameters, ","), "");
|
||||
}
|
||||
|
||||
std::string get_source_text_raw(
|
||||
clang::SourceRange range, const clang::SourceManager &sm)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,12 @@ std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx,
|
||||
std::string to_string(const clang::RecordType &type,
|
||||
const clang::ASTContext &ctx, bool try_canonical = true);
|
||||
|
||||
std::string to_string(const clang::Expr *expr);
|
||||
|
||||
std::string to_string(const clang::Stmt *stmt);
|
||||
|
||||
std::string to_string(const clang::FunctionTemplateDecl *decl);
|
||||
|
||||
std::string get_source_text_raw(
|
||||
clang::SourceRange range, const clang::SourceManager &sm);
|
||||
|
||||
|
||||
@@ -100,6 +100,12 @@ std::string to_string(message_t r)
|
||||
return "catch";
|
||||
case message_t::kTryEnd:
|
||||
return "end try";
|
||||
case message_t::kSwitch:
|
||||
return "switch";
|
||||
case message_t::kCase:
|
||||
return "case";
|
||||
case message_t::kSwitchEnd:
|
||||
return "end switch";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
|
||||
@@ -56,6 +56,9 @@ enum class message_t {
|
||||
kTry,
|
||||
kCatch,
|
||||
kTryEnd,
|
||||
kSwitch,
|
||||
kCase,
|
||||
kSwitchEnd,
|
||||
kNone
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user