forked from qt-creator/qt-creator
revamp message callbacks
instead of having a bazillion different callbacks, have only one with a type parameter. the drain typically multiplexes all into one stream anyway. Change-Id: I963daefc5a266c91334a4cc599570ed26b603d5d Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -54,19 +54,9 @@ ProMessageHandler::ProMessageHandler(bool verbose)
|
|||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProMessageHandler::parseError(const QString &fileName, int lineNo, const QString &msg)
|
void ProMessageHandler::message(int type, const QString &msg, const QString &fileName, int lineNo)
|
||||||
{
|
{
|
||||||
emit errorFound(format(fileName, lineNo, msg));
|
if ((type & CategoryMask) == ErrorMessage && ((type & SourceMask) == SourceParser || m_verbose))
|
||||||
}
|
|
||||||
|
|
||||||
void ProMessageHandler::configError(const QString &msg)
|
|
||||||
{
|
|
||||||
emit errorFound(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProMessageHandler::evalError(const QString &fileName, int lineNo, const QString &msg)
|
|
||||||
{
|
|
||||||
if (m_verbose)
|
|
||||||
emit errorFound(format(fileName, lineNo, msg));
|
emit errorFound(format(fileName, lineNo, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ public:
|
|||||||
|
|
||||||
virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {}
|
virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {}
|
||||||
virtual void doneWithEval(ProFile *) {}
|
virtual void doneWithEval(ProFile *) {}
|
||||||
virtual void parseError(const QString &filename, int lineNo, const QString &msg);
|
virtual void message(int type, const QString &msg, const QString &fileName, int lineNo);
|
||||||
virtual void configError(const QString &msg);
|
|
||||||
virtual void evalError(const QString &filename, int lineNo, const QString &msg);
|
|
||||||
virtual void fileMessage(const QString &msg);
|
virtual void fileMessage(const QString &msg);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ void QMakeEvaluator::runProcess(QProcess *proc, const QString &command,
|
|||||||
QByteArray errout = proc->readAll();
|
QByteArray errout = proc->readAll();
|
||||||
if (errout.endsWith('\n'))
|
if (errout.endsWith('\n'))
|
||||||
errout.chop(1);
|
errout.chop(1);
|
||||||
m_handler->evalError(QString(), 0, QString::fromLocal8Bit(errout));
|
m_handler->message(QMakeHandler::EvalError, QString::fromLocal8Bit(errout));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1056,7 +1056,7 @@ bool QMakeEvaluator::loadSpec()
|
|||||||
goto cool;
|
goto cool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_handler->configError(fL1S("Could not find qmake configuration file"));
|
evalError(fL1S("Could not find qmake configuration file %1").arg(qmakespec));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cool:
|
cool:
|
||||||
@@ -1070,8 +1070,7 @@ bool QMakeEvaluator::loadSpec()
|
|||||||
return false;
|
return false;
|
||||||
QString spec = m_qmakespec + QLatin1String("/qmake.conf");
|
QString spec = m_qmakespec + QLatin1String("/qmake.conf");
|
||||||
if (!evaluateFileDirect(spec, QMakeHandler::EvalConfigFile, LoadProOnly)) {
|
if (!evaluateFileDirect(spec, QMakeHandler::EvalConfigFile, LoadProOnly)) {
|
||||||
m_handler->configError(
|
evalError(fL1S("Could not read qmake configuration file %1").arg(spec));
|
||||||
fL1S("Could not read qmake configuration file %1").arg(spec));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
@@ -1973,11 +1972,11 @@ bool QMakeEvaluator::evaluateFileInto(const QString &fileName, QMakeHandler::Eva
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMakeEvaluator::evalError(const QString &message) const
|
void QMakeEvaluator::message(int type, const QString &msg) const
|
||||||
{
|
{
|
||||||
if (!m_skipLevel)
|
if (!m_skipLevel)
|
||||||
m_handler->evalError(m_current.line ? m_current.pro->fileName() : QString(),
|
m_handler->message(type, msg,
|
||||||
m_current.line, message);
|
m_current.line ? m_current.pro->fileName() : QString(), m_current.line);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -50,11 +50,13 @@ class QMakeGlobals;
|
|||||||
class QMAKE_EXPORT QMakeHandler : public QMakeParserHandler
|
class QMAKE_EXPORT QMakeHandler : public QMakeParserHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// qmake/project configuration error
|
enum {
|
||||||
virtual void configError(const QString &msg) = 0;
|
SourceEvaluator = 0x10,
|
||||||
// Some error during evaluation
|
|
||||||
virtual void evalError(const QString &filename, int lineNo, const QString &msg) = 0;
|
EvalError = ErrorMessage | SourceEvaluator
|
||||||
// error() and message() from .pro file
|
};
|
||||||
|
|
||||||
|
// error(), warning() and message() from .pro file
|
||||||
virtual void fileMessage(const QString &msg) = 0;
|
virtual void fileMessage(const QString &msg) = 0;
|
||||||
|
|
||||||
enum EvalFileType { EvalProjectFile, EvalIncludeFile, EvalConfigFile, EvalFeatureFile, EvalAuxFile };
|
enum EvalFileType { EvalProjectFile, EvalIncludeFile, EvalConfigFile, EvalFeatureFile, EvalAuxFile };
|
||||||
@@ -141,7 +143,9 @@ public:
|
|||||||
bool evaluateFileInto(const QString &fileName, QMakeHandler::EvalFileType type,
|
bool evaluateFileInto(const QString &fileName, QMakeHandler::EvalFileType type,
|
||||||
ProValueMap *values, // output-only
|
ProValueMap *values, // output-only
|
||||||
LoadFlags flags);
|
LoadFlags flags);
|
||||||
void evalError(const QString &msg) const;
|
void message(int type, const QString &msg) const;
|
||||||
|
void evalError(const QString &msg) const
|
||||||
|
{ message(QMakeHandler::EvalError, msg); }
|
||||||
|
|
||||||
QList<ProStringList> prepareFunctionArgs(const ushort *&tokPtr);
|
QList<ProStringList> prepareFunctionArgs(const ushort *&tokPtr);
|
||||||
QList<ProStringList> prepareFunctionArgs(const ProString &arguments);
|
QList<ProStringList> prepareFunctionArgs(const ProString &arguments);
|
||||||
|
|||||||
@@ -204,8 +204,8 @@ bool QMakeParser::read(ProFile *pro)
|
|||||||
QFile file(pro->fileName());
|
QFile file(pro->fileName());
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
if (m_handler && IoUtils::exists(pro->fileName()))
|
if (m_handler && IoUtils::exists(pro->fileName()))
|
||||||
m_handler->parseError(QString(), 0, fL1S("Cannot read %1: %2")
|
m_handler->message(QMakeParserHandler::ParserIoError,
|
||||||
.arg(pro->fileName(), file.errorString()));
|
fL1S("Cannot read %1: %2").arg(pro->fileName(), file.errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,10 +1086,10 @@ bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMakeParser::parseError(const QString &msg) const
|
void QMakeParser::message(int type, const QString &msg) const
|
||||||
{
|
{
|
||||||
if (!m_inError && m_handler)
|
if (!m_inError && m_handler)
|
||||||
m_handler->parseError(m_proFile->fileName(), m_lineNo, msg);
|
m_handler->message(type, msg, m_proFile->fileName(), m_lineNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -44,8 +44,18 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QMAKE_EXPORT QMakeParserHandler
|
class QMAKE_EXPORT QMakeParserHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Some error during parsing
|
enum {
|
||||||
virtual void parseError(const QString &filename, int lineNo, const QString &msg) = 0;
|
CategoryMask = 0xf00,
|
||||||
|
ErrorMessage = 0x100,
|
||||||
|
|
||||||
|
SourceMask = 0xf0,
|
||||||
|
SourceParser = 0,
|
||||||
|
|
||||||
|
ParserIoError = ErrorMessage | SourceParser,
|
||||||
|
ParserError
|
||||||
|
};
|
||||||
|
virtual void message(int type, const QString &msg,
|
||||||
|
const QString &fileName = QString(), int lineNo = 0) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProFileCache;
|
class ProFileCache;
|
||||||
@@ -110,7 +120,9 @@ private:
|
|||||||
void flushCond(ushort *&tokPtr);
|
void flushCond(ushort *&tokPtr);
|
||||||
void flushScopes(ushort *&tokPtr);
|
void flushScopes(ushort *&tokPtr);
|
||||||
|
|
||||||
void parseError(const QString &msg) const;
|
void message(int type, const QString &msg) const;
|
||||||
|
void parseError(const QString &msg) const
|
||||||
|
{ message(QMakeParserHandler::ParserError, msg); }
|
||||||
|
|
||||||
// Current location
|
// Current location
|
||||||
ProFile *m_proFile;
|
ProFile *m_proFile;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static void print(const QString &fileName, int lineNo, const QString &msg)
|
|||||||
|
|
||||||
class ParseHandler : public QMakeParserHandler {
|
class ParseHandler : public QMakeParserHandler {
|
||||||
public:
|
public:
|
||||||
virtual void parseError(const QString &fileName, int lineNo, const QString &msg)
|
virtual void message(int /* type */, const QString &msg, const QString &fileName, int lineNo)
|
||||||
{ print(fileName, lineNo, msg); }
|
{ print(fileName, lineNo, msg); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -53,13 +53,9 @@ static void print(const QString &fileName, int lineNo, const QString &msg)
|
|||||||
|
|
||||||
class EvalHandler : public QMakeHandler {
|
class EvalHandler : public QMakeHandler {
|
||||||
public:
|
public:
|
||||||
virtual void parseError(const QString &fileName, int lineNo, const QString &msg)
|
virtual void message(int /* type */, const QString &msg, const QString &fileName, int lineNo)
|
||||||
{ print(fileName, lineNo, msg); }
|
{ print(fileName, lineNo, msg); }
|
||||||
|
|
||||||
virtual void configError(const QString &msg)
|
|
||||||
{ qWarning("%s", qPrintable(msg)); }
|
|
||||||
virtual void evalError(const QString &fileName, int lineNo, const QString &msg)
|
|
||||||
{ print(fileName, lineNo, msg); }
|
|
||||||
virtual void fileMessage(const QString &msg)
|
virtual void fileMessage(const QString &msg)
|
||||||
{ qWarning("%s", qPrintable(msg)); }
|
{ qWarning("%s", qPrintable(msg)); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user