forked from qt-creator/qt-creator
hide includes from within feature files
this fixes the recent appearance of qt_webkit_version.pri in all qt 4.7 based projects. in fact, the patch does somewhat more: it makes the evaluator provide the information to the higher layers which is necessary for a truly hierarchical display of includes. TBD later. Reviewed-by: dt Task-number: QTCREATORBUG-1590
This commit is contained in:
@@ -48,7 +48,8 @@ ProFileReader::~ProFileReader()
|
|||||||
bool ProFileReader::readProFile(const QString &fileName)
|
bool ProFileReader::readProFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (ProFile *pro = parsedProFile(fileName)) {
|
if (ProFile *pro = parsedProFile(fileName)) {
|
||||||
aboutToEval(pro);
|
m_ignoreLevel = 0;
|
||||||
|
aboutToEval(0, pro, EvalIncludeFile);
|
||||||
bool ok = accept(pro);
|
bool ok = accept(pro);
|
||||||
pro->deref();
|
pro->deref();
|
||||||
return ok;
|
return ok;
|
||||||
@@ -56,15 +57,23 @@ bool ProFileReader::readProFile(const QString &fileName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileReader::aboutToEval(ProFile *pro)
|
void ProFileReader::aboutToEval(ProFile *, ProFile *pro, EvalFileType type)
|
||||||
{
|
{
|
||||||
if (!m_includeFiles.contains(pro->fileName())) {
|
if (m_ignoreLevel || type == EvalFeatureFile) {
|
||||||
|
m_ignoreLevel++;
|
||||||
|
} else if (!m_includeFiles.contains(pro->fileName())) {
|
||||||
m_includeFiles.insert(pro->fileName(), pro);
|
m_includeFiles.insert(pro->fileName(), pro);
|
||||||
m_proFiles.append(pro);
|
m_proFiles.append(pro);
|
||||||
pro->ref();
|
pro->ref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProFileReader::doneWithEval(ProFile *)
|
||||||
|
{
|
||||||
|
if (m_ignoreLevel)
|
||||||
|
m_ignoreLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
QList<ProFile*> ProFileReader::includeFiles() const
|
QList<ProFile*> ProFileReader::includeFiles() const
|
||||||
{
|
{
|
||||||
QString qmakeMkSpecDir = QFileInfo(propertyValue("QMAKE_MKSPECS")).absoluteFilePath();
|
QString qmakeMkSpecDir = QFileInfo(propertyValue("QMAKE_MKSPECS")).absoluteFilePath();
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ signals:
|
|||||||
void errorFound(const QString &error);
|
void errorFound(const QString &error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void aboutToEval(ProFile *proFile);
|
virtual void aboutToEval(ProFile *parent, ProFile *proFile, EvalFileType type);
|
||||||
|
virtual void doneWithEval(ProFile *parent);
|
||||||
virtual void logMessage(const QString &msg);
|
virtual void logMessage(const QString &msg);
|
||||||
virtual void fileMessage(const QString &msg);
|
virtual void fileMessage(const QString &msg);
|
||||||
virtual void errorMessage(const QString &msg);
|
virtual void errorMessage(const QString &msg);
|
||||||
@@ -66,6 +67,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QMap<QString, ProFile *> m_includeFiles;
|
QMap<QString, ProFile *> m_includeFiles;
|
||||||
QList<ProFile *> m_proFiles;
|
QList<ProFile *> m_proFiles;
|
||||||
|
int m_ignoreLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProFileCacheManager : public QObject
|
class ProFileCacheManager : public QObject
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ public:
|
|||||||
ProItem::ProItemReturn evaluateConditionalFunction(const QString &function, const QString &arguments);
|
ProItem::ProItemReturn evaluateConditionalFunction(const QString &function, const QString &arguments);
|
||||||
ProFile *parsedProFile(const QString &fileName, bool cache,
|
ProFile *parsedProFile(const QString &fileName, bool cache,
|
||||||
const QString &contents = QString());
|
const QString &contents = QString());
|
||||||
|
bool evaluateFileDirect(const QString &fileName, ProFileEvaluator::EvalFileType type);
|
||||||
bool evaluateFile(const QString &fileName);
|
bool evaluateFile(const QString &fileName);
|
||||||
bool evaluateFeatureFile(const QString &fileName,
|
bool evaluateFeatureFile(const QString &fileName,
|
||||||
QHash<QString, QStringList> *values = 0, FunctionDefs *defs = 0);
|
QHash<QString, QStringList> *values = 0, FunctionDefs *defs = 0);
|
||||||
@@ -3120,6 +3121,20 @@ ProFile *ProFileEvaluator::Private::parsedProFile(const QString &fileName, bool
|
|||||||
return pro;
|
return pro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProFileEvaluator::Private::evaluateFileDirect(
|
||||||
|
const QString &fileName, ProFileEvaluator::EvalFileType type)
|
||||||
|
{
|
||||||
|
if (ProFile *pro = parsedProFile(fileName, true)) {
|
||||||
|
q->aboutToEval(currentProFile(), pro, type);
|
||||||
|
bool ok = (visitProFile(pro) == ProItem::ReturnTrue);
|
||||||
|
q->doneWithEval(currentProFile());
|
||||||
|
pro->deref();
|
||||||
|
return ok;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::Private::evaluateFile(const QString &fileName)
|
bool ProFileEvaluator::Private::evaluateFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
@@ -3129,14 +3144,7 @@ bool ProFileEvaluator::Private::evaluateFile(const QString &fileName)
|
|||||||
errorMessage(format("circular inclusion of %1").arg(fileName));
|
errorMessage(format("circular inclusion of %1").arg(fileName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (ProFile *pro = parsedProFile(fileName, true)) {
|
return evaluateFileDirect(fileName, ProFileEvaluator::EvalIncludeFile);
|
||||||
q->aboutToEval(pro);
|
|
||||||
bool ok = (visitProFile(pro) == ProItem::ReturnTrue);
|
|
||||||
pro->deref();
|
|
||||||
return ok;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProFileEvaluator::Private::evaluateFeatureFile(
|
bool ProFileEvaluator::Private::evaluateFeatureFile(
|
||||||
@@ -3183,13 +3191,8 @@ bool ProFileEvaluator::Private::evaluateFeatureFile(
|
|||||||
bool cumulative = m_cumulative;
|
bool cumulative = m_cumulative;
|
||||||
m_cumulative = false;
|
m_cumulative = false;
|
||||||
|
|
||||||
// Don't use evaluateFile() here to avoid calling aboutToEval().
|
|
||||||
// The path is fully normalized already.
|
// The path is fully normalized already.
|
||||||
bool ok = false;
|
bool ok = evaluateFileDirect(fn, ProFileEvaluator::EvalFeatureFile);
|
||||||
if (ProFile *pro = parsedProFile(fn, true)) {
|
|
||||||
ok = (visitProFile(pro) == ProItem::ReturnTrue);
|
|
||||||
pro->deref();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_cumulative = cumulative;
|
m_cumulative = cumulative;
|
||||||
return ok;
|
return ok;
|
||||||
@@ -3371,7 +3374,11 @@ QString ProFileEvaluator::propertyValue(const QString &name) const
|
|||||||
return d->propertyValue(name);
|
return d->propertyValue(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEvaluator::aboutToEval(ProFile *)
|
void ProFileEvaluator::aboutToEval(ProFile *, ProFile *, EvalFileType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProFileEvaluator::doneWithEval(ProFile *)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ public:
|
|||||||
QString propertyValue(const QString &val) const;
|
QString propertyValue(const QString &val) const;
|
||||||
|
|
||||||
// for our descendents
|
// for our descendents
|
||||||
virtual void aboutToEval(ProFile *proFile); // only .pri, but not .prf. or .pro
|
enum EvalFileType { EvalFeatureFile, EvalIncludeFile };
|
||||||
|
virtual void aboutToEval(ProFile *parent, ProFile *proFile, EvalFileType type);
|
||||||
|
virtual void doneWithEval(ProFile *parent);
|
||||||
virtual void logMessage(const QString &msg);
|
virtual void logMessage(const QString &msg);
|
||||||
virtual void errorMessage(const QString &msg); // .pro parse errors
|
virtual void errorMessage(const QString &msg); // .pro parse errors
|
||||||
virtual void fileMessage(const QString &msg); // error() and message() from .pro file
|
virtual void fileMessage(const QString &msg); // error() and message() from .pro file
|
||||||
|
|||||||
Reference in New Issue
Block a user