forked from qt-creator/qt-creator
Invalidate the documents in the snapshot that need to be reparsed.
This commit is contained in:
@@ -120,6 +120,9 @@ public:
|
|||||||
void run(QString &fileName);
|
void run(QString &fileName);
|
||||||
void operator()(QString &fileName);
|
void operator()(QString &fileName);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
Snapshot snapshot;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
|
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
|
||||||
|
|
||||||
@@ -141,7 +144,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<CppModelManager> m_modelManager;
|
QPointer<CppModelManager> m_modelManager;
|
||||||
Snapshot m_snapshot;
|
|
||||||
Environment env;
|
Environment env;
|
||||||
Preprocessor m_proc;
|
Preprocessor m_proc;
|
||||||
QStringList m_includePaths;
|
QStringList m_includePaths;
|
||||||
@@ -157,9 +159,9 @@ private:
|
|||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|
||||||
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
|
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
|
||||||
: m_modelManager(modelManager),
|
: snapshot(modelManager->snapshot()),
|
||||||
m_snapshot(modelManager->snapshot()),
|
m_modelManager(modelManager),
|
||||||
m_proc(this, env)
|
m_proc(this, env)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
|
void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
|
||||||
@@ -337,8 +339,13 @@ void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet<QString> *process
|
|||||||
|
|
||||||
processed->insert(fn);
|
processed->insert(fn);
|
||||||
|
|
||||||
foreach (QString includedFile, doc->includedFiles()) {
|
foreach (Document::Include incl, doc->includes()) {
|
||||||
mergeEnvironment(m_snapshot.value(includedFile), processed);
|
QString includedFile = incl.fileName();
|
||||||
|
|
||||||
|
if (Document::Ptr includedDoc = snapshot.value(includedFile))
|
||||||
|
mergeEnvironment(includedDoc, processed);
|
||||||
|
else
|
||||||
|
run(includedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const Macro macro, doc->definedMacros()) {
|
foreach (const Macro macro, doc->definedMacros()) {
|
||||||
@@ -384,7 +391,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! contents.isEmpty()) {
|
if (! contents.isEmpty()) {
|
||||||
Document::Ptr cachedDoc = m_snapshot.value(fileName);
|
Document::Ptr cachedDoc = snapshot.value(fileName);
|
||||||
if (cachedDoc && m_currentDoc) {
|
if (cachedDoc && m_currentDoc) {
|
||||||
mergeEnvironment(cachedDoc);
|
mergeEnvironment(cachedDoc);
|
||||||
} else {
|
} else {
|
||||||
@@ -393,8 +400,8 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
|
|||||||
const QByteArray previousFile = env.currentFile;
|
const QByteArray previousFile = env.currentFile;
|
||||||
const unsigned previousLine = env.currentLine;
|
const unsigned previousLine = env.currentLine;
|
||||||
|
|
||||||
env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(),
|
TranslationUnit *unit = m_currentDoc->translationUnit();
|
||||||
m_currentDoc->translationUnit()->fileNameLength());
|
env.currentFile = QByteArray(unit->fileName(), unit->fileNameLength());
|
||||||
|
|
||||||
QByteArray preprocessedCode;
|
QByteArray preprocessedCode;
|
||||||
m_proc(contents, &preprocessedCode);
|
m_proc(contents, &preprocessedCode);
|
||||||
@@ -775,7 +782,12 @@ void CppModelManager::parse(QFutureInterface<void> &future,
|
|||||||
CppPreprocessor *preproc,
|
CppPreprocessor *preproc,
|
||||||
QStringList files)
|
QStringList files)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!files.isEmpty(), return);
|
if (files.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (QString file, files) {
|
||||||
|
preproc->snapshot.remove(file);
|
||||||
|
}
|
||||||
|
|
||||||
// Change the priority of the background parser thread to idle.
|
// Change the priority of the background parser thread to idle.
|
||||||
QThread::currentThread()->setPriority(QThread::IdlePriority);
|
QThread::currentThread()->setPriority(QThread::IdlePriority);
|
||||||
|
Reference in New Issue
Block a user