cppcheck-verify: added code editor that highlight the errors
This commit is contained in:
parent
2387ed49f3
commit
af8a178b71
|
@ -1,7 +1,6 @@
|
|||
TARGET = cppcheck-verify
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += ../lib
|
||||
|
||||
SOURCES += main.cpp \
|
||||
mainwindow.cpp \
|
||||
../lib/tokenize.cpp \
|
||||
|
@ -13,8 +12,8 @@ SOURCES += main.cpp \
|
|||
../lib/filelister_win32.cpp \
|
||||
../lib/filelister_unix.cpp \
|
||||
../lib/filelister.cpp \
|
||||
../lib/errorlogger.cpp
|
||||
|
||||
../lib/errorlogger.cpp \
|
||||
codeeditor.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
../lib/tokenize.h \
|
||||
../lib/token.h \
|
||||
|
@ -25,7 +24,6 @@ HEADERS += mainwindow.h \
|
|||
../lib/filelister_win32.h \
|
||||
../lib/filelister_unix.h \
|
||||
../lib/filelister.h \
|
||||
../lib/errorlogger.h
|
||||
|
||||
../lib/errorlogger.h \
|
||||
codeeditor.h
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
|
|
|
@ -98,29 +98,25 @@ void MainWindow::open()
|
|||
// show report..
|
||||
{
|
||||
std::ostringstream report;
|
||||
report << std::string(8,' ');
|
||||
unsigned int lineno = 1;
|
||||
std::ifstream fin(fileName.c_str());
|
||||
for (unsigned char c = readChar(fin); fin.good(); c = readChar(fin))
|
||||
{
|
||||
if (c & 0x80)
|
||||
continue;
|
||||
report << c;
|
||||
if (c == '\n')
|
||||
{
|
||||
++lineno;
|
||||
if (errorlines.find(lineno) != errorlines.end())
|
||||
report << std::string(6,'!') << " ";
|
||||
else
|
||||
report << std::string(8,' ');
|
||||
}
|
||||
}
|
||||
ui->plainTextEdit->setPlainText(QString::fromStdString(report.str()));
|
||||
ui->codeEditor->setPlainText(QString::fromStdString(report.str()));
|
||||
|
||||
QList<int> errorLines;
|
||||
for (std::set<unsigned int>::const_iterator it = errorlines.begin(); it != errorlines.end(); ++it)
|
||||
errorLines.push_back(*it);
|
||||
ui->codeEditor->highlightErrors(errorLines);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check that array indexes are within bounds
|
||||
* 1. Locate array access through: [ .. ]
|
||||
|
|
|
@ -40,5 +40,4 @@ private slots:
|
|||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -16,9 +16,15 @@
|
|||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="plainText">
|
||||
<string>ab</string>
|
||||
<widget class="CodeEditor" name="codeEditor">
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabStopWidth">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -57,6 +63,13 @@
|
|||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CodeEditor</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header>codeeditor.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in New Issue