| 243 | } |
| 244 | |
| 245 | DocumentChangeSet::ChangeResult ClangRefactoring::applyChangesToDeclarations(const QString& oldName, |
| 246 | const QString& newName, |
| 247 | DocumentChangeSet& changes, |
| 248 | const QList<IndexedDeclaration>& declarations) |
| 249 | { |
| 250 | for (const IndexedDeclaration decl : declarations) { |
| 251 | Declaration *declaration = decl.data(); |
| 252 | if (!declaration) |
| 253 | continue; |
| 254 | |
| 255 | if (declaration->range().isEmpty()) |
| 256 | clangDebug() << "found empty declaration:" << declaration->toString(); |
| 257 | |
| 258 | // special handling for dtors, their name is not "Foo", but "~Foo" |
| 259 | // see https://bugs.kde.org/show_bug.cgi?id=373452 |
| 260 | QString fixedOldName = oldName; |
| 261 | QString fixedNewName = newName; |
| 262 | |
| 263 | if (isDestructor(declaration)) { |
| 264 | clangDebug() << "found destructor:" << declaration->toString() << "-- making sure we replace the identifier correctly"; |
| 265 | fixedOldName = QLatin1Char('~') + oldName; |
| 266 | fixedNewName = QLatin1Char('~') + newName; |
| 267 | } |
| 268 | |
| 269 | TopDUContext *top = declaration->topContext(); |
| 270 | DocumentChangeSet::ChangeResult result = changes.addChange(DocumentChange(top->url(), declaration->rangeInCurrentRevision(), fixedOldName, fixedNewName)); |
| 271 | if (!result) |
| 272 | return result; |
| 273 | } |
| 274 | |
| 275 | return KDevelop::DocumentChangeSet::ChangeResult::successfulResult(); |
| 276 | } |
| 277 | |
| 278 | #include "moc_clangrefactoring.cpp" |
nothing calls this directly
no test coverage detected