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

Method newNameForDeclaration

kdevplatform/language/codegen/basicrefactoring.cpp:273–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273BasicRefactoring::NameAndCollector BasicRefactoring::newNameForDeclaration(
274 const KDevelop::DeclarationPointer& declaration)
275{
276 DUChainReadLocker lock;
277 if (!declaration) {
278 return {};
279 }
280
281 QSharedPointer<BasicRefactoringCollector> collector(new BasicRefactoringCollector(declaration.data()));
282
283 Ui::RenameDialog renameDialog;
284 QDialog dialog;
285 renameDialog.setupUi(&dialog);
286
287 UsesWidget uses(declaration.data(), collector);
288
289 //So the context-links work
290 auto* navigationWidget = declaration->context()->createNavigationWidget(declaration.data());
291 if (navigationWidget)
292 connect(&uses, &UsesWidget::navigateDeclaration, navigationWidget,
293 &AbstractNavigationWidget::navigateDeclaration);
294
295 QString declarationName = declaration->toString();
296 dialog.setWindowTitle(i18nc("@title:window Renaming some declaration", "Rename \"%1\"", declarationName));
297 renameDialog.edit->setText(declaration->identifier().identifier().str());
298 renameDialog.edit->selectAll();
299
300 renameDialog.tabWidget->addTab(&uses, i18nc("@title:tab", "Uses"));
301 if (navigationWidget)
302 renameDialog.tabWidget->addTab(navigationWidget, i18nc("@title:tab", "Declaration Info"));
303 lock.unlock();
304
305 if (dialog.exec() != QDialog::Accepted)
306 return {};
307
308 const auto text = renameDialog.edit->text().trimmed();
309 RefactoringProgressDialog refactoringProgress(i18n("Renaming \"%1\" to \"%2\"", declarationName,
310 text), collector.data());
311 if (!collector->isReady()) {
312 if (refactoringProgress.exec() != QDialog::Accepted) { // krazy:exclude=crashy
313 return {};
314 }
315 }
316
317 //TODO: input validation
318 return {
319 text, collector
320 };
321}
322
323DocumentChangeSet BasicRefactoring::renameCollectedDeclarations(KDevelop::BasicRefactoringCollector* collector,
324 const QString& replacementName,

Callers

nothing calls this directly

Calls 13

setupUiMethod · 0.80
strMethod · 0.80
execMethod · 0.80
dataMethod · 0.45
contextMethod · 0.45
toStringMethod · 0.45
setTextMethod · 0.45
identifierMethod · 0.45
selectAllMethod · 0.45
unlockMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected