summaryrefslogtreecommitdiff
path: root/src/plugins/qmljseditor/qmljsquickfixes.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-08-17 11:35:57 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-08-19 11:12:09 +0200
commit8a6d767a8f2f98ea4e04847f92cff40d661b806f (patch)
tree586e5c539adfbb18623246d00dec5e894288c8e1 /src/plugins/qmljseditor/qmljsquickfixes.cpp
parenta07acad516b5fa1ac503493b4ec28d595f6e1ea0 (diff)
downloadqt-creator-8a6d767a8f2f98ea4e04847f92cff40d661b806f.tar.gz
Refactoring changes: Cleanup and improvements.
Previously RefactoringFiles were usually passed around by value. However, since a RefactoringFile may sometimes own a QTextDocument (when it was read from a file), that's not great and caused the file to be reread after every copy. With this change RefactoringFile becomes noncopyable and is always owned by a shared pointer. This change also allowed having const RefactoringFiles which is useful because they can be safely used from other threads. See CppRefactoringChanges::fileNoEditor. Change-Id: I9045921d6d0f6349f9558ff2a3d8317ea172193b Reviewed-on: http://codereview.qt.nokia.com/3084 Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/qmljseditor/qmljsquickfixes.cpp')
-rw-r--r--src/plugins/qmljseditor/qmljsquickfixes.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/qmljseditor/qmljsquickfixes.cpp b/src/plugins/qmljseditor/qmljsquickfixes.cpp
index 84fd0de6fe..394e8c1d1c 100644
--- a/src/plugins/qmljseditor/qmljsquickfixes.cpp
+++ b/src/plugins/qmljseditor/qmljsquickfixes.cpp
@@ -70,7 +70,7 @@ public:
{
UiObjectInitializer *objectInitializer = 0;
- const int pos = interface->currentFile().cursor().position();
+ const int pos = interface->currentFile()->cursor().position();
if (QmlJS::AST::Node *member = interface->semanticInfo().rangeAt(pos)) {
if (QmlJS::AST::UiObjectBinding *b = QmlJS::AST::cast<QmlJS::AST::UiObjectBinding *>(member)) {
@@ -104,7 +104,8 @@ private:
"Split initializer"));
}
- virtual void performChanges(QmlJSRefactoringFile *currentFile, QmlJSRefactoringChanges *)
+ virtual void performChanges(QmlJSRefactoringFilePtr currentFile,
+ const QmlJSRefactoringChanges &)
{
Q_ASSERT(_objectInitializer != 0);
@@ -123,9 +124,10 @@ private:
changes.insert(currentFile->startOf(_objectInitializer->rbraceToken),
QLatin1String("\n"));
- currentFile->change(changes);
- currentFile->indent(Range(currentFile->startOf(_objectInitializer->lbraceToken),
+ currentFile->setChangeSet(changes);
+ currentFile->appendIndentRange(Range(currentFile->startOf(_objectInitializer->lbraceToken),
currentFile->startOf(_objectInitializer->rbraceToken)));
+ currentFile->apply();
}
};
};