forked from qt-creator/qt-creator
CppTools: Move WorkingCopy to new cppworkingcopy.{h,cpp}
Change-Id: I447acf28849bffb52c1e6b6eafdde221ec0b179e Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
077bbf6803
commit
b8a6a4dd4e
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <cpptools/cppdoxygen.h>
|
#include <cpptools/cppdoxygen.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
#include <texteditor/convenience.h>
|
#include <texteditor/convenience.h>
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
|
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
@@ -64,7 +66,7 @@ bool isBlacklisted(const QString &path)
|
|||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // 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: change the modelmanager to hold one working copy, and amend it every time we ask for one.
|
||||||
// TODO: Reason: the UnsavedFile needs a QByteArray.
|
// TODO: Reason: the UnsavedFile needs a QByteArray.
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
namespace Utils {
|
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, CppTools::ProjectFile::Kind fileKind);
|
||||||
QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart, const QString &fileName = QString());
|
QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart, const QString &fileName = QString());
|
||||||
|
|||||||
@@ -30,8 +30,10 @@
|
|||||||
#include "clangutils.h"
|
#include "clangutils.h"
|
||||||
#include "cppcreatemarkers.h"
|
#include "cppcreatemarkers.h"
|
||||||
|
|
||||||
#include <cplusplus/CppDocument.h>
|
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
|
|
||||||
|
#include <cplusplus/CppDocument.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/runextensions.h>
|
#include <utils/runextensions.h>
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <cpptools/cppcodemodelinspectordumper.h>
|
#include <cpptools/cppcodemodelinspectordumper.h>
|
||||||
#include <cpptools/cppmodelmanager.h>
|
#include <cpptools/cppmodelmanager.h>
|
||||||
#include <cpptools/cpptoolseditorsupport.h>
|
#include <cpptools/cpptoolseditorsupport.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
@@ -1050,7 +1051,7 @@ class WorkingCopyModel : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
WorkingCopyModel(QObject *parent);
|
WorkingCopyModel(QObject *parent);
|
||||||
|
|
||||||
void configure(const CppModelManagerInterface::WorkingCopy &workingCopy);
|
void configure(const WorkingCopy &workingCopy);
|
||||||
QModelIndex indexForFile(const QString &filePath);
|
QModelIndex indexForFile(const QString &filePath);
|
||||||
|
|
||||||
enum Columns { RevisionColumn, FilePathColumn, ColumnCount };
|
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();
|
emit layoutAboutToBeChanged();
|
||||||
m_workingCopyList.clear();
|
m_workingCopyList.clear();
|
||||||
@@ -1431,7 +1432,7 @@ void CppCodeModelInspectorDialog::refresh()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Working Copy
|
// Working Copy
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy = cmmi->workingCopy();
|
const WorkingCopy workingCopy = cmmi->workingCopy();
|
||||||
dumper.dumpWorkingCopy(workingCopy);
|
dumper.dumpWorkingCopy(workingCopy);
|
||||||
m_workingCopyModel->configure(workingCopy);
|
m_workingCopyModel->configure(workingCopy);
|
||||||
m_workingCopyView->resizeColumns(WorkingCopyModel::ColumnCount);
|
m_workingCopyView->resizeColumns(WorkingCopyModel::ColumnCount);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include <cpptools/cpptoolseditorsupport.h>
|
#include <cpptools/cpptoolseditorsupport.h>
|
||||||
#include <cpptools/cpptoolsplugin.h>
|
#include <cpptools/cpptoolsplugin.h>
|
||||||
#include <cpptools/cpptoolsreuse.h>
|
#include <cpptools/cpptoolsreuse.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
#include <cpptools/symbolfinder.h>
|
#include <cpptools/symbolfinder.h>
|
||||||
|
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
|||||||
@@ -38,14 +38,15 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <cpptools/cpptoolsreuse.h>
|
#include <cpptools/cpptoolsreuse.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <cpptools/cppworkingcopy.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
#include <utils/algorithm.h>
|
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
#include <cplusplus/TranslationUnit.h>
|
#include <cplusplus/TranslationUnit.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
int dumpFileNameWhileParsing;
|
int dumpFileNameWhileParsing;
|
||||||
int revision;
|
int revision;
|
||||||
ProjectPart::HeaderPaths headerPaths;
|
ProjectPart::HeaderPaths headerPaths;
|
||||||
CppModelManagerInterface::WorkingCopy workingCopy;
|
WorkingCopy workingCopy;
|
||||||
QStringList sourceFiles;
|
QStringList sourceFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ namespace CppTools {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BuiltinIndexingSupport: public CppIndexingSupport {
|
class BuiltinIndexingSupport: public CppIndexingSupport {
|
||||||
public:
|
|
||||||
typedef CppModelManagerInterface::WorkingCopy WorkingCopy;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BuiltinIndexingSupport();
|
BuiltinIndexingSupport();
|
||||||
~BuiltinIndexingSupport();
|
~BuiltinIndexingSupport();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include "cppcodemodelinspectordumper.h"
|
#include "cppcodemodelinspectordumper.h"
|
||||||
|
|
||||||
|
#include "cppworkingcopy.h"
|
||||||
|
|
||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <cpptools/cppprojectfile.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";
|
m_out << "Working Copy contains " << workingCopy.size() << " entries{{{1\n";
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
void dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
|
void dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
bool isGlobalSnapshot = false);
|
bool isGlobalSnapshot = false);
|
||||||
void dumpWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
|
void dumpWorkingCopy(const CppTools::WorkingCopy &workingCopy);
|
||||||
void dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths,
|
void dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths,
|
||||||
const QByteArray &mergedMacros);
|
const QByteArray &mergedMacros);
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "cppcompletionassistprovider.h"
|
#include "cppcompletionassistprovider.h"
|
||||||
#include "cppmodelmanagerinterface.h"
|
#include "cppmodelmanagerinterface.h"
|
||||||
|
#include "cppworkingcopy.h"
|
||||||
|
|
||||||
#include <cplusplus/Icons.h>
|
#include <cplusplus/Icons.h>
|
||||||
#include <cplusplus/TypeOfExpression.h>
|
#include <cplusplus/TypeOfExpression.h>
|
||||||
@@ -177,7 +178,7 @@ public:
|
|||||||
bool isObjCEnabled,
|
bool isObjCEnabled,
|
||||||
int position,
|
int position,
|
||||||
TextEditor::AssistReason reason,
|
TextEditor::AssistReason reason,
|
||||||
const CppModelManagerInterface::WorkingCopy &workingCopy)
|
const WorkingCopy &workingCopy)
|
||||||
: TextEditor::DefaultAssistInterface(textDocument, position, editor->document()->filePath(),
|
: TextEditor::DefaultAssistInterface(textDocument, position, editor->document()->filePath(),
|
||||||
reason)
|
reason)
|
||||||
, m_editor(editor)
|
, m_editor(editor)
|
||||||
@@ -212,7 +213,7 @@ private:
|
|||||||
TextEditor::BaseTextEditor *m_editor;
|
TextEditor::BaseTextEditor *m_editor;
|
||||||
mutable bool m_isObjCEnabled;
|
mutable bool m_isObjCEnabled;
|
||||||
mutable bool m_gotCppSpecifics;
|
mutable bool m_gotCppSpecifics;
|
||||||
CppModelManagerInterface::WorkingCopy m_workingCopy;
|
WorkingCopy m_workingCopy;
|
||||||
mutable CPlusPlus::Snapshot m_snapshot;
|
mutable CPlusPlus::Snapshot m_snapshot;
|
||||||
mutable ProjectPart::HeaderPaths m_headerPaths;
|
mutable ProjectPart::HeaderPaths m_headerPaths;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
#include "cppmodelmanagerinterface.h"
|
#include "cppmodelmanagerinterface.h"
|
||||||
|
#include "cppworkingcopy.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -54,7 +55,7 @@ using namespace CppTools;
|
|||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
static QByteArray getSource(const QString &fileName,
|
static QByteArray getSource(const QString &fileName,
|
||||||
const CppModelManagerInterface::WorkingCopy &workingCopy)
|
const WorkingCopy &workingCopy)
|
||||||
{
|
{
|
||||||
if (workingCopy.contains(fileName)) {
|
if (workingCopy.contains(fileName)) {
|
||||||
return workingCopy.source(fileName);
|
return workingCopy.source(fileName);
|
||||||
@@ -167,14 +168,14 @@ namespace {
|
|||||||
|
|
||||||
class ProcessFile: public std::unary_function<QString, QList<Usage> >
|
class ProcessFile: public std::unary_function<QString, QList<Usage> >
|
||||||
{
|
{
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy;
|
const WorkingCopy workingCopy;
|
||||||
const Snapshot snapshot;
|
const Snapshot snapshot;
|
||||||
Document::Ptr symbolDocument;
|
Document::Ptr symbolDocument;
|
||||||
Symbol *symbol;
|
Symbol *symbol;
|
||||||
QFutureInterface<Usage> *future;
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProcessFile(const CppModelManagerInterface::WorkingCopy &workingCopy,
|
ProcessFile(const WorkingCopy &workingCopy,
|
||||||
const Snapshot snapshot,
|
const Snapshot snapshot,
|
||||||
Document::Ptr symbolDocument,
|
Document::Ptr symbolDocument,
|
||||||
Symbol *symbol,
|
Symbol *symbol,
|
||||||
@@ -268,7 +269,7 @@ QList<int> CppFindReferences::references(Symbol *symbol, const LookupContext &co
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void find_helper(QFutureInterface<Usage> &future,
|
static void find_helper(QFutureInterface<Usage> &future,
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy,
|
const WorkingCopy workingCopy,
|
||||||
const LookupContext context,
|
const LookupContext context,
|
||||||
CppFindReferences *findRefs,
|
CppFindReferences *findRefs,
|
||||||
Symbol *symbol)
|
Symbol *symbol)
|
||||||
@@ -367,7 +368,7 @@ void CppFindReferences::findAll_helper(Core::SearchResult *search, CPlusPlus::Sy
|
|||||||
this, SLOT(openEditor(Core::SearchResultItem)));
|
this, SLOT(openEditor(Core::SearchResultItem)));
|
||||||
|
|
||||||
Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy();
|
const WorkingCopy workingCopy = m_modelManager->workingCopy();
|
||||||
QFuture<Usage> result;
|
QFuture<Usage> result;
|
||||||
result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol);
|
result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol);
|
||||||
createWatcher(result, search);
|
createWatcher(result, search);
|
||||||
@@ -531,13 +532,13 @@ namespace {
|
|||||||
|
|
||||||
class FindMacroUsesInFile: public std::unary_function<QString, QList<Usage> >
|
class FindMacroUsesInFile: public std::unary_function<QString, QList<Usage> >
|
||||||
{
|
{
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy;
|
const WorkingCopy workingCopy;
|
||||||
const Snapshot snapshot;
|
const Snapshot snapshot;
|
||||||
const Macro ¯o;
|
const Macro ¯o;
|
||||||
QFutureInterface<Usage> *future;
|
QFutureInterface<Usage> *future;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FindMacroUsesInFile(const CppModelManagerInterface::WorkingCopy &workingCopy,
|
FindMacroUsesInFile(const WorkingCopy &workingCopy,
|
||||||
const Snapshot snapshot,
|
const Snapshot snapshot,
|
||||||
const Macro ¯o,
|
const Macro ¯o,
|
||||||
QFutureInterface<Usage> *future)
|
QFutureInterface<Usage> *future)
|
||||||
@@ -611,7 +612,7 @@ restart_search:
|
|||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
static void findMacroUses_helper(QFutureInterface<Usage> &future,
|
static void findMacroUses_helper(QFutureInterface<Usage> &future,
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy,
|
const WorkingCopy workingCopy,
|
||||||
const Snapshot snapshot,
|
const Snapshot snapshot,
|
||||||
CppFindReferences *findRefs,
|
CppFindReferences *findRefs,
|
||||||
const Macro macro)
|
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)));
|
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
|
|
||||||
const Snapshot snapshot = m_modelManager->snapshot();
|
const Snapshot snapshot = m_modelManager->snapshot();
|
||||||
const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy();
|
const WorkingCopy workingCopy = m_modelManager->workingCopy();
|
||||||
|
|
||||||
// add the macro definition itself
|
// add the macro definition itself
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ void CppModelManager::replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot)
|
|||||||
m_snapshot = newSnapshot;
|
m_snapshot = newSnapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
|
WorkingCopy CppModelManager::buildWorkingCopyList()
|
||||||
{
|
{
|
||||||
WorkingCopy workingCopy;
|
WorkingCopy workingCopy;
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
|
|||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppModelManager::WorkingCopy CppModelManager::workingCopy() const
|
WorkingCopy CppModelManager::workingCopy() const
|
||||||
{
|
{
|
||||||
return const_cast<CppModelManager *>(this)->buildWorkingCopyList();
|
return const_cast<CppModelManager *>(this)->buildWorkingCopyList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
|
|||||||
// Check working copy.
|
// Check working copy.
|
||||||
// An AbstractEditorSupport object should have been added for the ui_* file.
|
// An AbstractEditorSupport object should have been added for the ui_* file.
|
||||||
CppModelManagerInterface *mm = CppModelManagerInterface::instance();
|
CppModelManagerInterface *mm = CppModelManagerInterface::instance();
|
||||||
CppModelManagerInterface::WorkingCopy workingCopy = mm->workingCopy();
|
WorkingCopy workingCopy = mm->workingCopy();
|
||||||
|
|
||||||
QCOMPARE(workingCopy.size(), 2); // mm->configurationFileName() and "ui_*.h"
|
QCOMPARE(workingCopy.size(), 2); // mm->configurationFileName() and "ui_*.h"
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class CppCompletionAssistProvider;
|
|||||||
class CppEditorSupport;
|
class CppEditorSupport;
|
||||||
class CppHighlightingSupport;
|
class CppHighlightingSupport;
|
||||||
class CppIndexingSupport;
|
class CppIndexingSupport;
|
||||||
|
class WorkingCopy;
|
||||||
|
|
||||||
class CPPTOOLS_EXPORT ProjectPart
|
class CPPTOOLS_EXPORT ProjectPart
|
||||||
{
|
{
|
||||||
@@ -200,41 +201,6 @@ public:
|
|||||||
QByteArray m_defines;
|
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:
|
public:
|
||||||
static const QString configurationFileName();
|
static const QString configurationFileName();
|
||||||
static const QString editorConfigurationFileName();
|
static const QString editorConfigurationFileName();
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include "cppqtstyleindenter.h"
|
#include "cppqtstyleindenter.h"
|
||||||
#include "cppcodeformatter.h"
|
#include "cppcodeformatter.h"
|
||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
|
#include "cppworkingcopy.h"
|
||||||
|
|
||||||
#include <projectexplorer/editorconfiguration.h>
|
#include <projectexplorer/editorconfiguration.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -77,7 +79,7 @@ public:
|
|||||||
|
|
||||||
Snapshot m_snapshot;
|
Snapshot m_snapshot;
|
||||||
CppModelManagerInterface *m_modelManager;
|
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);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
QString fileInEditor() const
|
QString fileInEditor() const
|
||||||
{ return m_fileInEditor; }
|
{ return m_fileInEditor; }
|
||||||
|
|
||||||
void update(CppModelManagerInterface::WorkingCopy workingCopy);
|
void update(WorkingCopy workingCopy);
|
||||||
void releaseSnapshot();
|
void releaseSnapshot();
|
||||||
|
|
||||||
CPlusPlus::Document::Ptr document() const;
|
CPlusPlus::Document::Ptr document() const;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* correctly.
|
* correctly.
|
||||||
*
|
*
|
||||||
* \sa CPlusPlus::Document
|
* \sa CPlusPlus::Document
|
||||||
* \sa CppTools::CppModelManagerInterface::WorkingCopy
|
* \sa CppTools::WorkingCopy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
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);
|
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)
|
const Macro ¯o)
|
||||||
{
|
{
|
||||||
Macro newMacro(macro);
|
Macro newMacro(macro);
|
||||||
@@ -96,7 +96,7 @@ CppSourceProcessor::~CppSourceProcessor()
|
|||||||
void CppSourceProcessor::setRevision(unsigned revision)
|
void CppSourceProcessor::setRevision(unsigned revision)
|
||||||
{ m_revision = revision; }
|
{ m_revision = revision; }
|
||||||
|
|
||||||
void CppSourceProcessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy)
|
void CppSourceProcessor::setWorkingCopy(const WorkingCopy &workingCopy)
|
||||||
{ m_workingCopy = workingCopy; }
|
{ m_workingCopy = workingCopy; }
|
||||||
|
|
||||||
void CppSourceProcessor::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
|
void CppSourceProcessor::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define CPPSOURCEPROCESSOR_H
|
#define CPPSOURCEPROCESSOR_H
|
||||||
|
|
||||||
#include "cppmodelmanagerinterface.h"
|
#include "cppmodelmanagerinterface.h"
|
||||||
|
#include "cppworkingcopy.h"
|
||||||
|
|
||||||
#include <cplusplus/PreprocessorEnvironment.h>
|
#include <cplusplus/PreprocessorEnvironment.h>
|
||||||
#include <cplusplus/pp-engine.h>
|
#include <cplusplus/pp-engine.h>
|
||||||
@@ -39,7 +40,7 @@ public:
|
|||||||
{ m_dumpFileNameWhileParsing = onoff; }
|
{ m_dumpFileNameWhileParsing = onoff; }
|
||||||
|
|
||||||
void setRevision(unsigned revision);
|
void setRevision(unsigned revision);
|
||||||
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
|
void setWorkingCopy(const CppTools::WorkingCopy &workingCopy);
|
||||||
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
|
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
|
||||||
void setTodo(const QStringList &files);
|
void setTodo(const QStringList &files);
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ private:
|
|||||||
CPlusPlus::Environment m_env;
|
CPlusPlus::Environment m_env;
|
||||||
CPlusPlus::Preprocessor m_preprocess;
|
CPlusPlus::Preprocessor m_preprocess;
|
||||||
ProjectPart::HeaderPaths m_headerPaths;
|
ProjectPart::HeaderPaths m_headerPaths;
|
||||||
CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy;
|
CppTools::WorkingCopy m_workingCopy;
|
||||||
QSet<QString> m_included;
|
QSet<QString> m_included;
|
||||||
CPlusPlus::Document::Ptr m_currentDoc;
|
CPlusPlus::Document::Ptr m_currentDoc;
|
||||||
QSet<QString> m_todo;
|
QSet<QString> m_todo;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ HEADERS += \
|
|||||||
cpptoolsplugin.h \
|
cpptoolsplugin.h \
|
||||||
cpptoolsreuse.h \
|
cpptoolsreuse.h \
|
||||||
cpptoolssettings.h \
|
cpptoolssettings.h \
|
||||||
|
cppworkingcopy.h \
|
||||||
doxygengenerator.h \
|
doxygengenerator.h \
|
||||||
functionutils.h \
|
functionutils.h \
|
||||||
includeutils.h \
|
includeutils.h \
|
||||||
@@ -101,6 +102,7 @@ SOURCES += \
|
|||||||
cpptoolsplugin.cpp \
|
cpptoolsplugin.cpp \
|
||||||
cpptoolsreuse.cpp \
|
cpptoolsreuse.cpp \
|
||||||
cpptoolssettings.cpp \
|
cpptoolssettings.cpp \
|
||||||
|
cppworkingcopy.cpp \
|
||||||
doxygengenerator.cpp \
|
doxygengenerator.cpp \
|
||||||
functionutils.cpp \
|
functionutils.cpp \
|
||||||
includeutils.cpp \
|
includeutils.cpp \
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ QtcPlugin {
|
|||||||
"cpptoolsplugin.cpp", "cpptoolsplugin.h",
|
"cpptoolsplugin.cpp", "cpptoolsplugin.h",
|
||||||
"cpptoolsreuse.cpp", "cpptoolsreuse.h",
|
"cpptoolsreuse.cpp", "cpptoolsreuse.h",
|
||||||
"cpptoolssettings.cpp", "cpptoolssettings.h",
|
"cpptoolssettings.cpp", "cpptoolssettings.h",
|
||||||
|
"cppworkingcopy.cpp", "cppworkingcopy.h",
|
||||||
"doxygengenerator.cpp", "doxygengenerator.h",
|
"doxygengenerator.cpp", "doxygengenerator.h",
|
||||||
"functionutils.cpp", "functionutils.h",
|
"functionutils.cpp", "functionutils.h",
|
||||||
"includeutils.cpp", "includeutils.h",
|
"includeutils.cpp", "includeutils.h",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "cpplocalsymbols.h"
|
#include "cpplocalsymbols.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/runextensions.h>
|
#include <utils/runextensions.h>
|
||||||
@@ -282,7 +283,7 @@ void CppEditorSupport::updateDocument()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater,
|
static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater,
|
||||||
CppModelManagerInterface::WorkingCopy workingCopy)
|
WorkingCopy workingCopy)
|
||||||
{
|
{
|
||||||
future.setProgressRange(0, 1);
|
future.setProgressRange(0, 1);
|
||||||
if (future.isCanceled()) {
|
if (future.isCanceled()) {
|
||||||
|
|||||||
51
src/plugins/cpptools/cppworkingcopy.cpp
Normal file
51
src/plugins/cpptools/cppworkingcopy.cpp
Normal file
@@ -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
|
||||||
71
src/plugins/cpptools/cppworkingcopy.h
Normal file
71
src/plugins/cpptools/cppworkingcopy.h
Normal file
@@ -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 <QHash>
|
||||||
|
#include <QString>
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
|
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<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;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CppTools
|
||||||
|
|
||||||
|
#endif // CPPWORKINGCOPY_H
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include "modelmanagertesthelper.h"
|
#include "modelmanagertesthelper.h"
|
||||||
|
|
||||||
|
#include "cppworkingcopy.h"
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|||||||
@@ -68,6 +68,7 @@
|
|||||||
|
|
||||||
#include <cplusplus/findcdbbreakpoint.h>
|
#include <cplusplus/findcdbbreakpoint.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -2796,18 +2797,18 @@ class BreakpointCorrectionContext
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit BreakpointCorrectionContext(const CPlusPlus::Snapshot &s,
|
explicit BreakpointCorrectionContext(const CPlusPlus::Snapshot &s,
|
||||||
const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy) :
|
const CppTools::WorkingCopy &workingCopy) :
|
||||||
m_snapshot(s), m_workingCopy(workingCopy) {}
|
m_snapshot(s), m_workingCopy(workingCopy) {}
|
||||||
|
|
||||||
unsigned fixLineNumber(const QString &fileName, unsigned lineNumber) const;
|
unsigned fixLineNumber(const QString &fileName, unsigned lineNumber) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CPlusPlus::Snapshot m_snapshot;
|
const CPlusPlus::Snapshot m_snapshot;
|
||||||
CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy;
|
CppTools::WorkingCopy m_workingCopy;
|
||||||
};
|
};
|
||||||
|
|
||||||
static CPlusPlus::Document::Ptr getParsedDocument(const QString &fileName,
|
static CPlusPlus::Document::Ptr getParsedDocument(const QString &fileName,
|
||||||
const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy,
|
const CppTools::WorkingCopy &workingCopy,
|
||||||
const CPlusPlus::Snapshot &snapshot)
|
const CPlusPlus::Snapshot &snapshot)
|
||||||
{
|
{
|
||||||
QByteArray src;
|
QByteArray src;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <cpptools/cpptoolsconstants.h>
|
#include <cpptools/cpptoolsconstants.h>
|
||||||
|
#include <cpptools/cppworkingcopy.h>
|
||||||
#include <cpptools/insertionpointlocator.h>
|
#include <cpptools/insertionpointlocator.h>
|
||||||
#include <cpptools/symbolfinder.h>
|
#include <cpptools/symbolfinder.h>
|
||||||
#include <cplusplus/Overview.h>
|
#include <cplusplus/Overview.h>
|
||||||
@@ -498,7 +499,7 @@ static inline QString uiClassName(QString formObjectName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Document::Ptr getParsedDocument(const QString &fileName,
|
static Document::Ptr getParsedDocument(const QString &fileName,
|
||||||
CppTools::CppModelManagerInterface::WorkingCopy &workingCopy,
|
CppTools::WorkingCopy &workingCopy,
|
||||||
Snapshot &snapshot)
|
Snapshot &snapshot)
|
||||||
{
|
{
|
||||||
QByteArray src;
|
QByteArray src;
|
||||||
@@ -553,7 +554,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
|
|||||||
newDocTable.insert(it.value());
|
newDocTable.insert(it.value());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy =
|
const CppTools::WorkingCopy workingCopy =
|
||||||
CppTools::CppModelManagerInterface::instance()->workingCopy();
|
CppTools::CppModelManagerInterface::instance()->workingCopy();
|
||||||
QHashIterator<QString, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
|
QHashIterator<QString, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@@ -631,7 +632,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// add function declaration to cl
|
// add function declaration to cl
|
||||||
CppTools::CppModelManagerInterface::WorkingCopy workingCopy =
|
CppTools::WorkingCopy workingCopy =
|
||||||
CppTools::CppModelManagerInterface::instance()->workingCopy();
|
CppTools::CppModelManagerInterface::instance()->workingCopy();
|
||||||
const QString fileName = doc->fileName();
|
const QString fileName = doc->fileName();
|
||||||
getParsedDocument(fileName, workingCopy, docTable);
|
getParsedDocument(fileName, workingCopy, docTable);
|
||||||
|
|||||||
Reference in New Issue
Block a user