Commit 51d8f468 authored by Christian Kamm's avatar Christian Kamm Committed by Thomas Hartmann

QmlJS: Remove old 'Rename id' action.

Replaced by superior 'Rename Symbol Under Cursor'.

Change-Id: I0d0367d1297fde37d501266ef7df515256c6abd7
Reviewed-on: http://codereview.qt.nokia.com/1428Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@nokia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 35cb3793
......@@ -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
......
......@@ -37,6 +37,7 @@
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljseditor/qmljseditor.h>
#include <texteditor/tabsettings.h>
#include <utils/changeset.h>
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<QmlJSEditor::QmlJSTextEditorWidget*>(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;
......
......@@ -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<AST::SourceLocation> &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()) {
......
......@@ -156,8 +156,6 @@ public:
bool updateSelectedElements() const;
void setUpdateSelectedElements(bool value);
void renameId(const QString &oldId, const QString &newId);
static QVector<QString> 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);
......
......@@ -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()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment