forked from qt-creator/qt-creator
Hide the implementation details of CppModelManagerInterface::WorkingCopy.
This commit is contained in:
@@ -68,15 +68,15 @@ namespace {
|
|||||||
|
|
||||||
class ProcessFile: public std::unary_function<QString, QList<Usage> >
|
class ProcessFile: public std::unary_function<QString, QList<Usage> >
|
||||||
{
|
{
|
||||||
const QHash<QString, QString> workingList;
|
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy;
|
||||||
const Snapshot snapshot;
|
const Snapshot snapshot;
|
||||||
Symbol *symbol;
|
Symbol *symbol;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProcessFile(const QHash<QString, QString> workingList,
|
ProcessFile(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy,
|
||||||
const Snapshot snapshot,
|
const Snapshot snapshot,
|
||||||
Symbol *symbol)
|
Symbol *symbol)
|
||||||
: workingList(workingList), snapshot(snapshot), symbol(symbol)
|
: workingCopy(workingCopy), snapshot(snapshot), symbol(symbol)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QList<Usage> operator()(const QString &fileName)
|
QList<Usage> operator()(const QString &fileName)
|
||||||
@@ -92,8 +92,8 @@ public:
|
|||||||
|
|
||||||
QByteArray source;
|
QByteArray source;
|
||||||
|
|
||||||
if (workingList.contains(fileName))
|
if (workingCopy.contains(fileName))
|
||||||
source = snapshot.preprocessedCode(workingList.value(fileName), fileName);
|
source = snapshot.preprocessedCode(workingCopy.source(fileName), fileName);
|
||||||
else {
|
else {
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (! file.open(QFile::ReadOnly))
|
if (! file.open(QFile::ReadOnly))
|
||||||
@@ -168,7 +168,7 @@ QList<int> CppFindReferences::references(Symbol *symbol,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void find_helper(QFutureInterface<Usage> &future,
|
static void find_helper(QFutureInterface<Usage> &future,
|
||||||
const QHash<QString, QString> workingList,
|
const CppTools::CppModelManagerInterface::WorkingCopy workingCopy,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
Symbol *symbol)
|
Symbol *symbol)
|
||||||
{
|
{
|
||||||
@@ -199,7 +199,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
|||||||
|
|
||||||
future.setProgressRange(0, files.size());
|
future.setProgressRange(0, files.size());
|
||||||
|
|
||||||
ProcessFile process(workingList, snapshot, symbol);
|
ProcessFile process(workingCopy, snapshot, symbol);
|
||||||
UpdateUI reduce(&future);
|
UpdateUI reduce(&future);
|
||||||
|
|
||||||
QtConcurrent::blockingMappedReduced<QList<Usage> > (files, process, reduce);
|
QtConcurrent::blockingMappedReduced<QList<Usage> > (files, process, reduce);
|
||||||
|
@@ -171,7 +171,7 @@ public:
|
|||||||
virtual ~CppPreprocessor();
|
virtual ~CppPreprocessor();
|
||||||
|
|
||||||
void setRevision(unsigned revision);
|
void setRevision(unsigned revision);
|
||||||
void setWorkingCopy(const QHash<QString, QString> &workingCopy);
|
void setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy);
|
||||||
void setIncludePaths(const QStringList &includePaths);
|
void setIncludePaths(const QStringList &includePaths);
|
||||||
void setFrameworkPaths(const QStringList &frameworkPaths);
|
void setFrameworkPaths(const QStringList &frameworkPaths);
|
||||||
void setProjectFiles(const QStringList &files);
|
void setProjectFiles(const QStringList &files);
|
||||||
@@ -215,7 +215,7 @@ private:
|
|||||||
Preprocessor preprocess;
|
Preprocessor preprocess;
|
||||||
QStringList m_includePaths;
|
QStringList m_includePaths;
|
||||||
QStringList m_systemIncludePaths;
|
QStringList m_systemIncludePaths;
|
||||||
QHash<QString, QString> m_workingCopy;
|
CppModelManagerInterface::WorkingCopy m_workingCopy;
|
||||||
QStringList m_projectFiles;
|
QStringList m_projectFiles;
|
||||||
QStringList m_frameworkPaths;
|
QStringList m_frameworkPaths;
|
||||||
QSet<QString> m_included;
|
QSet<QString> m_included;
|
||||||
@@ -241,7 +241,7 @@ CppPreprocessor::~CppPreprocessor()
|
|||||||
void CppPreprocessor::setRevision(unsigned revision)
|
void CppPreprocessor::setRevision(unsigned revision)
|
||||||
{ m_revision = revision; }
|
{ m_revision = revision; }
|
||||||
|
|
||||||
void CppPreprocessor::setWorkingCopy(const QHash<QString, QString> &workingCopy)
|
void CppPreprocessor::setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy)
|
||||||
{ m_workingCopy = workingCopy; }
|
{ m_workingCopy = workingCopy; }
|
||||||
|
|
||||||
void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
|
void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
|
||||||
@@ -263,13 +263,13 @@ class Process: public std::unary_function<Document::Ptr, void>
|
|||||||
{
|
{
|
||||||
QPointer<CppModelManager> _modelManager;
|
QPointer<CppModelManager> _modelManager;
|
||||||
Snapshot _snapshot;
|
Snapshot _snapshot;
|
||||||
QHash<QString, QString> _workingCopy;
|
CppModelManager::WorkingCopy _workingCopy;
|
||||||
Document::Ptr _doc;
|
Document::Ptr _doc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Process(QPointer<CppModelManager> modelManager,
|
Process(QPointer<CppModelManager> modelManager,
|
||||||
Snapshot snapshot,
|
Snapshot snapshot,
|
||||||
const QHash<QString, QString> &workingCopy)
|
const CppModelManager::WorkingCopy &workingCopy)
|
||||||
: _modelManager(modelManager),
|
: _modelManager(modelManager),
|
||||||
_snapshot(snapshot),
|
_snapshot(snapshot),
|
||||||
_workingCopy(workingCopy)
|
_workingCopy(workingCopy)
|
||||||
@@ -335,7 +335,7 @@ bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QString *resu
|
|||||||
|
|
||||||
if (m_workingCopy.contains(absoluteFilePath)) {
|
if (m_workingCopy.contains(absoluteFilePath)) {
|
||||||
m_included.insert(absoluteFilePath);
|
m_included.insert(absoluteFilePath);
|
||||||
*result = m_workingCopy.value(absoluteFilePath);
|
*result = m_workingCopy.source(absoluteFilePath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,19 +797,19 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
|
|||||||
TextEditor::ITextEditor *textEditor = it.key();
|
TextEditor::ITextEditor *textEditor = it.key();
|
||||||
CppEditorSupport *editorSupport = it.value();
|
CppEditorSupport *editorSupport = it.value();
|
||||||
QString fileName = textEditor->file()->fileName();
|
QString fileName = textEditor->file()->fileName();
|
||||||
workingCopy[fileName] = editorSupport->contents();
|
workingCopy.insert(fileName, editorSupport->contents());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSetIterator<AbstractEditorSupport *> jt(m_addtionalEditorSupport);
|
QSetIterator<AbstractEditorSupport *> jt(m_addtionalEditorSupport);
|
||||||
while (jt.hasNext()) {
|
while (jt.hasNext()) {
|
||||||
AbstractEditorSupport *es = jt.next();
|
AbstractEditorSupport *es = jt.next();
|
||||||
workingCopy[es->fileName()] = es->contents();
|
workingCopy.insert(es->fileName(), es->contents());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the project configuration file
|
// add the project configuration file
|
||||||
QByteArray conf(pp_configuration);
|
QByteArray conf(pp_configuration);
|
||||||
conf += definedMacros();
|
conf += definedMacros();
|
||||||
workingCopy[pp_configuration_file] = conf;
|
workingCopy.insert(pp_configuration_file, conf);
|
||||||
|
|
||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,30 @@ public:
|
|||||||
QStringList frameworkPaths;
|
QStringList frameworkPaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QHash<QString, QString> WorkingCopy;
|
class WorkingCopy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef QHash<QString, QString> Table;
|
||||||
|
|
||||||
|
typedef Table::const_iterator iterator;
|
||||||
|
typedef Table::const_iterator const_iterator;
|
||||||
|
|
||||||
|
public:
|
||||||
|
const_iterator begin() const { return _elements.begin(); }
|
||||||
|
const_iterator end() const { return _elements.end(); }
|
||||||
|
|
||||||
|
void insert(const QString &fileName, const QString &source)
|
||||||
|
{ _elements.insert(fileName, source); }
|
||||||
|
|
||||||
|
bool contains(const QString &fileName) const
|
||||||
|
{ return _elements.contains(fileName); }
|
||||||
|
|
||||||
|
QString source(const QString &fileName) const
|
||||||
|
{ return _elements.value(fileName); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Table _elements;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppModelManagerInterface(QObject *parent = 0) : QObject(parent) {}
|
CppModelManagerInterface(QObject *parent = 0) : QObject(parent) {}
|
||||||
|
Reference in New Issue
Block a user