Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renabled error dots

  • Loading branch information...
commit 24579d51b09a14f688b3ce0e8681c30b111c00ac 1 parent 7aa2d1f
@bmcdorman bmcdorman authored
View
44 include/output_helper.hpp
@@ -0,0 +1,44 @@
+#ifndef _OUTPUT_HELPER_HPP_
+#define _OUTPUT_HELPER_HPP_
+
+#include "pcompiler/output.hpp"
+#include <QList>
+
+namespace Kiss
+{
+ class Lines
+ {
+ public:
+ enum Type
+ {
+ Unknown,
+ Warning,
+ Error
+ };
+
+ typedef unsigned int line_t;
+ typedef QList<line_t> LineList;
+
+ Lines();
+ Lines(const LineList& warningLines, const LineList& errorLines);
+
+ const LineList& warningLines() const;
+ const LineList& errorLines() const;
+
+ Lines operator+(const Lines& rhs) const;
+
+ private:
+ QList<line_t> m_warningLines;
+ QList<line_t> m_errorLines;
+ };
+
+ class OutputHelper
+ {
+ public:
+ static Lines lines(const Compiler::Output& output);
+ private:
+ static Lines::Type classifyLine(const QString& line);
+ };
+}
+
+#endif
View
3  include/source_file.hpp
@@ -24,6 +24,7 @@
#include "editor_settings_dialog.hpp"
#include "tab.hpp"
#include "unit.hpp"
+#include "output_helper.hpp"
#include "source_find_widget.hpp"
#include "qt_target_responder.hpp"
@@ -182,7 +183,7 @@ namespace Kiss
QWidget *m_runTab;
void clearProblems();
- void markProblems(const QStringList& errors, const QStringList& warnings);
+ void markProblems(const Lines& lines);
void updateErrors(const Compiler::OutputList& compileResult);
void updateTitle();
View
2  include/template_file.hpp
@@ -20,6 +20,8 @@ namespace Kiss
const QString& lexer() const;
const QByteArray& data() const;
+ QString resolvedData() const;
+
void setLexer(const QString& lexer);
void setData(const QByteArray& data);
View
67 src/output_helper.cpp
@@ -0,0 +1,67 @@
+#include "output_helper.hpp"
+
+#include <QString>
+#include <QStringList>
+
+using namespace Kiss;
+
+Lines::Lines()
+{
+}
+
+Lines::Lines(const LineList& warningLines, const LineList& errorLines)
+ : m_warningLines(warningLines),
+ m_errorLines(errorLines)
+{
+}
+
+const Lines::LineList& Lines::warningLines() const
+{
+ return m_warningLines;
+}
+
+const Lines::LineList& Lines::errorLines() const
+{
+ return m_errorLines;
+}
+
+Lines Lines::operator+(const Lines& rhs) const
+{
+ return Lines(m_warningLines + rhs.warningLines(),
+ m_errorLines + rhs.errorLines());
+}
+
+Lines OutputHelper::lines(const Compiler::Output& output)
+{
+ Lines::LineList errorLines;
+ Lines::LineList warningLines;
+ QString str = QString(output.error()) + "\n" + QString(output.output());
+ QStringList lines = str.split("\n");
+
+ foreach(const QString& line, lines) {
+ const Lines::Type classification = classifyLine(line);
+ if(classification == Lines::Unknown) continue;
+
+ int lineNumber = line.section(":", 1, 1).toInt();
+ if(--lineNumber < 0) continue;
+
+ if(classification == Lines::Error) errorLines << lineNumber;
+ else if(classification == Lines::Warning) warningLines << lineNumber;
+ }
+
+ return Lines(warningLines, errorLines);
+}
+
+Lines::Type OutputHelper::classifyLine(const QString& line)
+{
+ // Clang and GCC
+ const QString gcc = line.section(":", 3, 3);
+ if(gcc.contains("error", Qt::CaseInsensitive)) return Lines::Error;
+ if(gcc.contains("warning", Qt::CaseInsensitive)) return Lines::Warning;
+
+ // We hopefully didn't get here. Expand search.
+ if(line.contains("error", Qt::CaseInsensitive)) return Lines::Error;
+ if(line.contains("warning", Qt::CaseInsensitive)) return Lines::Warning;
+
+ return Lines::Unknown;
+}
View
31 src/source_file.cpp
@@ -40,6 +40,7 @@
#include "interface_manager.hpp"
#include "resource_helper.hpp"
#include "interface.hpp"
+#include "output_helper.hpp"
#include <pcompiler/pcompiler.hpp>
@@ -419,7 +420,7 @@ void SourceFile::refreshSettings()
updateMargins();
ui_editor->setMarginsBackgroundColor(QColor(Qt::white));
- ui_editor->setMarginsForegroundColor(QColor(200, 200, 200));
+ ui_editor->setMarginsForegroundColor(QColor(185, 185, 185));
Menu::TargetMenu::ref().refresh();
}
@@ -694,6 +695,7 @@ const bool SourceFile::changeTarget()
{
Dialog::Target targetDialog(&Target::InterfaceManager::ref(), this);
if(targetDialog.exec() == QDialog::Rejected) return false;
+ if(targetDialog.target().isNull()) return false;
setTarget(targetDialog.target());
target()->clearResponders();
@@ -747,6 +749,7 @@ void SourceFile::compileFinished(const Compiler::OutputList& result)
error |= out.exitCode() != 0 || !out.error().isEmpty();
}
mainWindow()->setStatusMessage(tr("Compile ") + (!error ? tr("Succeeded") : tr("Failed")));
+ updateErrors(result);
}
void SourceFile::downloadFinished(const bool& success)
@@ -821,28 +824,24 @@ void SourceFile::clearProblems()
ui_editor->markerDeleteAll(m_warningIndicator);
}
-void SourceFile::markProblems(const QStringList& errors, const QStringList& warnings)
+void SourceFile::markProblems(const Lines& lines)
{
- foreach(const QString& error, errors) {
- int line = error.section(":", 1, 1).toInt();
- if(--line < 0) continue;
- ui_editor->markerAdd(line, m_errorIndicator);
- }
-
- foreach(const QString& warning, warnings) {
- int line = warning.section(":", 1, 1).toInt();
- if(--line < 0) continue;
+ foreach(const Lines::line_t& line, lines.warningLines()) {
ui_editor->markerAdd(line, m_warningIndicator);
}
+ foreach(const Lines::line_t& line, lines.errorLines()) {
+ ui_editor->markerAdd(line, m_errorIndicator);
+ }
}
void SourceFile::updateErrors(const Compiler::OutputList& compileResult)
{
clearProblems();
-
- // mainWindow()->setOutputList(compileResult);
-
- // markProblems(errors, warnings);
+ Lines lines;
+ foreach(const Compiler::Output& output, compileResult) {
+ lines = lines + OutputHelper::lines(output);
+ }
+ markProblems(lines);
}
const bool SourceFile::selectTemplate()
@@ -858,7 +857,7 @@ const bool SourceFile::selectTemplate()
m_templateExt = tFile.lexer();
}
- ui_editor->setText(QString(tFile.data()));
+ ui_editor->setText(tFile.resolvedData());
// m_lexAPI = QString(targetPath).replace(QString(".") + TARGET_EXT, ".api");
View
9 src/template_file.cpp
@@ -1,5 +1,7 @@
#include "template_file.hpp"
+#include <QDateTime>
+
#define KISS_LEXER "KISS_LEXER"
#define KISS_DATE "KISS_DATE"
#define END_KISS "END_KISS_META"
@@ -36,6 +38,13 @@ const QByteArray& File::data() const
return m_data;
}
+QString File::resolvedData() const
+{
+ QString dataString(m_data);
+ dataString.replace("KISS_DATE", QDateTime::currentDateTime().toString("ddd MMMM d yyyy"));
+ return dataString;
+}
+
void File::setLexer(const QString& lexer)
{
m_lexer = lexer;
View
1  src/widgets/source_find_widget.cpp
@@ -52,6 +52,7 @@ void SourceFind::show()
ui_find->clear();
ui_replace->clear();
QWidget::show();
+ ui_find->setFocus(Qt::PopupFocusReason);
}
void SourceFind::on_ui_next_clicked()
Please sign in to comment.
Something went wrong with that request. Please try again.