Commit cfc1069c authored by Erik Verbruggen's avatar Erik Verbruggen

C++: Remove hard-coded configuration file name.

Change-Id: Ibe4cc69eafd14dab7707862b1068ce1e21b1d8e0
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent d37ee4d1
......@@ -30,13 +30,12 @@
#include "FastPreprocessor.h"
#include <Literals.h>
#include <TranslationUnit.h>
#include <QDebug>
using namespace CPlusPlus;
FastPreprocessor::FastPreprocessor(const Snapshot &snapshot)
: _snapshot(snapshot),
_preproc(this, &_env)
: _snapshot(snapshot)
, _preproc(this, &_env)
{ }
QByteArray FastPreprocessor::run(Document::Ptr newDoc, const QString &source)
......@@ -49,7 +48,7 @@ QByteArray FastPreprocessor::run(Document::Ptr newDoc, const QString &source)
if (Document::Ptr doc = _snapshot.document(fileName)) {
_merged.insert(fileName);
mergeEnvironment(QLatin1String("<configuration>"));
mergeEnvironment(Preprocessor::configurationFileName);
foreach (const Document::Include &i, doc->includes())
mergeEnvironment(i.fileName());
}
......
......@@ -589,6 +589,8 @@ void Preprocessor::State::popTokenBuffer()
--m_tokenBufferDepth;
}
const QString Preprocessor::configurationFileName = QLatin1String("<configuration>");
Preprocessor::Preprocessor(Client *client, Environment *env)
: m_client(client)
, m_env(env)
......@@ -1751,7 +1753,7 @@ void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk)
// the macro is a feature constraint(e.g. QT_NO_XXX)
if (checkUndefined && macroName.startsWith("QT_NO_")) {
if (macro->fileName() == QLatin1String("<configuration>")) {
if (macro->fileName() == configurationFileName) {
// and it' defined in a pro file (e.g. DEFINES += QT_NO_QOBJECT)
value = false; // take the branch
......
......@@ -74,6 +74,9 @@ class CPLUSPLUS_EXPORT Preprocessor
typedef Internal::PPToken PPToken;
typedef Internal::Value Value;
public:
static const QString configurationFileName;
public:
Preprocessor(Client *client, Environment *env);
......
......@@ -1434,7 +1434,7 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
return link; //already on definition!
} else {
const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1);
if (use && use->macro().fileName() != QLatin1String("<configuration>")) {
if (use && use->macro().fileName() != CppModelManagerInterface::configurationFileName()) {
const Macro &macro = use->macro();
link.fileName = macro.fileName();
link.line = macro.line();
......
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "ModelManagerInterface.h"
#include "pp-engine.h"
#include <QtCore/QSet>
......@@ -35,6 +36,9 @@ using namespace CPlusPlus;
static CppModelManagerInterface *g_instance = 0;
const QString CppModelManagerInterface::configurationFileName()
{ return Preprocessor::configurationFileName; }
CppModelManagerInterface::CppModelManagerInterface(QObject *parent)
: QObject(parent)
{
......
......@@ -180,6 +180,9 @@ public:
CppSemanticsDiagnostic
};
public:
static const QString configurationFileName();
public:
CppModelManagerInterface(QObject *parent = 0);
virtual ~CppModelManagerInterface();
......
......@@ -16,8 +16,7 @@ namespace {
static void parse(QFutureInterface<void> &future,
CppPreprocessor *preproc,
QStringList files,
const char *pp_configuration_file)
QStringList files)
{
if (files.isEmpty())
return;
......@@ -53,8 +52,7 @@ static void parse(QFutureInterface<void> &future,
future.setProgressRange(0, files.size());
QString conf = QLatin1String(pp_configuration_file);
const QString conf = CPlusPlus::CppModelManagerInterface::configurationFileName();
bool processingHeaders = false;
for (int i = 0; i < files.size(); ++i) {
......@@ -163,9 +161,8 @@ private:
} // anonymous namespace
BuiltinIndexingSupport::BuiltinIndexingSupport(const char *pp_configuration_file)
: m_pp_configuration_file(pp_configuration_file)
, m_revision(0)
BuiltinIndexingSupport::BuiltinIndexingSupport()
: m_revision(0)
{
m_synchronizer.setCancelOnWait(true);
m_dumpFileNameWhileParsing = !qgetenv("QTCREATOR_DUMP_FILENAME_WHILE_PARSING").isNull();
......@@ -186,7 +183,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sour
preproc->setFrameworkPaths(mgr->frameworkPaths());
preproc->setWorkingCopy(workingCopy);
QFuture<void> result = QtConcurrent::run(&parse, preproc, sourceFiles, m_pp_configuration_file);
QFuture<void> result = QtConcurrent::run(&parse, preproc, sourceFiles);
if (m_synchronizer.futures().size() > 10) {
QList<QFuture<void> > futures = m_synchronizer.futures();
......
......@@ -14,14 +14,13 @@ public:
typedef CPlusPlus::CppModelManagerInterface::WorkingCopy WorkingCopy;
public:
BuiltinIndexingSupport(const char *m_pp_configuration_file);
BuiltinIndexingSupport();
~BuiltinIndexingSupport();
virtual QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters, QSet<QString> fileNames);
private:
const char *m_pp_configuration_file;
QFutureSynchronizer<void> m_synchronizer;
unsigned m_revision;
bool m_dumpFileNameWhileParsing;
......
......@@ -1418,7 +1418,7 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
completeNamespace(b);
addKeywords();
addMacros(QLatin1String("<configuration>"), context.snapshot());
addMacros(CppModelManagerInterface::configurationFileName(), context.snapshot());
addMacros(context.thisDocument()->fileName(), context.snapshot());
addSnippets();
}
......
......@@ -164,8 +164,6 @@ protected:
#endif // QTCREATOR_WITH_DUMP_AST
static const char pp_configuration_file[] = "<configuration>";
static const char pp_configuration[] =
"# 1 \"<configuration>\"\n"
"#define __cplusplus 1\n"
......@@ -396,7 +394,7 @@ static inline void appendDirSeparatorIfNeeded(QString &path)
QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType type, unsigned *revision)
{
QFileInfo fileInfo(fileName);
if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) {
if (fileName == Preprocessor::configurationFileName || fileInfo.isAbsolute()) {
QString contents;
includeFile(fileName, &contents, revision);
return contents;
......@@ -741,7 +739,7 @@ CppModelManager::CppModelManager(QObject *parent)
ExtensionSystem::PluginManager::addObject(m_completionAssistProvider);
m_highlightingFallback = new CppHighlightingSupportInternalFactory;
m_highlightingFactory = m_highlightingFallback;
m_internalIndexingSupport = new BuiltinIndexingSupport(pp_configuration_file);
m_internalIndexingSupport = new BuiltinIndexingSupport;
}
CppModelManager::~CppModelManager()
......@@ -940,7 +938,7 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
// add the project configuration file
QByteArray conf(pp_configuration);
conf += definedMacros();
workingCopy.insert(QLatin1String(pp_configuration_file), QString::fromUtf8(conf));
workingCopy.insert(configurationFileName(), QString::fromUtf8(conf));
return workingCopy;
}
......
......@@ -273,7 +273,7 @@ void GenericProject::refresh(RefreshOptions options)
if (options & Configuration) {
filesToUpdate = part->sourceFiles;
filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
filesToUpdate.append(CPlusPlus::CppModelManagerInterface::configurationFileName());
// Full update, if there's a code model update, cancel it
m_codeModelFuture.cancel();
} else if (options & Files) {
......
......@@ -528,9 +528,9 @@ bool Qt4Project::equalFileList(const QStringList &a, const QStringList &b)
QStringList::const_iterator bend = b.constEnd();
while (ait != aend && bit != bend) {
if (*ait == QLatin1String("<configuration>"))
if (*ait == CPlusPlus::CppModelManagerInterface::configurationFileName())
++ait;
else if (*bit == QLatin1String("<configuration>"))
else if (*bit == CPlusPlus::CppModelManagerInterface::configurationFileName())
++bit;
else if (*ait == *bit)
++ait, ++bit;
......@@ -634,7 +634,7 @@ void Qt4Project::updateCppCodeModel()
part->sourceFiles = pro->variableValue(CppSourceVar);
part->headerFiles += pro->variableValue(CppHeaderVar);
part->headerFiles += pro->uiFiles();
part->sourceFiles.prepend(QLatin1String("<configuration>"));
part->sourceFiles.prepend(CPlusPlus::CppModelManagerInterface::configurationFileName());
part->objcSourceFiles = pro->variableValue(ObjCSourceVar);
pinfo.appendProjectPart(part);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment