Commit b8a6a4dd authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Erik Verbruggen
Browse files

CppTools: Move WorkingCopy to new cppworkingcopy.{h,cpp}



Change-Id: I447acf28849bffb52c1e6b6eafdde221ec0b179e
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 077bbf68
......@@ -44,6 +44,7 @@
#include <cpptools/cppdoxygen.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cppworkingcopy.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/convenience.h>
......
......@@ -35,6 +35,8 @@
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <cpptools/cppworkingcopy.h>
#include <QDir>
#include <QFile>
#include <QSet>
......@@ -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.
......
......@@ -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());
......
......@@ -30,8 +30,10 @@
#include "clangutils.h"
#include "cppcreatemarkers.h"
#include <cplusplus/CppDocument.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cppworkingcopy.h>
#include <cplusplus/CppDocument.h>
#include <utils/hostosinfo.h>
#include <utils/runextensions.h>
......
......@@ -36,6 +36,7 @@
#include <cpptools/cppcodemodelinspectordumper.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolseditorsupport.h>
#include <cpptools/cppworkingcopy.h>
#include <projectexplorer/project.h>
#include <cplusplus/CppDocument.h>
......@@ -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);
......
......@@ -53,6 +53,7 @@
#include <cpptools/cpptoolseditorsupport.h>
#include <cpptools/cpptoolsplugin.h>
#include <cpptools/cpptoolsreuse.h>
#include <cpptools/cppworkingcopy.h>
#include <cpptools/symbolfinder.h>
#include <projectexplorer/session.h>
......
......@@ -38,14 +38,15 @@
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpptoolsreuse.h>
#include <extensionsystem/pluginmanager.h>
#include <cpptools/cppworkingcopy.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <texteditor/basetextdocument.h>
#include <utils/algorithm.h>
#include <extensionsystem/pluginmanager.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/TranslationUnit.h>
#include <utils/algorithm.h>
#include <QApplication>
#include <QDebug>
......
......@@ -38,7 +38,7 @@ public:
int dumpFileNameWhileParsing;
int revision;
ProjectPart::HeaderPaths headerPaths;
CppModelManagerInterface::WorkingCopy workingCopy;
WorkingCopy workingCopy;
QStringList sourceFiles;
};
......
......@@ -39,9 +39,6 @@ namespace CppTools {
namespace Internal {
class BuiltinIndexingSupport: public CppIndexingSupport {
public:
typedef CppModelManagerInterface::WorkingCopy WorkingCopy;
public:
BuiltinIndexingSupport();
~BuiltinIndexingSupport();
......
......@@ -29,6 +29,8 @@
#include "cppcodemodelinspectordumper.h"
#include "cppworkingcopy.h"
#include <app/app_version.h>
#include <coreplugin/icore.h>
#include <cpptools/cppprojectfile.h>
......@@ -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";
......
......@@ -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);
......
......@@ -32,6 +32,7 @@
#include "cppcompletionassistprovider.h"
#include "cppmodelmanagerinterface.h"
#include "cppworkingcopy.h"
#include <cplusplus/Icons.h>
#include <cplusplus/TypeOfExpression.h>
......@@ -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;
};
......
......@@ -31,6 +31,7 @@
#include "cpptoolsconstants.h"
#include "cppmodelmanagerinterface.h"
#include "cppworkingcopy.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
......@@ -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<QString, QList<Usage> >
{
const CppModelManagerInterface::WorkingCopy workingCopy;
const WorkingCopy workingCopy;
const Snapshot snapshot;
Document::Ptr symbolDocument;
Symbol *symbol;
QFutureInterface<Usage> *future;
public:
ProcessFile(const CppModelManagerInterface::WorkingCopy &workingCopy,
ProcessFile(const WorkingCopy &workingCopy,
const Snapshot snapshot,
Document::Ptr symbolDocument,
Symbol *symbol,
......@@ -268,7 +269,7 @@ QList<int> CppFindReferences::references(Symbol *symbol, const LookupContext &co
}
static void find_helper(QFutureInterface<Usage> &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<Usage> result;
result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol);
createWatcher(result, search);
......@@ -531,13 +532,13 @@ namespace {
class FindMacroUsesInFile: public std::unary_function<QString, QList<Usage> >
{
const CppModelManagerInterface::WorkingCopy workingCopy;
const WorkingCopy workingCopy;
const Snapshot snapshot;
const Macro &macro;
QFutureInterface<Usage> *future;
public:
FindMacroUsesInFile(const CppModelManagerInterface::WorkingCopy &workingCopy,
FindMacroUsesInFile(const WorkingCopy &workingCopy,
const Snapshot snapshot,
const Macro &macro,
QFutureInterface<Usage> *future)
......@@ -611,7 +612,7 @@ restart_search:
} // end of anonymous namespace
static void findMacroUses_helper(QFutureInterface<Usage> &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 &macro, 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
{
......
......@@ -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<CppModelManager *>(this)->buildWorkingCopyList();
}
......
......@@ -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"
......
......@@ -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<QByteArray, unsigned> get(const QString &fileName) const
{ return _elements.value(fileName); }
QHashIterator<QString, QPair<QByteArray, unsigned> > iterator() const
{ return QHashIterator<QString, QPair<QByteArray, unsigned> >(_elements); }
int size() const
{ return _elements.size(); }
private:
typedef QHash<QString, QPair<QByteArray, unsigned> > Table;
Table _elements;
};
public:
static const QString configurationFileName();
static const QString editorConfigurationFileName();
......
......@@ -32,6 +32,8 @@
#include "cppqtstyleindenter.h"
#include "cppcodeformatter.h"
#include "cppmodelmanager.h"
#include "cppworkingcopy.h"
#include <projectexplorer/editorconfiguration.h>
#include <utils/qtcassert.h>
......@@ -77,7 +79,7 @@ public:
Snapshot m_snapshot;
CppModelManagerInterface *m_modelManager;
CppModelManagerInterface::WorkingCopy m_workingCopy;
WorkingCopy m_workingCopy;
};
......
......@@ -46,7 +46,7 @@ SnapshotUpdater::SnapshotUpdater(const QString &fileInEditor)
{
}
void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
void SnapshotUpdater::update(WorkingCopy workingCopy)
{
QMutexLocker locker(&m_mutex);
......
......@@ -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;
......
......@@ -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 &macro)
{
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)
......
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