diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 056f4586092..413c30d62ea 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -2713,14 +2713,13 @@ \section1 Renaming Symbols - The functions available for renaming symbols depend on whether you are - writing C++ or QML code. For QML, you can only rename IDs. - To rename a specific symbol in a Qt project: \list 1 \o In the editor, place the cursor on the symbol you would like to change and select \gui Tools > \gui C++ > - \gui{Rename Symbol Under Cursor} or press \key Ctrl+Shift+R. + \gui{Rename Symbol Under Cursor} or \gui Tools > \gui QML/JS > + \gui{Rename Symbol Under Cursor}. Alternatively press + \key Ctrl+Shift+R. The \gui{Search Results} pane opens and shows the location and number of instances of the symbol in the current project. @@ -2740,17 +2739,6 @@ The instances of the symbol are highlighted in code and you can edit the symbol. All instances of the local symbol are changed as you type. - To rename an ID in a Qt Quick project: - - \list 1 - - \o Right-click an ID in the QML code and select - \gui {Rename id}. - - \o In the \gui {Rename id} field, enter the new ID. - - \endlist - \section1 Applying Refactoring Actions Qt Creator allows you to quickly and conveniently apply actions to refactor diff --git a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp index 6d8678ff0e5..a78f5a98c27 100644 --- a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp +++ b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp @@ -37,6 +37,7 @@ #include #include #include +#include using namespace QmlDesigner; @@ -74,7 +75,12 @@ int BaseTextEditModifier::indentDepth() const bool BaseTextEditModifier::renameId(const QString &oldId, const QString &newId) { if (QmlJSEditor::QmlJSTextEditorWidget *qmljse = qobject_cast(plainTextEdit())) { - qmljse->renameId(oldId, newId); + Utils::ChangeSet changeSet; + foreach (const QmlJS::AST::SourceLocation &loc, qmljse->semanticInfo().idLocations.value(oldId)) { + changeSet.replace(loc.begin(), loc.end(), newId); + } + QTextCursor tc = qmljse->textCursor(); + changeSet.apply(&tc); return true; } else { return false; diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index dd7fd644847..175f1386e53 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -979,18 +979,6 @@ void QmlJSTextEditorWidget::setUpdateSelectedElements(bool value) m_updateSelectedElements = value; } -void QmlJSTextEditorWidget::renameId(const QString &oldId, const QString &newId) -{ - Utils::ChangeSet changeSet; - - foreach (const AST::SourceLocation &loc, m_semanticInfo.idLocations.value(oldId)) { - changeSet.replace(loc.begin(), loc.end(), newId); - } - - QTextCursor tc = textCursor(); - changeSet.apply(&tc); -} - void QmlJSTextEditorWidget::updateUsesNow() { if (document()->revision() != m_semanticInfo.revision()) { @@ -1164,20 +1152,6 @@ void QmlJSTextEditorWidget::updateFileName() { } -void QmlJSTextEditorWidget::renameIdUnderCursor() -{ - const QString id = wordUnderCursor(); - bool ok = false; - const QString newId = QInputDialog::getText(Core::ICore::instance()->mainWindow(), - tr("Rename..."), - tr("New id:"), - QLineEdit::Normal, - id, &ok); - if (ok) { - renameId(id, newId); - } -} - void QmlJSTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) { TextEditor::BaseTextEditorWidget::setFontSettings(fs); @@ -1361,14 +1335,6 @@ void QmlJSTextEditorWidget::contextMenuEvent(QContextMenuEvent *e) QMenu *refactoringMenu = new QMenu(tr("Refactoring"), menu); - // Conditionally add the rename-id action: - const QString id = wordUnderCursor(); - const QList &locations = m_semanticInfo.idLocations.value(id); - if (! locations.isEmpty()) { - QAction *a = refactoringMenu->addAction(tr("Rename id '%1'...").arg(id)); - connect(a, SIGNAL(triggered()), this, SLOT(renameIdUnderCursor())); - } - QSignalMapper mapper; connect(&mapper, SIGNAL(mapped(int)), this, SLOT(performQuickFix(int))); if (! isOutdated()) { diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 09997b8d28e..f5ef2b733c4 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -156,8 +156,6 @@ public: bool updateSelectedElements() const; void setUpdateSelectedElements(bool value); - void renameId(const QString &oldId, const QString &newId); - static QVector highlighterFormatCategories(); TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind, @@ -192,9 +190,6 @@ private slots: void updateUses(); void updateUsesNow(); - // refactoring ops - void renameIdUnderCursor(); - void semanticRehighlight(); void forceSemanticRehighlightIfCurrentEditor(); void updateSemanticInfo(const QmlJSEditor::SemanticInfo &semanticInfo); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 5d1315fc008..0c691a63a17 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -180,7 +180,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); - QAction *renameUsagesAction = new QAction(tr("Rename Usages"), this); + QAction *renameUsagesAction = new QAction(tr("Rename Symbol Under Cursor"), this); cmd = am->registerAction(renameUsagesAction, Constants::RENAME_USAGES, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+R"))); connect(renameUsagesAction, SIGNAL(triggered()), this, SLOT(renameUsages()));