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);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void ProMessageHandler::configError(const QString &msg)
|
||||
{
|
||||
emit errorFound(msg);
|
||||
}
|
||||
|
||||
void ProMessageHandler::evalError(const QString &fileName, int lineNo, const QString &msg)
|
||||
{
|
||||
if (m_verbose)
|
||||
if ((type & CategoryMask) == ErrorMessage && ((type & SourceMask) == SourceParser || m_verbose))
|
||||
emit errorFound(format(fileName, lineNo, msg));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,7 @@ public:
|
||||
|
||||
virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {}
|
||||
virtual void doneWithEval(ProFile *) {}
|
||||
virtual void parseError(const QString &filename, int lineNo, const QString &msg);
|
||||
virtual void configError(const QString &msg);
|
||||
virtual void evalError(const QString &filename, int lineNo, const QString &msg);
|
||||
virtual void message(int type, const QString &msg, const QString &fileName, int lineNo);
|
||||
virtual void fileMessage(const QString &msg);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -184,7 +184,7 @@ void QMakeEvaluator::runProcess(QProcess *proc, const QString &command,
|
||||
QByteArray errout = proc->readAll();
|
||||
if (errout.endsWith('\n'))
|
||||
errout.chop(1);
|
||||
m_handler->evalError(QString(), 0, QString::fromLocal8Bit(errout));
|
||||
m_handler->message(QMakeHandler::EvalError, QString::fromLocal8Bit(errout));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1056,7 +1056,7 @@ bool QMakeEvaluator::loadSpec()
|
||||
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;
|
||||
}
|
||||
cool:
|
||||
@@ -1070,8 +1070,7 @@ bool QMakeEvaluator::loadSpec()
|
||||
return false;
|
||||
QString spec = m_qmakespec + QLatin1String("/qmake.conf");
|
||||
if (!evaluateFileDirect(spec, QMakeHandler::EvalConfigFile, LoadProOnly)) {
|
||||
m_handler->configError(
|
||||
fL1S("Could not read qmake configuration file %1").arg(spec));
|
||||
evalError(fL1S("Could not read qmake configuration file %1").arg(spec));
|
||||
return false;
|
||||
}
|
||||
#ifdef Q_OS_UNIX
|
||||
@@ -1973,11 +1972,11 @@ bool QMakeEvaluator::evaluateFileInto(const QString &fileName, QMakeHandler::Eva
|
||||
return true;
|
||||
}
|
||||
|
||||
void QMakeEvaluator::evalError(const QString &message) const
|
||||
void QMakeEvaluator::message(int type, const QString &msg) const
|
||||
{
|
||||
if (!m_skipLevel)
|
||||
m_handler->evalError(m_current.line ? m_current.pro->fileName() : QString(),
|
||||
m_current.line, message);
|
||||
m_handler->message(type, msg,
|
||||
m_current.line ? m_current.pro->fileName() : QString(), m_current.line);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -50,11 +50,13 @@ class QMakeGlobals;
|
||||
class QMAKE_EXPORT QMakeHandler : public QMakeParserHandler
|
||||
{
|
||||
public:
|
||||
// qmake/project configuration error
|
||||
virtual void configError(const QString &msg) = 0;
|
||||
// Some error during evaluation
|
||||
virtual void evalError(const QString &filename, int lineNo, const QString &msg) = 0;
|
||||
// error() and message() from .pro file
|
||||
enum {
|
||||
SourceEvaluator = 0x10,
|
||||
|
||||
EvalError = ErrorMessage | SourceEvaluator
|
||||
};
|
||||
|
||||
// error(), warning() and message() from .pro file
|
||||
virtual void fileMessage(const QString &msg) = 0;
|
||||
|
||||
enum EvalFileType { EvalProjectFile, EvalIncludeFile, EvalConfigFile, EvalFeatureFile, EvalAuxFile };
|
||||
@@ -141,7 +143,9 @@ public:
|
||||
bool evaluateFileInto(const QString &fileName, QMakeHandler::EvalFileType type,
|
||||
ProValueMap *values, // output-only
|
||||
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 ProString &arguments);
|
||||
|
||||
@@ -204,8 +204,8 @@ bool QMakeParser::read(ProFile *pro)
|
||||
QFile file(pro->fileName());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
if (m_handler && IoUtils::exists(pro->fileName()))
|
||||
m_handler->parseError(QString(), 0, fL1S("Cannot read %1: %2")
|
||||
.arg(pro->fileName(), file.errorString()));
|
||||
m_handler->message(QMakeParserHandler::ParserIoError,
|
||||
fL1S("Cannot read %1: %2").arg(pro->fileName(), file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1086,10 +1086,10 @@ bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort
|
||||
return true;
|
||||
}
|
||||
|
||||
void QMakeParser::parseError(const QString &msg) const
|
||||
void QMakeParser::message(int type, const QString &msg) const
|
||||
{
|
||||
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
|
||||
|
||||
@@ -44,8 +44,18 @@ QT_BEGIN_NAMESPACE
|
||||
class QMAKE_EXPORT QMakeParserHandler
|
||||
{
|
||||
public:
|
||||
// Some error during parsing
|
||||
virtual void parseError(const QString &filename, int lineNo, const QString &msg) = 0;
|
||||
enum {
|
||||
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;
|
||||
@@ -110,7 +120,9 @@ private:
|
||||
void flushCond(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
|
||||
ProFile *m_proFile;
|
||||
|
||||
@@ -47,7 +47,7 @@ static void print(const QString &fileName, int lineNo, const QString &msg)
|
||||
|
||||
class ParseHandler : public QMakeParserHandler {
|
||||
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); }
|
||||
};
|
||||
|
||||
|
||||
@@ -53,13 +53,9 @@ static void print(const QString &fileName, int lineNo, const QString &msg)
|
||||
|
||||
class EvalHandler : public QMakeHandler {
|
||||
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); }
|
||||
|
||||
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)
|
||||
{ qWarning("%s", qPrintable(msg)); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user