diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-09-27 18:01:04 +0200 |
---|---|---|
committer | Robert Loehning <robert.loehning@nokia.com> | 2010-09-27 19:07:15 +0200 |
commit | f39494e4c2d2b81901052f513e2a8ce336edf11b (patch) | |
tree | ea6cae48b20a0f93515736ea5829a937c730820d /src/plugins/designer | |
parent | 91208c827f1e796b54137c64bc4c32a9c9e161c2 (diff) | |
download | qt-creator-f39494e4c2d2b81901052f513e2a8ce336edf11b.tar.gz |
C++: make InsertionPointLocator ready for re-use.
(cherry picked from commit 519f1d11947ff3109850e559fae868c4a55deb43)
Diffstat (limited to 'src/plugins/designer')
-rw-r--r-- | src/plugins/designer/qtcreatorintegration.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index a6e48e8834..4b741898ec 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -273,21 +273,24 @@ static inline ITextEditable *editableAt(const QString &fileName, int line, int c return qobject_cast<ITextEditable *>(TextEditor::BaseTextEditor::openEditorAt(fileName, line, column)); } -static void addDeclaration(Document::Ptr doc, const Class *cl, const QString &functionName) +static void addDeclaration(const Snapshot &snapshot, + const QString &fileName, + const Class *cl, + const QString &functionName) { - const QString docFileName = doc->fileName(); QString declaration = QLatin1String("void "); declaration += functionName; declaration += QLatin1String(";\n"); - InsertionPointLocator find(doc); - const InsertionLocation loc = find.methodDeclarationInClass(cl, InsertionPointLocator::PrivateSlot); + InsertionPointLocator find(snapshot); + const InsertionLocation loc = find.methodDeclarationInClass( + fileName, cl, InsertionPointLocator::PrivateSlot); // //! \todo change this to use the Refactoring changes. // - if (ITextEditable *editable = editableAt(docFileName, loc.line(), loc.column() - 1)) { + if (ITextEditable *editable = editableAt(fileName, loc.line(), loc.column() - 1)) { BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(editable->widget()); if (editor) { QTextCursor tc = editor->textCursor(); @@ -302,8 +305,10 @@ static void addDeclaration(Document::Ptr doc, const Class *cl, const QString &fu } static Document::Ptr addDefinition(const CPlusPlus::Snapshot &docTable, - const QString &headerFileName, const QString &className, - const QString &functionName, int *line) + const QString &headerFileName, + const QString &className, + const QString &functionName, + int *line) { QString definition = QLatin1String("\nvoid "); definition += className; @@ -440,6 +445,7 @@ static Document::Ptr getParsedDocument(const QString &fileName, CppTools::CppMod Document::Ptr doc = snapshot.documentFromSource(source, fileName); doc->check(); + snapshot.insert(doc); return doc; } @@ -541,11 +547,12 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, } else { // add function declaration to cl CppTools::CppModelManagerInterface::WorkingCopy workingCopy = cppModelManagerInstance()->workingCopy(); - Document::Ptr tmpDoc = getParsedDocument(doc->fileName(), workingCopy, docTable); - addDeclaration(tmpDoc, cl, functionNameWithParameterNames); + const QString fileName = doc->fileName(); + getParsedDocument(fileName, workingCopy, docTable); + addDeclaration(docTable, fileName, cl, functionNameWithParameterNames); // add function definition to cpp file - sourceDoc = addDefinition(docTable, doc->fileName(), className, functionNameWithParameterNames, &line); + sourceDoc = addDefinition(docTable, fileName, className, functionNameWithParameterNames, &line); } if (!sourceDoc) { |