| 69 | } |
| 70 | |
| 71 | void Manager::init() |
| 72 | { |
| 73 | if (m_args->positionalArguments().isEmpty()) { |
| 74 | std::cerr << "Need file or directory to duchainify" << std::endl; |
| 75 | QCoreApplication::exit(1); |
| 76 | } |
| 77 | |
| 78 | TopDUContext::Features features = TopDUContext::VisibleDeclarationsAndContexts; |
| 79 | if (m_args->isSet(QStringLiteral("features"))) { |
| 80 | QString featuresStr = m_args->value(QStringLiteral("features")); |
| 81 | if (featuresStr == QLatin1String("visible-declarations")) { |
| 82 | features = TopDUContext::VisibleDeclarationsAndContexts; |
| 83 | } else if (featuresStr == QLatin1String("all-declarations")) { |
| 84 | features = TopDUContext::AllDeclarationsAndContexts; |
| 85 | } else if (featuresStr == QLatin1String("all-declarations-and-uses")) { |
| 86 | features = TopDUContext::AllDeclarationsContextsAndUses; |
| 87 | } else if (featuresStr == QLatin1String("all-declarations-and-uses-and-AST")) { |
| 88 | features = TopDUContext::AllDeclarationsContextsAndUses | TopDUContext::AST; |
| 89 | } else if (featuresStr == QLatin1String("empty")) { |
| 90 | features = TopDUContext::Empty; |
| 91 | } else if (featuresStr == QLatin1String("simplified-visible-declarations")) { |
| 92 | features = TopDUContext::SimplifiedVisibleDeclarationsAndContexts; |
| 93 | } else { |
| 94 | std::cerr << "Wrong feature-string given\n"; |
| 95 | QCoreApplication::exit(2); |
| 96 | return; |
| 97 | } |
| 98 | } |
| 99 | if (m_args->isSet(QStringLiteral("force-update"))) |
| 100 | features |= TopDUContext::ForceUpdate; |
| 101 | if (m_args->isSet(QStringLiteral("force-update-recursive"))) |
| 102 | features |= TopDUContext::ForceUpdateRecursive; |
| 103 | |
| 104 | if (m_args->isSet(QStringLiteral("threads"))) { |
| 105 | bool ok = false; |
| 106 | int count = m_args->value(QStringLiteral("threads")).toInt(&ok); |
| 107 | ICore::self()->languageController()->backgroundParser()->setThreadCount(count); |
| 108 | if (!ok) { |
| 109 | std::cerr << "bad thread count\n"; |
| 110 | QCoreApplication::exit(3); |
| 111 | return; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | // quit when everything is done |
| 116 | // background parser emits hideProgress() signal in two situations: |
| 117 | // when everything is done and when bgparser is suspended |
| 118 | // later doesn't happen in duchain, so just rely on hideProgress() |
| 119 | // and quit when it's emitted |
| 120 | connect(ICore::self()->languageController()->backgroundParser(), &BackgroundParser::hideProgress, this, |
| 121 | &Manager::finishIfDone); |
| 122 | |
| 123 | const auto files = m_args->positionalArguments(); |
| 124 | for (const auto& file : files) { |
| 125 | addToBackgroundParser(file, features); |
| 126 | } |
| 127 | |
| 128 | m_allFilesAdded = 1; |
nothing calls this directly
no test coverage detected