| 163 | } |
| 164 | |
| 165 | void execute(KTextEditor::View* view, const KTextEditor::Range& word) override |
| 166 | { |
| 167 | QString replacement = m_returnType + QLatin1Char(' ') + m_display.replace(QRegularExpression(QStringLiteral("\\s*=\\s*0")), QString()); |
| 168 | |
| 169 | bool appendSpecifer = true; |
| 170 | if (const auto* project = |
| 171 | KDevelop::ICore::self()->projectController()->findProjectForUrl(view->document()->url())) { |
| 172 | const auto arguments = KDevelop::IDefinesAndIncludesManager::manager()->parserArguments( |
| 173 | project->filesForPath(IndexedString(view->document()->url().path())).first()); |
| 174 | const auto match = QRegularExpression(QStringLiteral(R"(-std=c\+\+(\w+))")).match(arguments); |
| 175 | |
| 176 | appendSpecifer = match.hasMatch(); // assume non-modern if no standard is specified |
| 177 | if (appendSpecifer) { |
| 178 | const auto standard = match.capturedView(1); |
| 179 | appendSpecifer = (standard != QLatin1String("98") && standard != QLatin1String("03")); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if (appendSpecifer) { |
| 184 | replacement.append(QLatin1String(" override;")); |
| 185 | } else { |
| 186 | replacement.append(QLatin1Char(';')); |
| 187 | } |
| 188 | |
| 189 | DocumentChange overrideChange(IndexedString(view->document()->url()), |
| 190 | word, |
| 191 | QString{}, |
| 192 | replacement); |
| 193 | overrideChange.m_ignoreOldText = true; |
| 194 | DocumentChangeSet changes; |
| 195 | changes.addChange(overrideChange); |
| 196 | changes.applyAllChanges(); |
| 197 | } |
| 198 | |
| 199 | private: |
| 200 | QString m_returnType; |
nothing calls this directly
no test coverage detected