Commit ae581598 authored by Alex Neundorf's avatar Alex Neundorf Committed by Christoph Cullmann

build plugin: add support for Intel icpc error messages

The format looks a bit different, an example is included in the
source file.
For gcc users still only one regex will be tested (after the first successfull one).
Intel users will have a bit more overhead.
I didn't measure it, but now the regex is checked only once, and after
that no additional searching in the string is done anymore, so it may
be even a bit faster.


parent 47fc7d5c
......@@ -85,8 +85,12 @@ KateBuildView::KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
: QObject (mw)
, m_proc(0)
// NOTE this will not allow spaces in file names.
, m_filenameDetector(QStringLiteral("([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+:[0-9]+")),
m_newDirDetector(QStringLiteral("make\\[.+\\]: .+ `.*'"))
// e.g. from gcc: "main.cpp:14: error: cannot convert ‘std::string’ to ‘int’ in return"
, m_filenameDetector(QStringLiteral("(([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+):([0-9]+)(.*)"))
// e.g. from icpc: "main.cpp(14): error: no suitable conversion function from "std::string" to "int" exists"
, m_filenameDetectorIcpc(QStringLiteral("(([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+)\\(([0-9]+)\\)(:.*)"))
, m_filenameDetectorGccWorked(false)
, m_newDirDetector(QStringLiteral("make\\[.+\\]: .+ `.*'"))
......@@ -668,7 +672,7 @@ bool KateBuildView::buildTarget(const QString& targetName, bool keepAsPrevTarget
buildCmd.replace(QStringLiteral("%f"), docFInfo.absoluteFilePath());
buildCmd.replace(QStringLiteral("%d"), docFInfo.absolutePath());
m_filenameDetectorGccWorked = false;
return startProcess(dir, buildCmd);
......@@ -804,26 +808,45 @@ void KateBuildView::slotReadReadyStdErr()
void KateBuildView::processLine(const QString &line)
QString l = line;
//qDebug() << l ;
//qDebug() << line ;
//look for a filename
if (l.indexOf(m_filenameDetector)<0)
int index = m_filenameDetector.indexIn(line);
QRegExp* rx = 0;
if (index >= 0)
addError(QString(), QStringLiteral("0"), QString(), l);
//qDebug() << "A filename was not found in the line ";
m_filenameDetectorGccWorked = true;
rx = &m_filenameDetector;
if (!m_filenameDetectorGccWorked)
// let's see whether the icpc regexp works:
// so for icpc users error detection will be a bit slower,
// since always both regexps are checked.
// But this should be the minority, for gcc and clang users
// both regexes will only be checked until the first regex
// matched the first time.
index = m_filenameDetectorIcpc.indexIn(line);
if (index >= 0)
rx = &m_filenameDetectorIcpc;
int match_start = m_filenameDetector.indexIn(l, 0);
int match_len = m_filenameDetector.matchedLength();
QString file_n_line = l.mid(match_start, match_len);
if (!rx)
addError(QString(), 0, QString(), line);
//kDebug() << "A filename was not found in the line ";
int name_end = file_n_line.lastIndexOf(QLatin1Char(':'));
QString filename = file_n_line.left(name_end);
QString line_n = file_n_line.mid(name_end+1);
QString msg = l.remove(m_filenameDetector);
QString filename = rx->cap(1);
QString line_n = rx->cap(3);
QString msg = rx->cap(4);
//qDebug() << "File Name:"<<filename<< " msg:"<< msg;
//add path to file
......@@ -147,6 +147,8 @@ class KateBuildView : public QObject, public KXMLGUIClient, public KTextEditor::
QString m_make_dir;
QStack<QString> m_make_dir_stack;
QRegExp m_filenameDetector;
QRegExp m_filenameDetectorIcpc;
bool m_filenameDetectorGccWorked;
QRegExp m_newDirDetector;
unsigned int m_numErrors;
unsigned int m_numWarnings;
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