| 73 | } |
| 74 | |
| 75 | std::string ModelicaFileImpl::printTree() const { |
| 76 | std::stringstream ss; |
| 77 | |
| 78 | const std::function<void(antlr4::tree::ParseTree*, antlr4::Parser*, int)> to_s = [&ss, &to_s](antlr4::tree::ParseTree* tree, antlr4::Parser* parser, |
| 79 | int indent) { |
| 80 | if (!tree) { |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | // Print indentation |
| 85 | for (int i = 0; i < indent; i++) { |
| 86 | ss << " "; |
| 87 | } |
| 88 | |
| 89 | // Check if the node is a rule (internal) or a leaf (token) |
| 90 | auto* ruleContext = dynamic_cast<antlr4::ParserRuleContext*>(tree); |
| 91 | if (ruleContext) { |
| 92 | // Internal rule node - print rule name |
| 93 | ss << "rule: " << parser->getRuleNames()[ruleContext->getRuleIndex()] << std::endl; // NOLINT |
| 94 | } else { |
| 95 | // Leaf token node - print actual token text |
| 96 | ss << "token: " << tree->getText() << std::endl; // NOLINT |
| 97 | } |
| 98 | |
| 99 | // Recursively print children with increased indentation |
| 100 | for (auto* child : tree->children) { |
| 101 | to_s(child, parser, indent + 1); |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | to_s(m_modelicaParser->stored_definition(), m_modelicaParser.get(), 0); |
| 106 | |
| 107 | return ss.str(); |
| 108 | } |
| 109 | |
| 110 | void ModelicaFileImpl::ensureClassDefinitionCache() { |
| 111 | if (!m_classDefinitionsDirty) { |
nothing calls this directly
no test coverage detected