summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2014-01-20 23:25:00 (GMT)
committerAlex Neundorf <neundorf@kde.org>2014-01-20 23:25:00 (GMT)
commit33f5deef3f7537d2c4269b912e97df230291e2fc (patch)
tree7ccd0cb441648d198ee28eade58cd8a306112d11
parentd09b782d602a7fa385ca41ae38db5a3ace47830d (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
-rw-r--r--addons/kate/katebuild-plugin/plugin_katebuild.cpp55
-rw-r--r--addons/kate/katebuild-plugin/plugin_katebuild.h2
2 files changed, 42 insertions, 15 deletions
diff --git a/addons/kate/katebuild-plugin/plugin_katebuild.cpp b/addons/kate/katebuild-plugin/plugin_katebuild.cpp
index e78e730..d786499 100644
--- a/addons/kate/katebuild-plugin/plugin_katebuild.cpp
+++ b/addons/kate/katebuild-plugin/plugin_katebuild.cpp
@@ -99,8 +99,12 @@ KateBuildView::KateBuildView(Kate::MainWindow *mw)
)
, m_proc(0)
// NOTE this will not allow spaces in file names.
- , m_filenameDetector("([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+:[0-9]+"),
- m_newDirDetector("make\\[.+\\]: .+ `.*'")
+ // e.g. from gcc: "main.cpp:14: error: cannot convert ‘std::string’ to ‘int’ in return"
+ , m_filenameDetector("(([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("(([a-np-zA-Z]:[\\\\/])?[a-zA-Z0-9_\\.\\-/\\\\]+\\.[a-zA-Z0-9]+)\\(([0-9]+)\\)(:.*)")
+ , m_filenameDetectorGccWorked(false)
+ , m_newDirDetector("make\\[.+\\]: .+ `.*'")
{
m_targetList.append(Target());
@@ -512,6 +516,8 @@ bool KateBuildView::startProcess(const KUrl &dir, const QString &command)
return false;
}
+ m_filenameDetectorGccWorked = false;
+
// clear previous runs
m_buildUi.plainTextEdit->clear();
m_buildUi.errTreeWidget->clear();
@@ -667,26 +673,45 @@ void KateBuildView::slotReadReadyStdErr()
/******************************************************************/
void KateBuildView::processLine(const QString &line)
{
- QString l = line;
- //kDebug() << l ;
+ //kDebug() << line ;
//look for a filename
- if (l.indexOf(m_filenameDetector)<0)
+ int index = m_filenameDetector.indexIn(line);
+
+ QRegExp* rx = 0;
+ if (index >= 0)
+ {
+ m_filenameDetectorGccWorked = true;
+ rx = &m_filenameDetector;
+ }
+ else
{
- addError(QString(), 0, QString(), l);
+ 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;
+ }
+ }
+ }
+
+ if (!rx)
+ {
+ addError(QString(), 0, QString(), line);
//kDebug() << "A filename was not found in the line ";
return;
}
- int match_start = m_filenameDetector.indexIn(l, 0);
- int match_len = m_filenameDetector.matchedLength();
-
- QString file_n_line = l.mid(match_start, match_len);
-
- int name_end = file_n_line.lastIndexOf(':');
- 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);
//kDebug() << "File Name:"<<filename<< " msg:"<< msg;
//add path to file
diff --git a/addons/kate/katebuild-plugin/plugin_katebuild.h b/addons/kate/katebuild-plugin/plugin_katebuild.h
index f60c872..27b6e39 100644
--- a/addons/kate/katebuild-plugin/plugin_katebuild.h
+++ b/addons/kate/katebuild-plugin/plugin_katebuild.h
@@ -128,6 +128,8 @@ class KateBuildView : public Kate::PluginView, public Kate::XMLGUIClient
KUrl m_make_dir;
QStack<KUrl> m_make_dir_stack;
QRegExp m_filenameDetector;
+ QRegExp m_filenameDetectorIcpc;
+ bool m_filenameDetectorGccWorked;
QRegExp m_newDirDetector;
unsigned int m_numErrors;
unsigned int m_numWarnings;