CppTools: Rename CppPreprocessor to CppSourceProcessor

...since it does quite a bit more than only preprocessing, as the name
suggests. We use that class to process source files in general. The
output is not a preprocessed source, but a set of CPlusPlus::Documents
with symbols.

Change-Id: I787d0f22f9f042ddf0c99e8c2f0bdb9aa7001735
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-05-16 15:51:04 -04:00
parent 43895b038f
commit ec97d967e6
13 changed files with 117 additions and 116 deletions

View File

@@ -36,8 +36,8 @@
#include <cpptools/cppcodestylepreferences.h> #include <cpptools/cppcodestylepreferences.h>
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <cpptools/cpppreprocessertesthelper.h> #include <cpptools/cppsourceprocessertesthelper.h>
#include <cpptools/cpppreprocessor.h> #include <cpptools/cppsourceprocessor.h>
#include <cpptools/cpptoolssettings.h> #include <cpptools/cpptoolssettings.h>
#include <cpptools/includeutils.h> #include <cpptools/includeutils.h>
@@ -1859,9 +1859,9 @@ QList<Include> includesForSource(const QByteArray &source)
CppModelManager *cmm = CppModelManager::instance(); CppModelManager *cmm = CppModelManager::instance();
cmm->GC(); cmm->GC();
CppPreprocessor pp((QPointer<CppModelManager>(cmm))); CppSourceProcessor sourceProcessor((QPointer<CppModelManager>(cmm)));
pp.setIncludePaths(QStringList(TestIncludePaths::globalIncludePath())); sourceProcessor.setIncludePaths(QStringList(TestIncludePaths::globalIncludePath()));
pp.run(fileName); sourceProcessor.run(fileName);
Document::Ptr document = cmm->document(fileName); Document::Ptr document = cmm->document(fileName);
return document->resolvedIncludes(); return document->resolvedIncludes();

View File

@@ -1,7 +1,7 @@
#include "builtinindexingsupport.h" #include "builtinindexingsupport.h"
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
#include "cpppreprocessor.h" #include "cppsourceprocessor.h"
#include "searchsymbols.h" #include "searchsymbols.h"
#include "cpptoolsconstants.h" #include "cpptoolsconstants.h"
#include "cpptoolsplugin.h" #include "cpptoolsplugin.h"
@@ -22,7 +22,7 @@ static const bool DumpFileNameWhileParsing = qgetenv("QTC_DUMP_FILENAME_WHILE_PA
namespace { namespace {
static void parse(QFutureInterface<void> &future, static void parse(QFutureInterface<void> &future,
CppPreprocessor *preproc, CppSourceProcessor *sourceProcessor,
QStringList files) QStringList files)
{ {
if (files.isEmpty()) if (files.isEmpty())
@@ -32,7 +32,7 @@ static void parse(QFutureInterface<void> &future,
QStringList headers; QStringList headers;
foreach (const QString &file, files) { foreach (const QString &file, files) {
preproc->removeFromCache(file); sourceProcessor->removeFromCache(file);
if (ProjectFile::isSource(ProjectFile::classify(file))) if (ProjectFile::isSource(ProjectFile::classify(file)))
sources.append(file); sources.append(file);
else else
@@ -43,7 +43,7 @@ static void parse(QFutureInterface<void> &future,
files = sources; files = sources;
files += headers; files += headers;
preproc->setTodo(files); sourceProcessor->setTodo(files);
future.setProgressRange(0, files.size()); future.setProgressRange(0, files.size());
@@ -63,9 +63,9 @@ static void parse(QFutureInterface<void> &future,
const bool isSourceFile = i < sourceCount; const bool isSourceFile = i < sourceCount;
if (isSourceFile) { if (isSourceFile) {
(void) preproc->run(conf); (void) sourceProcessor->run(conf);
} else if (!processingHeaders) { } else if (!processingHeaders) {
(void) preproc->run(conf); (void) sourceProcessor->run(conf);
processingHeaders = true; processingHeaders = true;
} }
@@ -74,19 +74,19 @@ static void parse(QFutureInterface<void> &future,
QStringList includePaths = parts.isEmpty() QStringList includePaths = parts.isEmpty()
? fallbackIncludePaths ? fallbackIncludePaths
: parts.first()->includePaths; : parts.first()->includePaths;
preproc->setIncludePaths(includePaths); sourceProcessor->setIncludePaths(includePaths);
preproc->run(fileName); sourceProcessor->run(fileName);
future.setProgressValue(files.size() - preproc->todo().size()); future.setProgressValue(files.size() - sourceProcessor->todo().size());
if (isSourceFile) if (isSourceFile)
preproc->resetEnvironment(); sourceProcessor->resetEnvironment();
} }
future.setProgressValue(files.size()); future.setProgressValue(files.size());
preproc->modelManager()->finishedRefreshingSourceFiles(files); sourceProcessor->modelManager()->finishedRefreshingSourceFiles(files);
delete preproc; delete sourceProcessor;
} }
class BuiltinSymbolSearcher: public SymbolSearcher class BuiltinSymbolSearcher: public SymbolSearcher
@@ -184,7 +184,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sour
CppModelManager *mgr = CppModelManager::instance(); CppModelManager *mgr = CppModelManager::instance();
const WorkingCopy workingCopy = mgr->workingCopy(); const WorkingCopy workingCopy = mgr->workingCopy();
CppPreprocessor *preproc = new CppPreprocessor(mgr, m_dumpFileNameWhileParsing); CppSourceProcessor *preproc = new CppSourceProcessor(mgr, m_dumpFileNameWhileParsing);
preproc->setRevision(++m_revision); preproc->setRevision(++m_revision);
preproc->setIncludePaths(mgr->includePaths()); preproc->setIncludePaths(mgr->includePaths());
preproc->setFrameworkPaths(mgr->frameworkPaths()); preproc->setFrameworkPaths(mgr->frameworkPaths());

View File

@@ -37,7 +37,7 @@
#include "cpphighlightingsupport.h" #include "cpphighlightingsupport.h"
#include "cppindexingsupport.h" #include "cppindexingsupport.h"
#include "cppmodelmanagersupportinternal.h" #include "cppmodelmanagersupportinternal.h"
#include "cpppreprocessor.h" #include "cppsourceprocessor.h"
#include "cpptoolsconstants.h" #include "cpptoolsconstants.h"
#include "cpptoolseditorsupport.h" #include "cpptoolseditorsupport.h"
#include "cpptoolsplugin.h" #include "cpptoolsplugin.h"
@@ -310,7 +310,7 @@ QStringList CppModelManager::internalIncludePaths() const
const ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
foreach (const QString &path, part->includePaths) foreach (const QString &path, part->includePaths)
includePaths.append(CppPreprocessor::cleanPath(path)); includePaths.append(CppSourceProcessor::cleanPath(path));
} }
includePaths.removeDuplicates(); includePaths.removeDuplicates();
return includePaths; return includePaths;
@@ -325,7 +325,7 @@ QStringList CppModelManager::internalFrameworkPaths() const
const ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
foreach (const QString &path, part->frameworkPaths) foreach (const QString &path, part->frameworkPaths)
frameworkPaths.append(CppPreprocessor::cleanPath(path)); frameworkPaths.append(CppSourceProcessor::cleanPath(path));
} }
frameworkPaths.removeDuplicates(); frameworkPaths.removeDuplicates();
return frameworkPaths; return frameworkPaths;

View File

@@ -27,7 +27,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cpppreprocessor.h" #include "cppsourceprocessor.h"
#include "cpptoolseditorsupport.h" #include "cpptoolseditorsupport.h"
#include "cpptoolsplugin.h" #include "cpptoolsplugin.h"
#include "cpptoolstestcase.h" #include "cpptoolstestcase.h"
@@ -345,7 +345,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
/// QTCREATORBUG-9205 /// QTCREATORBUG-9205
/// Check: When reparsing the same files again, no errors occur /// Check: When reparsing the same files again, no errors occur
/// (The CppPreprocessor's already seen files are properly cleared!). /// (The CppSourceProcessor's already seen files are properly cleared!).
void CppToolsPlugin::test_modelmanager_refresh_several_times() void CppToolsPlugin::test_modelmanager_refresh_several_times()
{ {
ModelManagerTestHelper helper; ModelManagerTestHelper helper;
@@ -646,7 +646,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
/// Check: (1) For a project with a *.ui file an AbstractEditorSupport object /// Check: (1) For a project with a *.ui file an AbstractEditorSupport object
/// is added for the ui_* file. /// is added for the ui_* file.
/// Check: (2) The CppPreprocessor can successfully resolve the ui_* file /// Check: (2) The CppSourceProcessor can successfully resolve the ui_* file
/// though it might not be actually generated in the build dir. /// though it might not be actually generated in the build dir.
void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles() void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
{ {
@@ -678,8 +678,8 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
QCOMPARE(fileNamesInWorkinCopy.at(0), mm->configurationFileName()); QCOMPARE(fileNamesInWorkinCopy.at(0), mm->configurationFileName());
QCOMPARE(fileNamesInWorkinCopy.at(1), expectedUiHeaderFileName); QCOMPARE(fileNamesInWorkinCopy.at(1), expectedUiHeaderFileName);
// Check CppPreprocessor / includes. // Check CppSourceProcessor / includes.
// The CppPreprocessor is expected to find the ui_* file in the working copy. // The CppSourceProcessor is expected to find the ui_* file in the working copy.
const QString fileIncludingTheUiFile = testDataDirectory.file(_("mainwindow.cpp")); const QString fileIncludingTheUiFile = testDataDirectory.file(_("mainwindow.cpp"));
while (!mm->snapshot().document(fileIncludingTheUiFile)) while (!mm->snapshot().document(fileIncludingTheUiFile))
QCoreApplication::processEvents(); QCoreApplication::processEvents();

View File

@@ -27,7 +27,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "cpppreprocessor.h" #include "cppsourceprocessor.h"
#include "cppsnapshotupdater.h" #include "cppsnapshotupdater.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -159,25 +159,25 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
workingCopy.insert(editorDefinesFileName, m_editorDefines); workingCopy.insert(editorDefinesFileName, m_editorDefines);
} }
CppPreprocessor preproc(modelManager, m_snapshot); CppSourceProcessor sourceProcessor(modelManager, m_snapshot);
Snapshot globalSnapshot = modelManager->snapshot(); Snapshot globalSnapshot = modelManager->snapshot();
globalSnapshot.remove(fileInEditor()); globalSnapshot.remove(fileInEditor());
preproc.setGlobalSnapshot(globalSnapshot); sourceProcessor.setGlobalSnapshot(globalSnapshot);
preproc.setWorkingCopy(workingCopy); sourceProcessor.setWorkingCopy(workingCopy);
preproc.setIncludePaths(m_includePaths); sourceProcessor.setIncludePaths(m_includePaths);
preproc.setFrameworkPaths(m_frameworkPaths); sourceProcessor.setFrameworkPaths(m_frameworkPaths);
preproc.run(configurationFileName); sourceProcessor.run(configurationFileName);
if (!m_projectConfigFile.isEmpty()) if (!m_projectConfigFile.isEmpty())
preproc.run(m_projectConfigFile); sourceProcessor.run(m_projectConfigFile);
if (m_usePrecompiledHeaders) { if (m_usePrecompiledHeaders) {
foreach (const QString &precompiledHeader, m_precompiledHeaders) foreach (const QString &precompiledHeader, m_precompiledHeaders)
preproc.run(precompiledHeader); sourceProcessor.run(precompiledHeader);
} }
if (!m_editorDefines.isEmpty()) if (!m_editorDefines.isEmpty())
preproc.run(editorDefinesFileName); sourceProcessor.run(editorDefinesFileName);
preproc.run(m_fileInEditor); sourceProcessor.run(m_fileInEditor);
m_snapshot = preproc.snapshot(); m_snapshot = sourceProcessor.snapshot();
Snapshot newSnapshot = m_snapshot.simplified(document()); Snapshot newSnapshot = m_snapshot.simplified(document());
for (Snapshot::const_iterator i = m_snapshot.begin(), ei = m_snapshot.end(); i != ei; ++i) { for (Snapshot::const_iterator i = m_snapshot.begin(), ei = m_snapshot.end(); i != ei; ++i) {
if (Client::isInjectedFile(i.key())) if (Client::isInjectedFile(i.key()))

View File

@@ -28,7 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include "cpppreprocessertesthelper.h" #include "cppsourceprocessertesthelper.h"
#include <QDir> #include <QDir>

View File

@@ -28,8 +28,8 @@
****************************************************************************/ ****************************************************************************/
#ifndef CPPPREPROCESSERTESTHELPER_H #ifndef CPPPSOURCEPROCESSERTESTHELPER_H
#define CPPPREPROCESSERTESTHELPER_H #define CPPPSOURCEPROCESSERTESTHELPER_H
#include "cpptools_global.h" #include "cpptools_global.h"
@@ -56,4 +56,4 @@ public:
} // namespace Tests } // namespace Tests
} // namespace CppTools } // namespace CppTools
#endif // CPPPREPROCESSERTESTHELPER_H #endif // CPPPSOURCEPROCESSERTESTHELPER_H

View File

@@ -1,4 +1,4 @@
#include "cpppreprocessor.h" #include "cppsourceprocessor.h"
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
@@ -13,8 +13,8 @@
#include <QTextCodec> #include <QTextCodec>
/*! /*!
* \class CppTools::Internal::CppPreprocessor * \class CppTools::Internal::CppSourceProcessor
* \brief The CppPreprocessor class updates set of indexed C++ files. * \brief The CppSourceProcessor class updates set of indexed C++ files.
* *
* Indexed file is truncated version of fully parsed document: copy of source * Indexed file is truncated version of fully parsed document: copy of source
* code and full AST will be dropped when indexing is done. Working copy ensures * code and full AST will be dropped when indexing is done. Working copy ensures
@@ -28,8 +28,8 @@ using namespace CPlusPlus;
using namespace CppTools; using namespace CppTools;
using namespace CppTools::Internal; using namespace CppTools::Internal;
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager, CppSourceProcessor::CppSourceProcessor(QPointer<CppModelManager> modelManager,
bool dumpFileNameWhileParsing) bool dumpFileNameWhileParsing)
: m_snapshot(modelManager->snapshot()), : m_snapshot(modelManager->snapshot()),
m_modelManager(modelManager), m_modelManager(modelManager),
m_dumpFileNameWhileParsing(dumpFileNameWhileParsing), m_dumpFileNameWhileParsing(dumpFileNameWhileParsing),
@@ -40,8 +40,9 @@ CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager,
m_preprocess.setKeepComments(true); m_preprocess.setKeepComments(true);
} }
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager, const Snapshot &snapshot, CppSourceProcessor::CppSourceProcessor(QPointer<CppModelManager> modelManager,
bool dumpFileNameWhileParsing) const Snapshot &snapshot,
bool dumpFileNameWhileParsing)
: m_snapshot(snapshot), : m_snapshot(snapshot),
m_modelManager(modelManager), m_modelManager(modelManager),
m_dumpFileNameWhileParsing(dumpFileNameWhileParsing), m_dumpFileNameWhileParsing(dumpFileNameWhileParsing),
@@ -52,16 +53,16 @@ CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager, const S
m_preprocess.setKeepComments(true); m_preprocess.setKeepComments(true);
} }
CppPreprocessor::~CppPreprocessor() CppSourceProcessor::~CppSourceProcessor()
{ } { }
void CppPreprocessor::setRevision(unsigned revision) void CppSourceProcessor::setRevision(unsigned revision)
{ m_revision = revision; } { m_revision = revision; }
void CppPreprocessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy) void CppSourceProcessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy)
{ m_workingCopy = workingCopy; } { m_workingCopy = workingCopy; }
void CppPreprocessor::setIncludePaths(const QStringList &includePaths) void CppSourceProcessor::setIncludePaths(const QStringList &includePaths)
{ {
m_includePaths.clear(); m_includePaths.clear();
@@ -86,7 +87,7 @@ void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
} }
} }
void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths) void CppSourceProcessor::setFrameworkPaths(const QStringList &frameworkPaths)
{ {
m_frameworkPaths.clear(); m_frameworkPaths.clear();
foreach (const QString &frameworkPath, frameworkPaths) foreach (const QString &frameworkPath, frameworkPaths)
@@ -100,7 +101,7 @@ void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths)
// has private frameworks in: // has private frameworks in:
// <framework-path>/ApplicationServices.framework/Frameworks // <framework-path>/ApplicationServices.framework/Frameworks
// if the "Frameworks" folder exists inside the top level framework. // if the "Frameworks" folder exists inside the top level framework.
void CppPreprocessor::addFrameworkPath(const QString &frameworkPath) void CppSourceProcessor::addFrameworkPath(const QString &frameworkPath)
{ {
// The algorithm below is a bit too eager, but that's because we're not getting // The algorithm below is a bit too eager, but that's because we're not getting
// in the frameworks we're linking against. If we would have that, then we could // in the frameworks we're linking against. If we would have that, then we could
@@ -121,7 +122,7 @@ void CppPreprocessor::addFrameworkPath(const QString &frameworkPath)
} }
} }
void CppPreprocessor::setTodo(const QStringList &files) void CppSourceProcessor::setTodo(const QStringList &files)
{ m_todo = QSet<QString>::fromList(files); } { m_todo = QSet<QString>::fromList(files); }
namespace { namespace {
@@ -155,26 +156,26 @@ public:
}; };
} // end of anonymous namespace } // end of anonymous namespace
void CppPreprocessor::run(const QString &fileName) void CppSourceProcessor::run(const QString &fileName)
{ {
sourceNeeded(0, fileName, IncludeGlobal); sourceNeeded(0, fileName, IncludeGlobal);
} }
void CppPreprocessor::removeFromCache(const QString &fileName) void CppSourceProcessor::removeFromCache(const QString &fileName)
{ {
m_snapshot.remove(fileName); m_snapshot.remove(fileName);
} }
void CppPreprocessor::resetEnvironment() void CppSourceProcessor::resetEnvironment()
{ {
m_env.reset(); m_env.reset();
m_processed.clear(); m_processed.clear();
m_included.clear(); m_included.clear();
} }
bool CppPreprocessor::getFileContents(const QString &absoluteFilePath, bool CppSourceProcessor::getFileContents(const QString &absoluteFilePath,
QByteArray *contents, QByteArray *contents,
unsigned *revision) const unsigned *revision) const
{ {
if (absoluteFilePath.isEmpty() || !contents || !revision) if (absoluteFilePath.isEmpty() || !contents || !revision)
return false; return false;
@@ -199,7 +200,7 @@ bool CppPreprocessor::getFileContents(const QString &absoluteFilePath,
return true; return true;
} }
bool CppPreprocessor::checkFile(const QString &absoluteFilePath) const bool CppSourceProcessor::checkFile(const QString &absoluteFilePath) const
{ {
if (absoluteFilePath.isEmpty() if (absoluteFilePath.isEmpty()
|| m_included.contains(absoluteFilePath) || m_included.contains(absoluteFilePath)
@@ -212,7 +213,7 @@ bool CppPreprocessor::checkFile(const QString &absoluteFilePath) const
} }
/// Resolve the given file name to its absolute path w.r.t. the include type. /// Resolve the given file name to its absolute path w.r.t. the include type.
QString CppPreprocessor::resolveFile(const QString &fileName, IncludeType type) QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType type)
{ {
if (type == IncludeGlobal) { if (type == IncludeGlobal) {
QHash<QString, QString>::ConstIterator it = m_fileNameCache.find(fileName); QHash<QString, QString>::ConstIterator it = m_fileNameCache.find(fileName);
@@ -227,7 +228,7 @@ QString CppPreprocessor::resolveFile(const QString &fileName, IncludeType type)
return resolveFile_helper(fileName, type); return resolveFile_helper(fileName, type);
} }
QString CppPreprocessor::cleanPath(const QString &path) QString CppSourceProcessor::cleanPath(const QString &path)
{ {
QString result = QDir::cleanPath(path); QString result = QDir::cleanPath(path);
const QChar slash(QLatin1Char('/')); const QChar slash(QLatin1Char('/'));
@@ -236,7 +237,7 @@ QString CppPreprocessor::cleanPath(const QString &path)
return result; return result;
} }
QString CppPreprocessor::resolveFile_helper(const QString &fileName, IncludeType type) QString CppSourceProcessor::resolveFile_helper(const QString &fileName, IncludeType type)
{ {
if (isInjectedFile(fileName)) if (isInjectedFile(fileName))
return fileName; return fileName;
@@ -275,7 +276,7 @@ QString CppPreprocessor::resolveFile_helper(const QString &fileName, IncludeType
return QString(); return QString();
} }
void CppPreprocessor::macroAdded(const Macro &macro) void CppSourceProcessor::macroAdded(const Macro &macro)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
@@ -291,8 +292,8 @@ static inline const Macro revision(const CppModelManagerInterface::WorkingCopy &
return newMacro; return newMacro;
} }
void CppPreprocessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset, void CppSourceProcessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
unsigned line, const Macro &macro) unsigned line, const Macro &macro)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
@@ -303,8 +304,8 @@ void CppPreprocessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned
line, QVector<MacroArgumentReference>()); line, QVector<MacroArgumentReference>());
} }
void CppPreprocessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset, void CppSourceProcessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset,
const ByteArrayRef &name) const ByteArrayRef &name)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
@@ -313,8 +314,8 @@ void CppPreprocessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned
bytesOffset, utf16charOffset); bytesOffset, utf16charOffset);
} }
void CppPreprocessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset, void CppSourceProcessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset,
unsigned line, const Macro &macro) unsigned line, const Macro &macro)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
@@ -325,9 +326,9 @@ void CppPreprocessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16c
line, QVector<MacroArgumentReference>()); line, QVector<MacroArgumentReference>());
} }
void CppPreprocessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset, void CppSourceProcessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset,
unsigned line, const Macro &macro, unsigned line, const Macro &macro,
const QVector<MacroArgumentReference> &actuals) const QVector<MacroArgumentReference> &actuals)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
@@ -338,13 +339,13 @@ void CppPreprocessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16ch
line, actuals); line, actuals);
} }
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &) void CppSourceProcessor::stopExpandingMacro(unsigned, const Macro &)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
} }
void CppPreprocessor::markAsIncludeGuard(const QByteArray &macroName) void CppSourceProcessor::markAsIncludeGuard(const QByteArray &macroName)
{ {
if (!m_currentDoc) if (!m_currentDoc)
return; return;
@@ -352,7 +353,7 @@ void CppPreprocessor::markAsIncludeGuard(const QByteArray &macroName)
m_currentDoc->setIncludeGuardMacroName(macroName); m_currentDoc->setIncludeGuardMacroName(macroName);
} }
void CppPreprocessor::mergeEnvironment(Document::Ptr doc) void CppSourceProcessor::mergeEnvironment(Document::Ptr doc)
{ {
if (!doc) if (!doc)
return; return;
@@ -376,19 +377,19 @@ void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
m_env.addMacros(doc->definedMacros()); m_env.addMacros(doc->definedMacros());
} }
void CppPreprocessor::startSkippingBlocks(unsigned utf16charsOffset) void CppSourceProcessor::startSkippingBlocks(unsigned utf16charsOffset)
{ {
if (m_currentDoc) if (m_currentDoc)
m_currentDoc->startSkippingBlocks(utf16charsOffset); m_currentDoc->startSkippingBlocks(utf16charsOffset);
} }
void CppPreprocessor::stopSkippingBlocks(unsigned utf16charsOffset) void CppSourceProcessor::stopSkippingBlocks(unsigned utf16charsOffset)
{ {
if (m_currentDoc) if (m_currentDoc)
m_currentDoc->stopSkippingBlocks(utf16charsOffset); m_currentDoc->stopSkippingBlocks(utf16charsOffset);
} }
void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type) void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type)
{ {
typedef Document::DiagnosticMessage Message; typedef Document::DiagnosticMessage Message;
if (fileName.isEmpty()) if (fileName.isEmpty())
@@ -400,7 +401,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
m_currentDoc->addIncludeFile(Document::Include(fileName, absoluteFileName, line, type)); m_currentDoc->addIncludeFile(Document::Include(fileName, absoluteFileName, line, type));
if (absoluteFileName.isEmpty()) { if (absoluteFileName.isEmpty()) {
const QString text = QCoreApplication::translate( const QString text = QCoreApplication::translate(
"CppPreprocessor", "%1: No such file or directory").arg(fileName); "CppSourceProcessor", "%1: No such file or directory").arg(fileName);
Message message(Message::Warning, m_currentDoc->fileName(), line, /*column =*/ 0, text); Message message(Message::Warning, m_currentDoc->fileName(), line, /*column =*/ 0, text);
m_currentDoc->addDiagnosticMessage(message); m_currentDoc->addDiagnosticMessage(message);
return; return;
@@ -424,7 +425,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
const bool gotFileContents = getFileContents(absoluteFileName, &contents, &editorRevision); const bool gotFileContents = getFileContents(absoluteFileName, &contents, &editorRevision);
if (m_currentDoc && !gotFileContents) { if (m_currentDoc && !gotFileContents) {
const QString text = QCoreApplication::translate( const QString text = QCoreApplication::translate(
"CppPreprocessor", "%1: Could not get file contents").arg(fileName); "CppSourceProcessor", "%1: Could not get file contents").arg(fileName);
Message message(Message::Warning, m_currentDoc->fileName(), line, /*column =*/ 0, text); Message message(Message::Warning, m_currentDoc->fileName(), line, /*column =*/ 0, text);
m_currentDoc->addDiagnosticMessage(message); m_currentDoc->addDiagnosticMessage(message);
return; return;
@@ -493,7 +494,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
(void) switchDocument(previousDoc); (void) switchDocument(previousDoc);
} }
Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc) Document::Ptr CppSourceProcessor::switchDocument(Document::Ptr doc)
{ {
const Document::Ptr previousDoc = m_currentDoc; const Document::Ptr previousDoc = m_currentDoc;
m_currentDoc = doc; m_currentDoc = doc;

View File

@@ -1,5 +1,5 @@
#ifndef CPPPREPROCESSOR_H #ifndef CPPSOURCEPROCESSOR_H
#define CPPPREPROCESSOR_H #define CPPSOURCEPROCESSOR_H
#include "cppmodelmanagerinterface.h" #include "cppmodelmanagerinterface.h"
@@ -19,17 +19,17 @@ namespace Internal {
class CppModelManager; class CppModelManager;
// Documentation inside. // Documentation inside.
class CPPTOOLS_EXPORT CppPreprocessor: public CPlusPlus::Client class CPPTOOLS_EXPORT CppSourceProcessor: public CPlusPlus::Client
{ {
Q_DISABLE_COPY(CppPreprocessor) Q_DISABLE_COPY(CppSourceProcessor)
public: public:
static QString cleanPath(const QString &path); static QString cleanPath(const QString &path);
CppPreprocessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false); CppSourceProcessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false);
CppPreprocessor(QPointer<CppModelManager> modelManager, const CPlusPlus::Snapshot &snapshot, CppSourceProcessor(QPointer<CppModelManager> modelManager, const CPlusPlus::Snapshot &snapshot,
bool dumpFileNameWhileParsing = false); bool dumpFileNameWhileParsing = false);
virtual ~CppPreprocessor(); virtual ~CppSourceProcessor();
void setRevision(unsigned revision); void setRevision(unsigned revision);
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy); void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
@@ -82,7 +82,7 @@ protected:
virtual void sourceNeeded(unsigned line, const QString &fileName, IncludeType type); virtual void sourceNeeded(unsigned line, const QString &fileName, IncludeType type);
private: private:
CppPreprocessor(); CppSourceProcessor();
void addFrameworkPath(const QString &frameworkPath); void addFrameworkPath(const QString &frameworkPath);
CPlusPlus::Snapshot m_snapshot; CPlusPlus::Snapshot m_snapshot;
@@ -106,4 +106,4 @@ private:
} // namespace Internal } // namespace Internal
} // namespace CppTools } // namespace CppTools
#endif // CPPPREPROCESSOR_H #endif // CPPSOURCEPROCESSOR_H

View File

@@ -30,8 +30,8 @@
#include "cpptoolsplugin.h" #include "cpptoolsplugin.h"
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
#include "cpppreprocessertesthelper.h" #include "cppsourceprocessertesthelper.h"
#include "cpppreprocessor.h" #include "cppsourceprocessor.h"
#include "cppsnapshotupdater.h" #include "cppsnapshotupdater.h"
#include "cpptoolseditorsupport.h" #include "cpptoolseditorsupport.h"
#include "cpptoolstestcase.h" #include "cpptoolstestcase.h"
@@ -69,9 +69,9 @@ public:
TestCase::writeFile(fileName, source); TestCase::writeFile(fileName, source);
CppPreprocessor pp((QPointer<CppModelManager>(m_cmm))); CppSourceProcessor sourceProcessor((QPointer<CppModelManager>(m_cmm)));
pp.setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile())); sourceProcessor.setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile()));
pp.run(fileName); sourceProcessor.run(fileName);
Document::Ptr document = m_cmm->document(fileName); Document::Ptr document = m_cmm->document(fileName);
QFile(fileName).remove(); QFile(fileName).remove();
@@ -95,7 +95,7 @@ private:
}; };
/// Check: Resolved and unresolved includes are properly tracked. /// Check: Resolved and unresolved includes are properly tracked.
void CppToolsPlugin::test_cpppreprocessor_includes_resolvedUnresolved() void CppToolsPlugin::test_cppsourceprocessor_includes_resolvedUnresolved()
{ {
QByteArray source = QByteArray source =
"#include \"header.h\"\n" "#include \"header.h\"\n"
@@ -123,7 +123,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes_resolvedUnresolved()
} }
/// Check: Avoid self-include entries due to cyclic includes. /// Check: Avoid self-include entries due to cyclic includes.
void CppToolsPlugin::test_cpppreprocessor_includes_cyclic() void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
{ {
const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h")); const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h"));
const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h")); const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
@@ -163,7 +163,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes_cyclic()
} }
/// Check: All include errors are reported as diagnostic messages. /// Check: All include errors are reported as diagnostic messages.
void CppToolsPlugin::test_cpppreprocessor_includes_allDiagnostics() void CppToolsPlugin::test_cppsourceprocessor_includes_allDiagnostics()
{ {
QByteArray source = QByteArray source =
"#include <NotResolvable1>\n" "#include <NotResolvable1>\n"
@@ -181,7 +181,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes_allDiagnostics()
QCOMPARE(document->diagnosticMessages().size(), 3); QCOMPARE(document->diagnosticMessages().size(), 3);
} }
void CppToolsPlugin::test_cpppreprocessor_macroUses() void CppToolsPlugin::test_cppsourceprocessor_macroUses()
{ {
QByteArray source = QByteArray source =
"#define SOMEDEFINE 1\n" "#define SOMEDEFINE 1\n"

View File

@@ -35,12 +35,12 @@ HEADERS += \
cppmodelmanagersupport.h \ cppmodelmanagersupport.h \
cppmodelmanagersupportinternal.h \ cppmodelmanagersupportinternal.h \
cpppointerdeclarationformatter.h \ cpppointerdeclarationformatter.h \
cpppreprocessor.h \
cppprojectfile.h \ cppprojectfile.h \
cppqtstyleindenter.h \ cppqtstyleindenter.h \
cpprefactoringchanges.h \ cpprefactoringchanges.h \
cppsemanticinfo.h \ cppsemanticinfo.h \
cppsnapshotupdater.h \ cppsnapshotupdater.h \
cppsourceprocessor.h \
cpptools_global.h \ cpptools_global.h \
cpptoolsconstants.h \ cpptoolsconstants.h \
cpptoolseditorsupport.h \ cpptoolseditorsupport.h \
@@ -90,12 +90,12 @@ SOURCES += \
cppmodelmanagersupport.cpp \ cppmodelmanagersupport.cpp \
cppmodelmanagersupportinternal.cpp \ cppmodelmanagersupportinternal.cpp \
cpppointerdeclarationformatter.cpp \ cpppointerdeclarationformatter.cpp \
cpppreprocessor.cpp \
cppprojectfile.cpp \ cppprojectfile.cpp \
cppqtstyleindenter.cpp \ cppqtstyleindenter.cpp \
cpprefactoringchanges.cpp \ cpprefactoringchanges.cpp \
cppsemanticinfo.cpp \ cppsemanticinfo.cpp \
cppsnapshotupdater.cpp \ cppsnapshotupdater.cpp \
cppsourceprocessor.cpp \
cpptoolseditorsupport.cpp \ cpptoolseditorsupport.cpp \
cpptoolsplugin.cpp \ cpptoolsplugin.cpp \
cpptoolsreuse.cpp \ cpptoolsreuse.cpp \
@@ -118,7 +118,7 @@ FORMS += \
equals(TEST, 1) { equals(TEST, 1) {
HEADERS += \ HEADERS += \
cpppreprocessertesthelper.h \ cppsourceprocessertesthelper.h \
cpptoolstestcase.h \ cpptoolstestcase.h \
modelmanagertesthelper.h modelmanagertesthelper.h
@@ -129,8 +129,8 @@ equals(TEST, 1) {
cpplocatorfilter_test.cpp \ cpplocatorfilter_test.cpp \
cppmodelmanager_test.cpp \ cppmodelmanager_test.cpp \
cpppointerdeclarationformatter_test.cpp \ cpppointerdeclarationformatter_test.cpp \
cpppreprocessertesthelper.cpp \ cppsourceprocessertesthelper.cpp \
cpppreprocessor_test.cpp \ cppsourceprocessor_test.cpp \
cpptoolstestcase.cpp \ cpptoolstestcase.cpp \
modelmanagertesthelper.cpp \ modelmanagertesthelper.cpp \
symbolsearcher_test.cpp \ symbolsearcher_test.cpp \

View File

@@ -55,12 +55,12 @@ QtcPlugin {
"cppmodelmanagersupport.cpp", "cppmodelmanagersupport.h", "cppmodelmanagersupport.cpp", "cppmodelmanagersupport.h",
"cppmodelmanagersupportinternal.cpp", "cppmodelmanagersupportinternal.h", "cppmodelmanagersupportinternal.cpp", "cppmodelmanagersupportinternal.h",
"cpppointerdeclarationformatter.cpp", "cpppointerdeclarationformatter.h", "cpppointerdeclarationformatter.cpp", "cpppointerdeclarationformatter.h",
"cpppreprocessor.cpp", "cpppreprocessor.h",
"cppprojectfile.cpp", "cppprojectfile.h", "cppprojectfile.cpp", "cppprojectfile.h",
"cppqtstyleindenter.cpp", "cppqtstyleindenter.h", "cppqtstyleindenter.cpp", "cppqtstyleindenter.h",
"cpprefactoringchanges.cpp", "cpprefactoringchanges.h", "cpprefactoringchanges.cpp", "cpprefactoringchanges.h",
"cppsemanticinfo.cpp", "cppsemanticinfo.h", "cppsemanticinfo.cpp", "cppsemanticinfo.h",
"cppsnapshotupdater.cpp", "cppsnapshotupdater.h", "cppsnapshotupdater.cpp", "cppsnapshotupdater.h",
"cppsourceprocessor.cpp", "cppsourceprocessor.h",
"cpptools.qrc", "cpptools.qrc",
"cpptools_global.h", "cpptools_global.h",
"cpptoolsconstants.h", "cpptoolsconstants.h",
@@ -89,8 +89,8 @@ QtcPlugin {
"cpplocatorfilter_test.cpp", "cpplocatorfilter_test.cpp",
"cppmodelmanager_test.cpp", "cppmodelmanager_test.cpp",
"cpppointerdeclarationformatter_test.cpp", "cpppointerdeclarationformatter_test.cpp",
"cpppreprocessertesthelper.cpp", "cpppreprocessertesthelper.h", "cppsourceprocessertesthelper.cpp", "cppsourceprocessertesthelper.h",
"cpppreprocessor_test.cpp", "cppsourceprocessor_test.cpp",
"cpptoolstestcase.cpp", "cpptoolstestcase.h", "cpptoolstestcase.cpp", "cpptoolstestcase.h",
"modelmanagertesthelper.cpp", "modelmanagertesthelper.h", "modelmanagertesthelper.cpp", "modelmanagertesthelper.h",
"symbolsearcher_test.cpp", "symbolsearcher_test.cpp",

View File

@@ -125,10 +125,10 @@ private slots:
void test_format_pointerdeclaration_macros(); void test_format_pointerdeclaration_macros();
void test_format_pointerdeclaration_macros_data(); void test_format_pointerdeclaration_macros_data();
void test_cpppreprocessor_includes_resolvedUnresolved(); void test_cppsourceprocessor_includes_resolvedUnresolved();
void test_cpppreprocessor_includes_cyclic(); void test_cppsourceprocessor_includes_cyclic();
void test_cpppreprocessor_includes_allDiagnostics(); void test_cppsourceprocessor_includes_allDiagnostics();
void test_cpppreprocessor_macroUses(); void test_cppsourceprocessor_macroUses();
void test_functionutils_virtualFunctions(); void test_functionutils_virtualFunctions();
void test_functionutils_virtualFunctions_data(); void test_functionutils_virtualFunctions_data();