diff --git a/src/plugins/clangcodemodel/clangcompletion.cpp b/src/plugins/clangcodemodel/clangcompletion.cpp index a15b905e6c1..b4456c61b36 100644 --- a/src/plugins/clangcodemodel/clangcompletion.cpp +++ b/src/plugins/clangcodemodel/clangcompletion.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index 9dbb1eea65c..5f2a27ca68f 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -35,6 +35,8 @@ #include #include +#include + #include #include #include @@ -64,7 +66,7 @@ bool isBlacklisted(const QString &path) } } // anonymous namespace -UnsavedFiles createUnsavedFiles(CppModelManagerInterface::WorkingCopy workingCopy) +UnsavedFiles createUnsavedFiles(WorkingCopy workingCopy) { // TODO: change the modelmanager to hold one working copy, and amend it every time we ask for one. // TODO: Reason: the UnsavedFile needs a QByteArray. diff --git a/src/plugins/clangcodemodel/clangutils.h b/src/plugins/clangcodemodel/clangutils.h index bedafe2e0c8..9fa74b54afa 100644 --- a/src/plugins/clangcodemodel/clangutils.h +++ b/src/plugins/clangcodemodel/clangutils.h @@ -37,7 +37,7 @@ namespace ClangCodeModel { namespace Utils { -ClangCodeModel::Internal::UnsavedFiles createUnsavedFiles(CppTools::CppModelManagerInterface::WorkingCopy workingCopy); +ClangCodeModel::Internal::UnsavedFiles createUnsavedFiles(CppTools::WorkingCopy workingCopy); QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart, CppTools::ProjectFile::Kind fileKind); QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart, const QString &fileName = QString()); diff --git a/src/plugins/clangcodemodel/cppcreatemarkers.cpp b/src/plugins/clangcodemodel/cppcreatemarkers.cpp index 5171101ceb1..fc9e96ebdf5 100644 --- a/src/plugins/clangcodemodel/cppcreatemarkers.cpp +++ b/src/plugins/clangcodemodel/cppcreatemarkers.cpp @@ -30,8 +30,10 @@ #include "clangutils.h" #include "cppcreatemarkers.h" -#include #include +#include + +#include #include #include diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp index 2dbf38b24b3..1a65bec3ecf 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1050,7 +1051,7 @@ class WorkingCopyModel : public QAbstractListModel public: WorkingCopyModel(QObject *parent); - void configure(const CppModelManagerInterface::WorkingCopy &workingCopy); + void configure(const WorkingCopy &workingCopy); QModelIndex indexForFile(const QString &filePath); enum Columns { RevisionColumn, FilePathColumn, ColumnCount }; @@ -1078,7 +1079,7 @@ WorkingCopyModel::WorkingCopyModel(QObject *parent) : QAbstractListModel(parent) { } -void WorkingCopyModel::configure(const CppModelManagerInterface::WorkingCopy &workingCopy) +void WorkingCopyModel::configure(const WorkingCopy &workingCopy) { emit layoutAboutToBeChanged(); m_workingCopyList.clear(); @@ -1431,7 +1432,7 @@ void CppCodeModelInspectorDialog::refresh() } // Working Copy - const CppModelManagerInterface::WorkingCopy workingCopy = cmmi->workingCopy(); + const WorkingCopy workingCopy = cmmi->workingCopy(); dumper.dumpWorkingCopy(workingCopy); m_workingCopyModel->configure(workingCopy); m_workingCopyView->resizeColumns(WorkingCopyModel::ColumnCount); diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 7a37d1f746e..b9291961a18 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp index cab09696c5e..10ce9f99b3b 100644 --- a/src/plugins/cppeditor/fileandtokenactions_test.cpp +++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp @@ -38,14 +38,15 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include +#include #include #include diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp index 60874352c98..b16e85864e3 100644 --- a/src/plugins/cpptools/builtinindexingsupport.cpp +++ b/src/plugins/cpptools/builtinindexingsupport.cpp @@ -38,7 +38,7 @@ public: int dumpFileNameWhileParsing; int revision; ProjectPart::HeaderPaths headerPaths; - CppModelManagerInterface::WorkingCopy workingCopy; + WorkingCopy workingCopy; QStringList sourceFiles; }; diff --git a/src/plugins/cpptools/builtinindexingsupport.h b/src/plugins/cpptools/builtinindexingsupport.h index 8a8669d3350..cf1e9beae76 100644 --- a/src/plugins/cpptools/builtinindexingsupport.h +++ b/src/plugins/cpptools/builtinindexingsupport.h @@ -39,9 +39,6 @@ namespace CppTools { namespace Internal { class BuiltinIndexingSupport: public CppIndexingSupport { -public: - typedef CppModelManagerInterface::WorkingCopy WorkingCopy; - public: BuiltinIndexingSupport(); ~BuiltinIndexingSupport(); diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp index 6d6b7487378..9c27db8fe53 100644 --- a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp +++ b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp @@ -29,6 +29,8 @@ #include "cppcodemodelinspectordumper.h" +#include "cppworkingcopy.h" + #include #include #include @@ -578,7 +580,7 @@ void Dumper::dumpSnapshot(const CPlusPlus::Snapshot &snapshot, const QString &ti } } -void Dumper::dumpWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy) +void Dumper::dumpWorkingCopy(const WorkingCopy &workingCopy) { m_out << "Working Copy contains " << workingCopy.size() << " entries{{{1\n"; diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.h b/src/plugins/cpptools/cppcodemodelinspectordumper.h index b7ada3084d6..313229e4861 100644 --- a/src/plugins/cpptools/cppcodemodelinspectordumper.h +++ b/src/plugins/cpptools/cppcodemodelinspectordumper.h @@ -73,7 +73,7 @@ public: void dumpSnapshot(const CPlusPlus::Snapshot &snapshot, const QString &title, bool isGlobalSnapshot = false); - void dumpWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy); + void dumpWorkingCopy(const CppTools::WorkingCopy &workingCopy); void dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths, const QByteArray &mergedMacros); diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h index 4ecabc98117..a63ca76ad47 100644 --- a/src/plugins/cpptools/cppcompletionassist.h +++ b/src/plugins/cpptools/cppcompletionassist.h @@ -32,6 +32,7 @@ #include "cppcompletionassistprovider.h" #include "cppmodelmanagerinterface.h" +#include "cppworkingcopy.h" #include #include @@ -177,7 +178,7 @@ public: bool isObjCEnabled, int position, TextEditor::AssistReason reason, - const CppModelManagerInterface::WorkingCopy &workingCopy) + const WorkingCopy &workingCopy) : TextEditor::DefaultAssistInterface(textDocument, position, editor->document()->filePath(), reason) , m_editor(editor) @@ -212,7 +213,7 @@ private: TextEditor::BaseTextEditor *m_editor; mutable bool m_isObjCEnabled; mutable bool m_gotCppSpecifics; - CppModelManagerInterface::WorkingCopy m_workingCopy; + WorkingCopy m_workingCopy; mutable CPlusPlus::Snapshot m_snapshot; mutable ProjectPart::HeaderPaths m_headerPaths; }; diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 63b3b6a587e..27bd536a400 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -31,6 +31,7 @@ #include "cpptoolsconstants.h" #include "cppmodelmanagerinterface.h" +#include "cppworkingcopy.h" #include #include @@ -54,7 +55,7 @@ using namespace CppTools; using namespace CPlusPlus; static QByteArray getSource(const QString &fileName, - const CppModelManagerInterface::WorkingCopy &workingCopy) + const WorkingCopy &workingCopy) { if (workingCopy.contains(fileName)) { return workingCopy.source(fileName); @@ -167,14 +168,14 @@ namespace { class ProcessFile: public std::unary_function > { - const CppModelManagerInterface::WorkingCopy workingCopy; + const WorkingCopy workingCopy; const Snapshot snapshot; Document::Ptr symbolDocument; Symbol *symbol; QFutureInterface *future; public: - ProcessFile(const CppModelManagerInterface::WorkingCopy &workingCopy, + ProcessFile(const WorkingCopy &workingCopy, const Snapshot snapshot, Document::Ptr symbolDocument, Symbol *symbol, @@ -268,7 +269,7 @@ QList CppFindReferences::references(Symbol *symbol, const LookupContext &co } static void find_helper(QFutureInterface &future, - const CppModelManagerInterface::WorkingCopy workingCopy, + const WorkingCopy workingCopy, const LookupContext context, CppFindReferences *findRefs, Symbol *symbol) @@ -367,7 +368,7 @@ void CppFindReferences::findAll_helper(Core::SearchResult *search, CPlusPlus::Sy this, SLOT(openEditor(Core::SearchResultItem))); Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus); - const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy(); + const WorkingCopy workingCopy = m_modelManager->workingCopy(); QFuture result; result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol); createWatcher(result, search); @@ -531,13 +532,13 @@ namespace { class FindMacroUsesInFile: public std::unary_function > { - const CppModelManagerInterface::WorkingCopy workingCopy; + const WorkingCopy workingCopy; const Snapshot snapshot; const Macro ¯o; QFutureInterface *future; public: - FindMacroUsesInFile(const CppModelManagerInterface::WorkingCopy &workingCopy, + FindMacroUsesInFile(const WorkingCopy &workingCopy, const Snapshot snapshot, const Macro ¯o, QFutureInterface *future) @@ -611,7 +612,7 @@ restart_search: } // end of anonymous namespace static void findMacroUses_helper(QFutureInterface &future, - const CppModelManagerInterface::WorkingCopy workingCopy, + const WorkingCopy workingCopy, const Snapshot snapshot, CppFindReferences *findRefs, const Macro macro) @@ -663,7 +664,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o, const QString &replace connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool))); const Snapshot snapshot = m_modelManager->snapshot(); - const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy(); + const WorkingCopy workingCopy = m_modelManager->workingCopy(); // add the macro definition itself { diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 39fd4d81f08..81824c56bdd 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -479,7 +479,7 @@ void CppModelManager::replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot) m_snapshot = newSnapshot; } -CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList() +WorkingCopy CppModelManager::buildWorkingCopyList() { WorkingCopy workingCopy; @@ -502,7 +502,7 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList() return workingCopy; } -CppModelManager::WorkingCopy CppModelManager::workingCopy() const +WorkingCopy CppModelManager::workingCopy() const { return const_cast(this)->buildWorkingCopyList(); } diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp index 0366a57b39d..2af2cc2c233 100644 --- a/src/plugins/cpptools/cppmodelmanager_test.cpp +++ b/src/plugins/cpptools/cppmodelmanager_test.cpp @@ -672,7 +672,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles() // Check working copy. // An AbstractEditorSupport object should have been added for the ui_* file. CppModelManagerInterface *mm = CppModelManagerInterface::instance(); - CppModelManagerInterface::WorkingCopy workingCopy = mm->workingCopy(); + WorkingCopy workingCopy = mm->workingCopy(); QCOMPARE(workingCopy.size(), 2); // mm->configurationFileName() and "ui_*.h" diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index bd40a9de01d..27eaa6b2276 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -58,6 +58,7 @@ class CppCompletionAssistProvider; class CppEditorSupport; class CppHighlightingSupport; class CppIndexingSupport; +class WorkingCopy; class CPPTOOLS_EXPORT ProjectPart { @@ -200,41 +201,6 @@ public: QByteArray m_defines; }; - /// The working-copy stores all files that are stored on disk in their current state. - /// - /// So, currently the working copy holds: - /// - unsaved content of editors - /// - uic-ed UI files (through \c AbstractEditorSupport) - /// - the preprocessor configuration - /// - /// Contents are keyed on filename, and hold the revision in the editor and the editor's - /// contents encoded as UTF-8. - class CPPTOOLS_EXPORT WorkingCopy - { - public: - void insert(const QString &fileName, const QByteArray &source, unsigned revision = 0) - { _elements.insert(fileName, qMakePair(source, revision)); } - - bool contains(const QString &fileName) const - { return _elements.contains(fileName); } - - QByteArray source(const QString &fileName) const - { return _elements.value(fileName).first; } - - QPair get(const QString &fileName) const - { return _elements.value(fileName); } - - QHashIterator > iterator() const - { return QHashIterator >(_elements); } - - int size() const - { return _elements.size(); } - - private: - typedef QHash > Table; - Table _elements; - }; - public: static const QString configurationFileName(); static const QString editorConfigurationFileName(); diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp index a07d7a404c8..2532f740b02 100644 --- a/src/plugins/cpptools/cpprefactoringchanges.cpp +++ b/src/plugins/cpptools/cpprefactoringchanges.cpp @@ -32,6 +32,8 @@ #include "cppqtstyleindenter.h" #include "cppcodeformatter.h" #include "cppmodelmanager.h" +#include "cppworkingcopy.h" + #include #include @@ -77,7 +79,7 @@ public: Snapshot m_snapshot; CppModelManagerInterface *m_modelManager; - CppModelManagerInterface::WorkingCopy m_workingCopy; + WorkingCopy m_workingCopy; }; diff --git a/src/plugins/cpptools/cppsnapshotupdater.cpp b/src/plugins/cpptools/cppsnapshotupdater.cpp index a534da4d575..c6ef0cde258 100644 --- a/src/plugins/cpptools/cppsnapshotupdater.cpp +++ b/src/plugins/cpptools/cppsnapshotupdater.cpp @@ -46,7 +46,7 @@ SnapshotUpdater::SnapshotUpdater(const QString &fileInEditor) { } -void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy) +void SnapshotUpdater::update(WorkingCopy workingCopy) { QMutexLocker locker(&m_mutex); diff --git a/src/plugins/cpptools/cppsnapshotupdater.h b/src/plugins/cpptools/cppsnapshotupdater.h index 69e054ba75c..b4009de0ab5 100644 --- a/src/plugins/cpptools/cppsnapshotupdater.h +++ b/src/plugins/cpptools/cppsnapshotupdater.h @@ -51,7 +51,7 @@ public: QString fileInEditor() const { return m_fileInEditor; } - void update(CppModelManagerInterface::WorkingCopy workingCopy); + void update(WorkingCopy workingCopy); void releaseSnapshot(); CPlusPlus::Document::Ptr document() const; diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp index 33b2a0896eb..b20ae68d777 100644 --- a/src/plugins/cpptools/cppsourceprocessor.cpp +++ b/src/plugins/cpptools/cppsourceprocessor.cpp @@ -22,7 +22,7 @@ * correctly. * * \sa CPlusPlus::Document - * \sa CppTools::CppModelManagerInterface::WorkingCopy + * \sa CppTools::WorkingCopy */ using namespace CPlusPlus; @@ -69,7 +69,7 @@ inline Message messageNoFileContents(Document::Ptr &document, const QString &fil return Message(Message::Warning, document->fileName(), line, /*column =*/ 0, text); } -inline const Macro revision(const CppModelManagerInterface::WorkingCopy &workingCopy, +inline const Macro revision(const WorkingCopy &workingCopy, const Macro ¯o) { Macro newMacro(macro); @@ -96,7 +96,7 @@ CppSourceProcessor::~CppSourceProcessor() void CppSourceProcessor::setRevision(unsigned revision) { m_revision = revision; } -void CppSourceProcessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy) +void CppSourceProcessor::setWorkingCopy(const WorkingCopy &workingCopy) { m_workingCopy = workingCopy; } void CppSourceProcessor::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths) diff --git a/src/plugins/cpptools/cppsourceprocessor.h b/src/plugins/cpptools/cppsourceprocessor.h index e51315c32cc..a6e0bdb3ab3 100644 --- a/src/plugins/cpptools/cppsourceprocessor.h +++ b/src/plugins/cpptools/cppsourceprocessor.h @@ -2,6 +2,7 @@ #define CPPSOURCEPROCESSOR_H #include "cppmodelmanagerinterface.h" +#include "cppworkingcopy.h" #include #include @@ -39,7 +40,7 @@ public: { m_dumpFileNameWhileParsing = onoff; } void setRevision(unsigned revision); - void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy); + void setWorkingCopy(const CppTools::WorkingCopy &workingCopy); void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths); void setTodo(const QStringList &files); @@ -91,7 +92,7 @@ private: CPlusPlus::Environment m_env; CPlusPlus::Preprocessor m_preprocess; ProjectPart::HeaderPaths m_headerPaths; - CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy; + CppTools::WorkingCopy m_workingCopy; QSet m_included; CPlusPlus::Document::Ptr m_currentDoc; QSet m_todo; diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro index 451be672256..8c0cecb096a 100644 --- a/src/plugins/cpptools/cpptools.pro +++ b/src/plugins/cpptools/cpptools.pro @@ -47,6 +47,7 @@ HEADERS += \ cpptoolsplugin.h \ cpptoolsreuse.h \ cpptoolssettings.h \ + cppworkingcopy.h \ doxygengenerator.h \ functionutils.h \ includeutils.h \ @@ -101,6 +102,7 @@ SOURCES += \ cpptoolsplugin.cpp \ cpptoolsreuse.cpp \ cpptoolssettings.cpp \ + cppworkingcopy.cpp \ doxygengenerator.cpp \ functionutils.cpp \ includeutils.cpp \ diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs index 92c4b303910..0aed824106d 100644 --- a/src/plugins/cpptools/cpptools.qbs +++ b/src/plugins/cpptools/cpptools.qbs @@ -68,6 +68,7 @@ QtcPlugin { "cpptoolsplugin.cpp", "cpptoolsplugin.h", "cpptoolsreuse.cpp", "cpptoolsreuse.h", "cpptoolssettings.cpp", "cpptoolssettings.h", + "cppworkingcopy.cpp", "cppworkingcopy.h", "doxygengenerator.cpp", "doxygengenerator.h", "functionutils.cpp", "functionutils.h", "includeutils.cpp", "includeutils.h", diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp index f6d0ec1ce33..123f93da1b3 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.cpp +++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp @@ -35,6 +35,7 @@ #include "cpplocalsymbols.h" #include +#include #include #include @@ -282,7 +283,7 @@ void CppEditorSupport::updateDocument() } static void parse(QFutureInterface &future, QSharedPointer updater, - CppModelManagerInterface::WorkingCopy workingCopy) + WorkingCopy workingCopy) { future.setProgressRange(0, 1); if (future.isCanceled()) { diff --git a/src/plugins/cpptools/cppworkingcopy.cpp b/src/plugins/cpptools/cppworkingcopy.cpp new file mode 100644 index 00000000000..dfc59ffe6b4 --- /dev/null +++ b/src/plugins/cpptools/cppworkingcopy.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cppworkingcopy.h" + +/*! + \class CppTools::WorkingCopy + \brief The working copy holds among others the unsaved content of editors. + + The working copy holds + - unsaved content of editors + - uic-ed UI files (through \c AbstractEditorSupport) + - the preprocessor configuration + + Contents are keyed on filename, and hold the revision in the editor and the editor's + contents encoded as UTF-8. +*/ + +namespace CppTools { + +WorkingCopy::WorkingCopy() +{ +} + +} // namespace CppTools diff --git a/src/plugins/cpptools/cppworkingcopy.h b/src/plugins/cpptools/cppworkingcopy.h new file mode 100644 index 00000000000..3775838885d --- /dev/null +++ b/src/plugins/cpptools/cppworkingcopy.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CPPWORKINGCOPY_H +#define CPPWORKINGCOPY_H + +#include "cpptools_global.h" + +#include +#include +#include + +namespace CppTools { + +class CPPTOOLS_EXPORT WorkingCopy +{ +public: + WorkingCopy(); + + void insert(const QString &fileName, const QByteArray &source, unsigned revision = 0) + { _elements.insert(fileName, qMakePair(source, revision)); } + + bool contains(const QString &fileName) const + { return _elements.contains(fileName); } + + QByteArray source(const QString &fileName) const + { return _elements.value(fileName).first; } + + QPair get(const QString &fileName) const + { return _elements.value(fileName); } + + QHashIterator > iterator() const + { return QHashIterator >(_elements); } + + int size() const + { return _elements.size(); } + +private: + typedef QHash > Table; + Table _elements; +}; + +} // namespace CppTools + +#endif // CPPWORKINGCOPY_H diff --git a/src/plugins/cpptools/modelmanagertesthelper.cpp b/src/plugins/cpptools/modelmanagertesthelper.cpp index efcf81e4b0a..571a72c785b 100644 --- a/src/plugins/cpptools/modelmanagertesthelper.cpp +++ b/src/plugins/cpptools/modelmanagertesthelper.cpp @@ -29,6 +29,8 @@ #include "modelmanagertesthelper.h" +#include "cppworkingcopy.h" + #include #include diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index f1bcf882748..8090d9785cb 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -68,6 +68,7 @@ #include #include +#include #include #include @@ -2796,18 +2797,18 @@ class BreakpointCorrectionContext { public: explicit BreakpointCorrectionContext(const CPlusPlus::Snapshot &s, - const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy) : + const CppTools::WorkingCopy &workingCopy) : m_snapshot(s), m_workingCopy(workingCopy) {} unsigned fixLineNumber(const QString &fileName, unsigned lineNumber) const; private: const CPlusPlus::Snapshot m_snapshot; - CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy; + CppTools::WorkingCopy m_workingCopy; }; static CPlusPlus::Document::Ptr getParsedDocument(const QString &fileName, - const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy, + const CppTools::WorkingCopy &workingCopy, const CPlusPlus::Snapshot &snapshot) { QByteArray src; diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index 97c7b904020..c1aabdf7d05 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -498,7 +499,7 @@ static inline QString uiClassName(QString formObjectName) } static Document::Ptr getParsedDocument(const QString &fileName, - CppTools::CppModelManagerInterface::WorkingCopy &workingCopy, + CppTools::WorkingCopy &workingCopy, Snapshot &snapshot) { QByteArray src; @@ -553,7 +554,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, newDocTable.insert(it.value()); } } else { - const CppTools::CppModelManagerInterface::WorkingCopy workingCopy = + const CppTools::WorkingCopy workingCopy = CppTools::CppModelManagerInterface::instance()->workingCopy(); QHashIterator > it = workingCopy.iterator(); while (it.hasNext()) { @@ -631,7 +632,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, } } else { // add function declaration to cl - CppTools::CppModelManagerInterface::WorkingCopy workingCopy = + CppTools::WorkingCopy workingCopy = CppTools::CppModelManagerInterface::instance()->workingCopy(); const QString fileName = doc->fileName(); getParsedDocument(fileName, workingCopy, docTable);