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

Method startInteractiveRename

kdevplatform/language/codegen/basicrefactoring.cpp:215–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void BasicRefactoring::startInteractiveRename(const KDevelop::IndexedDeclaration& decl)
216{
217 DUChainReadLocker lock(DUChain::lock());
218
219 Declaration* declaration = decl.data();
220 if (!declaration) {
221 auto* message = new Sublime::Message(i18n("No declaration under cursor"), Sublime::Message::Error);
222 ICore::self()->uiController()->postMessage(message);
223 return;
224 }
225 QFileInfo info(declaration->topContext()->url().str());
226 if (!info.isWritable()) {
227 const QString messageText = i18n("Declaration is located in non-writable file %1.",
228 declaration->topContext()->url().str());
229 auto* message = new Sublime::Message(messageText, Sublime::Message::Error);
230 ICore::self()->uiController()->postMessage(message);
231 return;
232 }
233
234 QString originalName = declaration->identifier().identifier().str();
235 lock.unlock();
236
237 NameAndCollector nc = newNameForDeclaration(DeclarationPointer(declaration));
238
239 if (nc.newName == originalName || nc.newName.isEmpty())
240 return;
241
242 renameCollectedDeclarations(nc.collector.data(), nc.newName, originalName);
243}
244
245bool BasicRefactoring::acceptForContextMenu(const Declaration* decl)
246{

Callers

nothing calls this directly

Calls 10

uiControllerMethod · 0.80
strMethod · 0.80
dataMethod · 0.45
postMessageMethod · 0.45
urlMethod · 0.45
topContextMethod · 0.45
isWritableMethod · 0.45
identifierMethod · 0.45
unlockMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected