| 213 | } |
| 214 | |
| 215 | void 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 | |
| 245 | bool BasicRefactoring::acceptForContextMenu(const Declaration* decl) |
| 246 | { |
nothing calls this directly
no test coverage detected