forked from qt-creator/qt-creator
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:
@@ -36,8 +36,8 @@
|
||||
|
||||
#include <cpptools/cppcodestylepreferences.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/cpppreprocessertesthelper.h>
|
||||
#include <cpptools/cpppreprocessor.h>
|
||||
#include <cpptools/cppsourceprocessertesthelper.h>
|
||||
#include <cpptools/cppsourceprocessor.h>
|
||||
#include <cpptools/cpptoolssettings.h>
|
||||
#include <cpptools/includeutils.h>
|
||||
|
||||
@@ -1859,9 +1859,9 @@ QList<Include> includesForSource(const QByteArray &source)
|
||||
|
||||
CppModelManager *cmm = CppModelManager::instance();
|
||||
cmm->GC();
|
||||
CppPreprocessor pp((QPointer<CppModelManager>(cmm)));
|
||||
pp.setIncludePaths(QStringList(TestIncludePaths::globalIncludePath()));
|
||||
pp.run(fileName);
|
||||
CppSourceProcessor sourceProcessor((QPointer<CppModelManager>(cmm)));
|
||||
sourceProcessor.setIncludePaths(QStringList(TestIncludePaths::globalIncludePath()));
|
||||
sourceProcessor.run(fileName);
|
||||
|
||||
Document::Ptr document = cmm->document(fileName);
|
||||
return document->resolvedIncludes();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "builtinindexingsupport.h"
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpppreprocessor.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "searchsymbols.h"
|
||||
#include "cpptoolsconstants.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
@@ -22,7 +22,7 @@ static const bool DumpFileNameWhileParsing = qgetenv("QTC_DUMP_FILENAME_WHILE_PA
|
||||
namespace {
|
||||
|
||||
static void parse(QFutureInterface<void> &future,
|
||||
CppPreprocessor *preproc,
|
||||
CppSourceProcessor *sourceProcessor,
|
||||
QStringList files)
|
||||
{
|
||||
if (files.isEmpty())
|
||||
@@ -32,7 +32,7 @@ static void parse(QFutureInterface<void> &future,
|
||||
QStringList headers;
|
||||
|
||||
foreach (const QString &file, files) {
|
||||
preproc->removeFromCache(file);
|
||||
sourceProcessor->removeFromCache(file);
|
||||
if (ProjectFile::isSource(ProjectFile::classify(file)))
|
||||
sources.append(file);
|
||||
else
|
||||
@@ -43,7 +43,7 @@ static void parse(QFutureInterface<void> &future,
|
||||
files = sources;
|
||||
files += headers;
|
||||
|
||||
preproc->setTodo(files);
|
||||
sourceProcessor->setTodo(files);
|
||||
|
||||
future.setProgressRange(0, files.size());
|
||||
|
||||
@@ -63,9 +63,9 @@ static void parse(QFutureInterface<void> &future,
|
||||
|
||||
const bool isSourceFile = i < sourceCount;
|
||||
if (isSourceFile) {
|
||||
(void) preproc->run(conf);
|
||||
(void) sourceProcessor->run(conf);
|
||||
} else if (!processingHeaders) {
|
||||
(void) preproc->run(conf);
|
||||
(void) sourceProcessor->run(conf);
|
||||
|
||||
processingHeaders = true;
|
||||
}
|
||||
@@ -74,19 +74,19 @@ static void parse(QFutureInterface<void> &future,
|
||||
QStringList includePaths = parts.isEmpty()
|
||||
? fallbackIncludePaths
|
||||
: parts.first()->includePaths;
|
||||
preproc->setIncludePaths(includePaths);
|
||||
preproc->run(fileName);
|
||||
sourceProcessor->setIncludePaths(includePaths);
|
||||
sourceProcessor->run(fileName);
|
||||
|
||||
future.setProgressValue(files.size() - preproc->todo().size());
|
||||
future.setProgressValue(files.size() - sourceProcessor->todo().size());
|
||||
|
||||
if (isSourceFile)
|
||||
preproc->resetEnvironment();
|
||||
sourceProcessor->resetEnvironment();
|
||||
}
|
||||
|
||||
future.setProgressValue(files.size());
|
||||
preproc->modelManager()->finishedRefreshingSourceFiles(files);
|
||||
sourceProcessor->modelManager()->finishedRefreshingSourceFiles(files);
|
||||
|
||||
delete preproc;
|
||||
delete sourceProcessor;
|
||||
}
|
||||
|
||||
class BuiltinSymbolSearcher: public SymbolSearcher
|
||||
@@ -184,7 +184,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sour
|
||||
CppModelManager *mgr = CppModelManager::instance();
|
||||
const WorkingCopy workingCopy = mgr->workingCopy();
|
||||
|
||||
CppPreprocessor *preproc = new CppPreprocessor(mgr, m_dumpFileNameWhileParsing);
|
||||
CppSourceProcessor *preproc = new CppSourceProcessor(mgr, m_dumpFileNameWhileParsing);
|
||||
preproc->setRevision(++m_revision);
|
||||
preproc->setIncludePaths(mgr->includePaths());
|
||||
preproc->setFrameworkPaths(mgr->frameworkPaths());
|
||||
|
@@ -37,7 +37,7 @@
|
||||
#include "cpphighlightingsupport.h"
|
||||
#include "cppindexingsupport.h"
|
||||
#include "cppmodelmanagersupportinternal.h"
|
||||
#include "cpppreprocessor.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cpptoolsconstants.h"
|
||||
#include "cpptoolseditorsupport.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
@@ -310,7 +310,7 @@ QStringList CppModelManager::internalIncludePaths() const
|
||||
const ProjectInfo pinfo = it.value();
|
||||
foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
|
||||
foreach (const QString &path, part->includePaths)
|
||||
includePaths.append(CppPreprocessor::cleanPath(path));
|
||||
includePaths.append(CppSourceProcessor::cleanPath(path));
|
||||
}
|
||||
includePaths.removeDuplicates();
|
||||
return includePaths;
|
||||
@@ -325,7 +325,7 @@ QStringList CppModelManager::internalFrameworkPaths() const
|
||||
const ProjectInfo pinfo = it.value();
|
||||
foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
|
||||
foreach (const QString &path, part->frameworkPaths)
|
||||
frameworkPaths.append(CppPreprocessor::cleanPath(path));
|
||||
frameworkPaths.append(CppSourceProcessor::cleanPath(path));
|
||||
}
|
||||
frameworkPaths.removeDuplicates();
|
||||
return frameworkPaths;
|
||||
|
@@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpppreprocessor.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cpptoolseditorsupport.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
@@ -345,7 +345,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
|
||||
|
||||
/// QTCREATORBUG-9205
|
||||
/// 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()
|
||||
{
|
||||
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
|
||||
/// 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.
|
||||
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(1), expectedUiHeaderFileName);
|
||||
|
||||
// Check CppPreprocessor / includes.
|
||||
// The CppPreprocessor is expected to find the ui_* file in the working copy.
|
||||
// Check CppSourceProcessor / includes.
|
||||
// The CppSourceProcessor is expected to find the ui_* file in the working copy.
|
||||
const QString fileIncludingTheUiFile = testDataDirectory.file(_("mainwindow.cpp"));
|
||||
while (!mm->snapshot().document(fileIncludingTheUiFile))
|
||||
QCoreApplication::processEvents();
|
||||
|
@@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpppreprocessor.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cppsnapshotupdater.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -159,25 +159,25 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
|
||||
workingCopy.insert(editorDefinesFileName, m_editorDefines);
|
||||
}
|
||||
|
||||
CppPreprocessor preproc(modelManager, m_snapshot);
|
||||
CppSourceProcessor sourceProcessor(modelManager, m_snapshot);
|
||||
Snapshot globalSnapshot = modelManager->snapshot();
|
||||
globalSnapshot.remove(fileInEditor());
|
||||
preproc.setGlobalSnapshot(globalSnapshot);
|
||||
preproc.setWorkingCopy(workingCopy);
|
||||
preproc.setIncludePaths(m_includePaths);
|
||||
preproc.setFrameworkPaths(m_frameworkPaths);
|
||||
preproc.run(configurationFileName);
|
||||
sourceProcessor.setGlobalSnapshot(globalSnapshot);
|
||||
sourceProcessor.setWorkingCopy(workingCopy);
|
||||
sourceProcessor.setIncludePaths(m_includePaths);
|
||||
sourceProcessor.setFrameworkPaths(m_frameworkPaths);
|
||||
sourceProcessor.run(configurationFileName);
|
||||
if (!m_projectConfigFile.isEmpty())
|
||||
preproc.run(m_projectConfigFile);
|
||||
sourceProcessor.run(m_projectConfigFile);
|
||||
if (m_usePrecompiledHeaders) {
|
||||
foreach (const QString &precompiledHeader, m_precompiledHeaders)
|
||||
preproc.run(precompiledHeader);
|
||||
sourceProcessor.run(precompiledHeader);
|
||||
}
|
||||
if (!m_editorDefines.isEmpty())
|
||||
preproc.run(editorDefinesFileName);
|
||||
preproc.run(m_fileInEditor);
|
||||
sourceProcessor.run(editorDefinesFileName);
|
||||
sourceProcessor.run(m_fileInEditor);
|
||||
|
||||
m_snapshot = preproc.snapshot();
|
||||
m_snapshot = sourceProcessor.snapshot();
|
||||
Snapshot newSnapshot = m_snapshot.simplified(document());
|
||||
for (Snapshot::const_iterator i = m_snapshot.begin(), ei = m_snapshot.end(); i != ei; ++i) {
|
||||
if (Client::isInjectedFile(i.key()))
|
||||
|
@@ -28,7 +28,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "cpppreprocessertesthelper.h"
|
||||
#include "cppsourceprocessertesthelper.h"
|
||||
|
||||
#include <QDir>
|
||||
|
@@ -28,8 +28,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef CPPPREPROCESSERTESTHELPER_H
|
||||
#define CPPPREPROCESSERTESTHELPER_H
|
||||
#ifndef CPPPSOURCEPROCESSERTESTHELPER_H
|
||||
#define CPPPSOURCEPROCESSERTESTHELPER_H
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
@@ -56,4 +56,4 @@ public:
|
||||
} // namespace Tests
|
||||
} // namespace CppTools
|
||||
|
||||
#endif // CPPPREPROCESSERTESTHELPER_H
|
||||
#endif // CPPPSOURCEPROCESSERTESTHELPER_H
|
@@ -1,4 +1,4 @@
|
||||
#include "cpppreprocessor.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include <QTextCodec>
|
||||
|
||||
/*!
|
||||
* \class CppTools::Internal::CppPreprocessor
|
||||
* \brief The CppPreprocessor class updates set of indexed C++ files.
|
||||
* \class CppTools::Internal::CppSourceProcessor
|
||||
* \brief The CppSourceProcessor class updates set of indexed C++ files.
|
||||
*
|
||||
* 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
|
||||
@@ -28,8 +28,8 @@ using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
using namespace CppTools::Internal;
|
||||
|
||||
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager,
|
||||
bool dumpFileNameWhileParsing)
|
||||
CppSourceProcessor::CppSourceProcessor(QPointer<CppModelManager> modelManager,
|
||||
bool dumpFileNameWhileParsing)
|
||||
: m_snapshot(modelManager->snapshot()),
|
||||
m_modelManager(modelManager),
|
||||
m_dumpFileNameWhileParsing(dumpFileNameWhileParsing),
|
||||
@@ -40,8 +40,9 @@ CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager,
|
||||
m_preprocess.setKeepComments(true);
|
||||
}
|
||||
|
||||
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager, const Snapshot &snapshot,
|
||||
bool dumpFileNameWhileParsing)
|
||||
CppSourceProcessor::CppSourceProcessor(QPointer<CppModelManager> modelManager,
|
||||
const Snapshot &snapshot,
|
||||
bool dumpFileNameWhileParsing)
|
||||
: m_snapshot(snapshot),
|
||||
m_modelManager(modelManager),
|
||||
m_dumpFileNameWhileParsing(dumpFileNameWhileParsing),
|
||||
@@ -52,16 +53,16 @@ CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager, const S
|
||||
m_preprocess.setKeepComments(true);
|
||||
}
|
||||
|
||||
CppPreprocessor::~CppPreprocessor()
|
||||
CppSourceProcessor::~CppSourceProcessor()
|
||||
{ }
|
||||
|
||||
void CppPreprocessor::setRevision(unsigned revision)
|
||||
void CppSourceProcessor::setRevision(unsigned revision)
|
||||
{ m_revision = revision; }
|
||||
|
||||
void CppPreprocessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy)
|
||||
void CppSourceProcessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy)
|
||||
{ m_workingCopy = workingCopy; }
|
||||
|
||||
void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
|
||||
void CppSourceProcessor::setIncludePaths(const QStringList &includePaths)
|
||||
{
|
||||
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();
|
||||
foreach (const QString &frameworkPath, frameworkPaths)
|
||||
@@ -100,7 +101,7 @@ void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths)
|
||||
// has private frameworks in:
|
||||
// <framework-path>/ApplicationServices.framework/Frameworks
|
||||
// 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
|
||||
// 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); }
|
||||
|
||||
namespace {
|
||||
@@ -155,26 +156,26 @@ public:
|
||||
};
|
||||
} // end of anonymous namespace
|
||||
|
||||
void CppPreprocessor::run(const QString &fileName)
|
||||
void CppSourceProcessor::run(const QString &fileName)
|
||||
{
|
||||
sourceNeeded(0, fileName, IncludeGlobal);
|
||||
}
|
||||
|
||||
void CppPreprocessor::removeFromCache(const QString &fileName)
|
||||
void CppSourceProcessor::removeFromCache(const QString &fileName)
|
||||
{
|
||||
m_snapshot.remove(fileName);
|
||||
}
|
||||
|
||||
void CppPreprocessor::resetEnvironment()
|
||||
void CppSourceProcessor::resetEnvironment()
|
||||
{
|
||||
m_env.reset();
|
||||
m_processed.clear();
|
||||
m_included.clear();
|
||||
}
|
||||
|
||||
bool CppPreprocessor::getFileContents(const QString &absoluteFilePath,
|
||||
QByteArray *contents,
|
||||
unsigned *revision) const
|
||||
bool CppSourceProcessor::getFileContents(const QString &absoluteFilePath,
|
||||
QByteArray *contents,
|
||||
unsigned *revision) const
|
||||
{
|
||||
if (absoluteFilePath.isEmpty() || !contents || !revision)
|
||||
return false;
|
||||
@@ -199,7 +200,7 @@ bool CppPreprocessor::getFileContents(const QString &absoluteFilePath,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CppPreprocessor::checkFile(const QString &absoluteFilePath) const
|
||||
bool CppSourceProcessor::checkFile(const QString &absoluteFilePath) const
|
||||
{
|
||||
if (absoluteFilePath.isEmpty()
|
||||
|| 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.
|
||||
QString CppPreprocessor::resolveFile(const QString &fileName, IncludeType type)
|
||||
QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType type)
|
||||
{
|
||||
if (type == IncludeGlobal) {
|
||||
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);
|
||||
}
|
||||
|
||||
QString CppPreprocessor::cleanPath(const QString &path)
|
||||
QString CppSourceProcessor::cleanPath(const QString &path)
|
||||
{
|
||||
QString result = QDir::cleanPath(path);
|
||||
const QChar slash(QLatin1Char('/'));
|
||||
@@ -236,7 +237,7 @@ QString CppPreprocessor::cleanPath(const QString &path)
|
||||
return result;
|
||||
}
|
||||
|
||||
QString CppPreprocessor::resolveFile_helper(const QString &fileName, IncludeType type)
|
||||
QString CppSourceProcessor::resolveFile_helper(const QString &fileName, IncludeType type)
|
||||
{
|
||||
if (isInjectedFile(fileName))
|
||||
return fileName;
|
||||
@@ -275,7 +276,7 @@ QString CppPreprocessor::resolveFile_helper(const QString &fileName, IncludeType
|
||||
return QString();
|
||||
}
|
||||
|
||||
void CppPreprocessor::macroAdded(const Macro ¯o)
|
||||
void CppSourceProcessor::macroAdded(const Macro ¯o)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -291,8 +292,8 @@ static inline const Macro revision(const CppModelManagerInterface::WorkingCopy &
|
||||
return newMacro;
|
||||
}
|
||||
|
||||
void CppPreprocessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
|
||||
unsigned line, const Macro ¯o)
|
||||
void CppSourceProcessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
|
||||
unsigned line, const Macro ¯o)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -303,8 +304,8 @@ void CppPreprocessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned
|
||||
line, QVector<MacroArgumentReference>());
|
||||
}
|
||||
|
||||
void CppPreprocessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
const ByteArrayRef &name)
|
||||
void CppSourceProcessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
const ByteArrayRef &name)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -313,8 +314,8 @@ void CppPreprocessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned
|
||||
bytesOffset, utf16charOffset);
|
||||
}
|
||||
|
||||
void CppPreprocessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const Macro ¯o)
|
||||
void CppSourceProcessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const Macro ¯o)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -325,9 +326,9 @@ void CppPreprocessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16c
|
||||
line, QVector<MacroArgumentReference>());
|
||||
}
|
||||
|
||||
void CppPreprocessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const Macro ¯o,
|
||||
const QVector<MacroArgumentReference> &actuals)
|
||||
void CppSourceProcessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const Macro ¯o,
|
||||
const QVector<MacroArgumentReference> &actuals)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -338,13 +339,13 @@ void CppPreprocessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16ch
|
||||
line, actuals);
|
||||
}
|
||||
|
||||
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
|
||||
void CppSourceProcessor::stopExpandingMacro(unsigned, const Macro &)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
}
|
||||
|
||||
void CppPreprocessor::markAsIncludeGuard(const QByteArray ¯oName)
|
||||
void CppSourceProcessor::markAsIncludeGuard(const QByteArray ¯oName)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -352,7 +353,7 @@ void CppPreprocessor::markAsIncludeGuard(const QByteArray ¯oName)
|
||||
m_currentDoc->setIncludeGuardMacroName(macroName);
|
||||
}
|
||||
|
||||
void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
|
||||
void CppSourceProcessor::mergeEnvironment(Document::Ptr doc)
|
||||
{
|
||||
if (!doc)
|
||||
return;
|
||||
@@ -376,19 +377,19 @@ void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
|
||||
m_env.addMacros(doc->definedMacros());
|
||||
}
|
||||
|
||||
void CppPreprocessor::startSkippingBlocks(unsigned utf16charsOffset)
|
||||
void CppSourceProcessor::startSkippingBlocks(unsigned utf16charsOffset)
|
||||
{
|
||||
if (m_currentDoc)
|
||||
m_currentDoc->startSkippingBlocks(utf16charsOffset);
|
||||
}
|
||||
|
||||
void CppPreprocessor::stopSkippingBlocks(unsigned utf16charsOffset)
|
||||
void CppSourceProcessor::stopSkippingBlocks(unsigned utf16charsOffset)
|
||||
{
|
||||
if (m_currentDoc)
|
||||
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;
|
||||
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));
|
||||
if (absoluteFileName.isEmpty()) {
|
||||
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);
|
||||
m_currentDoc->addDiagnosticMessage(message);
|
||||
return;
|
||||
@@ -424,7 +425,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
|
||||
const bool gotFileContents = getFileContents(absoluteFileName, &contents, &editorRevision);
|
||||
if (m_currentDoc && !gotFileContents) {
|
||||
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);
|
||||
m_currentDoc->addDiagnosticMessage(message);
|
||||
return;
|
||||
@@ -493,7 +494,7 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
|
||||
(void) switchDocument(previousDoc);
|
||||
}
|
||||
|
||||
Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc)
|
||||
Document::Ptr CppSourceProcessor::switchDocument(Document::Ptr doc)
|
||||
{
|
||||
const Document::Ptr previousDoc = m_currentDoc;
|
||||
m_currentDoc = doc;
|
@@ -1,5 +1,5 @@
|
||||
#ifndef CPPPREPROCESSOR_H
|
||||
#define CPPPREPROCESSOR_H
|
||||
#ifndef CPPSOURCEPROCESSOR_H
|
||||
#define CPPSOURCEPROCESSOR_H
|
||||
|
||||
#include "cppmodelmanagerinterface.h"
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace Internal {
|
||||
class CppModelManager;
|
||||
|
||||
// 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:
|
||||
static QString cleanPath(const QString &path);
|
||||
|
||||
CppPreprocessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false);
|
||||
CppPreprocessor(QPointer<CppModelManager> modelManager, const CPlusPlus::Snapshot &snapshot,
|
||||
bool dumpFileNameWhileParsing = false);
|
||||
virtual ~CppPreprocessor();
|
||||
CppSourceProcessor(QPointer<CppModelManager> modelManager, bool dumpFileNameWhileParsing = false);
|
||||
CppSourceProcessor(QPointer<CppModelManager> modelManager, const CPlusPlus::Snapshot &snapshot,
|
||||
bool dumpFileNameWhileParsing = false);
|
||||
virtual ~CppSourceProcessor();
|
||||
|
||||
void setRevision(unsigned revision);
|
||||
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
|
||||
@@ -82,7 +82,7 @@ protected:
|
||||
virtual void sourceNeeded(unsigned line, const QString &fileName, IncludeType type);
|
||||
|
||||
private:
|
||||
CppPreprocessor();
|
||||
CppSourceProcessor();
|
||||
void addFrameworkPath(const QString &frameworkPath);
|
||||
|
||||
CPlusPlus::Snapshot m_snapshot;
|
||||
@@ -106,4 +106,4 @@ private:
|
||||
} // namespace Internal
|
||||
} // namespace CppTools
|
||||
|
||||
#endif // CPPPREPROCESSOR_H
|
||||
#endif // CPPSOURCEPROCESSOR_H
|
@@ -30,8 +30,8 @@
|
||||
#include "cpptoolsplugin.h"
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpppreprocessertesthelper.h"
|
||||
#include "cpppreprocessor.h"
|
||||
#include "cppsourceprocessertesthelper.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cppsnapshotupdater.h"
|
||||
#include "cpptoolseditorsupport.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
@@ -69,9 +69,9 @@ public:
|
||||
|
||||
TestCase::writeFile(fileName, source);
|
||||
|
||||
CppPreprocessor pp((QPointer<CppModelManager>(m_cmm)));
|
||||
pp.setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile()));
|
||||
pp.run(fileName);
|
||||
CppSourceProcessor sourceProcessor((QPointer<CppModelManager>(m_cmm)));
|
||||
sourceProcessor.setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile()));
|
||||
sourceProcessor.run(fileName);
|
||||
|
||||
Document::Ptr document = m_cmm->document(fileName);
|
||||
QFile(fileName).remove();
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
};
|
||||
|
||||
/// Check: Resolved and unresolved includes are properly tracked.
|
||||
void CppToolsPlugin::test_cpppreprocessor_includes_resolvedUnresolved()
|
||||
void CppToolsPlugin::test_cppsourceprocessor_includes_resolvedUnresolved()
|
||||
{
|
||||
QByteArray source =
|
||||
"#include \"header.h\"\n"
|
||||
@@ -123,7 +123,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes_resolvedUnresolved()
|
||||
}
|
||||
|
||||
/// 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 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.
|
||||
void CppToolsPlugin::test_cpppreprocessor_includes_allDiagnostics()
|
||||
void CppToolsPlugin::test_cppsourceprocessor_includes_allDiagnostics()
|
||||
{
|
||||
QByteArray source =
|
||||
"#include <NotResolvable1>\n"
|
||||
@@ -181,7 +181,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes_allDiagnostics()
|
||||
QCOMPARE(document->diagnosticMessages().size(), 3);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpppreprocessor_macroUses()
|
||||
void CppToolsPlugin::test_cppsourceprocessor_macroUses()
|
||||
{
|
||||
QByteArray source =
|
||||
"#define SOMEDEFINE 1\n"
|
@@ -35,12 +35,12 @@ HEADERS += \
|
||||
cppmodelmanagersupport.h \
|
||||
cppmodelmanagersupportinternal.h \
|
||||
cpppointerdeclarationformatter.h \
|
||||
cpppreprocessor.h \
|
||||
cppprojectfile.h \
|
||||
cppqtstyleindenter.h \
|
||||
cpprefactoringchanges.h \
|
||||
cppsemanticinfo.h \
|
||||
cppsnapshotupdater.h \
|
||||
cppsourceprocessor.h \
|
||||
cpptools_global.h \
|
||||
cpptoolsconstants.h \
|
||||
cpptoolseditorsupport.h \
|
||||
@@ -90,12 +90,12 @@ SOURCES += \
|
||||
cppmodelmanagersupport.cpp \
|
||||
cppmodelmanagersupportinternal.cpp \
|
||||
cpppointerdeclarationformatter.cpp \
|
||||
cpppreprocessor.cpp \
|
||||
cppprojectfile.cpp \
|
||||
cppqtstyleindenter.cpp \
|
||||
cpprefactoringchanges.cpp \
|
||||
cppsemanticinfo.cpp \
|
||||
cppsnapshotupdater.cpp \
|
||||
cppsourceprocessor.cpp \
|
||||
cpptoolseditorsupport.cpp \
|
||||
cpptoolsplugin.cpp \
|
||||
cpptoolsreuse.cpp \
|
||||
@@ -118,7 +118,7 @@ FORMS += \
|
||||
|
||||
equals(TEST, 1) {
|
||||
HEADERS += \
|
||||
cpppreprocessertesthelper.h \
|
||||
cppsourceprocessertesthelper.h \
|
||||
cpptoolstestcase.h \
|
||||
modelmanagertesthelper.h
|
||||
|
||||
@@ -129,8 +129,8 @@ equals(TEST, 1) {
|
||||
cpplocatorfilter_test.cpp \
|
||||
cppmodelmanager_test.cpp \
|
||||
cpppointerdeclarationformatter_test.cpp \
|
||||
cpppreprocessertesthelper.cpp \
|
||||
cpppreprocessor_test.cpp \
|
||||
cppsourceprocessertesthelper.cpp \
|
||||
cppsourceprocessor_test.cpp \
|
||||
cpptoolstestcase.cpp \
|
||||
modelmanagertesthelper.cpp \
|
||||
symbolsearcher_test.cpp \
|
||||
|
@@ -55,12 +55,12 @@ QtcPlugin {
|
||||
"cppmodelmanagersupport.cpp", "cppmodelmanagersupport.h",
|
||||
"cppmodelmanagersupportinternal.cpp", "cppmodelmanagersupportinternal.h",
|
||||
"cpppointerdeclarationformatter.cpp", "cpppointerdeclarationformatter.h",
|
||||
"cpppreprocessor.cpp", "cpppreprocessor.h",
|
||||
"cppprojectfile.cpp", "cppprojectfile.h",
|
||||
"cppqtstyleindenter.cpp", "cppqtstyleindenter.h",
|
||||
"cpprefactoringchanges.cpp", "cpprefactoringchanges.h",
|
||||
"cppsemanticinfo.cpp", "cppsemanticinfo.h",
|
||||
"cppsnapshotupdater.cpp", "cppsnapshotupdater.h",
|
||||
"cppsourceprocessor.cpp", "cppsourceprocessor.h",
|
||||
"cpptools.qrc",
|
||||
"cpptools_global.h",
|
||||
"cpptoolsconstants.h",
|
||||
@@ -89,8 +89,8 @@ QtcPlugin {
|
||||
"cpplocatorfilter_test.cpp",
|
||||
"cppmodelmanager_test.cpp",
|
||||
"cpppointerdeclarationformatter_test.cpp",
|
||||
"cpppreprocessertesthelper.cpp", "cpppreprocessertesthelper.h",
|
||||
"cpppreprocessor_test.cpp",
|
||||
"cppsourceprocessertesthelper.cpp", "cppsourceprocessertesthelper.h",
|
||||
"cppsourceprocessor_test.cpp",
|
||||
"cpptoolstestcase.cpp", "cpptoolstestcase.h",
|
||||
"modelmanagertesthelper.cpp", "modelmanagertesthelper.h",
|
||||
"symbolsearcher_test.cpp",
|
||||
|
@@ -125,10 +125,10 @@ private slots:
|
||||
void test_format_pointerdeclaration_macros();
|
||||
void test_format_pointerdeclaration_macros_data();
|
||||
|
||||
void test_cpppreprocessor_includes_resolvedUnresolved();
|
||||
void test_cpppreprocessor_includes_cyclic();
|
||||
void test_cpppreprocessor_includes_allDiagnostics();
|
||||
void test_cpppreprocessor_macroUses();
|
||||
void test_cppsourceprocessor_includes_resolvedUnresolved();
|
||||
void test_cppsourceprocessor_includes_cyclic();
|
||||
void test_cppsourceprocessor_includes_allDiagnostics();
|
||||
void test_cppsourceprocessor_macroUses();
|
||||
|
||||
void test_functionutils_virtualFunctions();
|
||||
void test_functionutils_virtualFunctions_data();
|
||||
|
Reference in New Issue
Block a user