| 151 | } |
| 152 | |
| 153 | void Manager::dump(const ReferencedTopDUContext& topContext) |
| 154 | { |
| 155 | if (!topContext) { |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | QTextStream stream(stdout); |
| 160 | |
| 161 | std::cerr << "\n"; |
| 162 | |
| 163 | if (m_args->isSet(QStringLiteral("dump-definitions"))) { |
| 164 | DUChainReadLocker lock; |
| 165 | std::cerr << "Definitions:" << std::endl; |
| 166 | DUChain::definitions()->dump(stream); |
| 167 | std::cerr << std::endl; |
| 168 | } |
| 169 | |
| 170 | if (m_args->isSet(QStringLiteral("dump-symboltable"))) { |
| 171 | DUChainReadLocker lock; |
| 172 | std::cerr << "PersistentSymbolTable:" << std::endl; |
| 173 | PersistentSymbolTable::self().dump(stream); |
| 174 | std::cerr << std::endl; |
| 175 | } |
| 176 | |
| 177 | DUChainDumper::Features features; |
| 178 | if (m_args->isSet(QStringLiteral("dump-context"))) { |
| 179 | features |= DUChainDumper::DumpContext; |
| 180 | } |
| 181 | if (m_args->isSet(QStringLiteral("dump-errors"))) { |
| 182 | features |= DUChainDumper::DumpProblems; |
| 183 | } |
| 184 | |
| 185 | if (auto depth = m_args->value(QStringLiteral("dump-depth")).toInt()) { |
| 186 | DUChainReadLocker lock; |
| 187 | std::cerr << "Context:" << std::endl; |
| 188 | DUChainDumper dumpChain(features); |
| 189 | dumpChain.dump(topContext, depth); |
| 190 | } |
| 191 | |
| 192 | if (m_args->isSet(QStringLiteral("dump-graph"))) { |
| 193 | DUChainReadLocker lock; |
| 194 | DumpDotGraph dumpGraph; |
| 195 | const QString dotOutput = dumpGraph.dotGraph(topContext); |
| 196 | std::cout << qPrintable(dotOutput) << std::endl; |
| 197 | } |
| 198 | |
| 199 | const auto dumpImportedErrors = m_args->isSet(QStringLiteral("dump-imported-errors")); |
| 200 | const auto dumpParentContexts = m_args->isSet(QStringLiteral("dump-parent-contexts")); |
| 201 | if (dumpImportedErrors || dumpParentContexts) { |
| 202 | DUChainReadLocker lock; |
| 203 | const auto imports = topContext->importedParentContexts(); |
| 204 | for (const auto& import : imports) { |
| 205 | auto top = dynamic_cast<TopDUContext*>(import.indexedContext().context()); |
| 206 | if (!top || top == topContext) { |
| 207 | continue; |
| 208 | } |
| 209 | |
| 210 | if (dumpParentContexts) { |