MCPcopy Create free account
hub / github.com/KDE/kdevelop / applyChangesToDeclarations

Method applyChangesToDeclarations

plugins/clang/codegen/clangrefactoring.cpp:245–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245DocumentChangeSet::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"

Callers

nothing calls this directly

Calls 9

isDestructorFunction · 0.85
addChangeMethod · 0.80
dataMethod · 0.45
isEmptyMethod · 0.45
rangeMethod · 0.45
toStringMethod · 0.45
topContextMethod · 0.45
urlMethod · 0.45

Tested by

no test coverage detected