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