aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2014-01-17 21:10:54 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-25 21:44:29 (GMT)
commitae58159832573fdf70edc12e39827cff1ac5710a (patch)
tree6930b463f3da725254219e547b5ce561f01f148d
parent47fc7d5cbf377d9f1ebd7244710836bb5165561d (diff)
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. Alex Conflicts: addons/katebuild-plugin/plugin_katebuild.cpp
-rw-r--r--addons/katebuild-plugin/plugin_katebuild.cpp59
-rw-r--r--addons/katebuild-plugin/plugin_katebuild.h2
2 files changed, 43 insertions, 18 deletions
diff --git a/addons/katebuild-plugin/plugin_katebuild.cpp b/addons/katebuild-plugin/plugin_katebuild.cpp
index 4418a65..b5a05b8 100644
--- a/addons/katebuild-plugin/plugin_katebuild.cpp
+++ b/addons/katebuild-plugin/plugin_katebuild.cpp
@@ -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\\[.+\\]: .+ `.*'"))
{
m_win=mw;
@@ -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 ";
- return;
+ m_filenameDetectorGccWorked = true;
+ rx = &m_filenameDetector;
+ }
+ else
+ {
+ 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 ";
+ return;
+ }
- 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
diff --git a/addons/katebuild-plugin/plugin_katebuild.h b/addons/katebuild-plugin/plugin_katebuild.h
index 213b50f..aa3e2f2 100644
--- a/addons/katebuild-plugin/plugin_katebuild.h
+++ b/addons/katebuild-plugin/plugin_katebuild.h
@@ -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;