data: saving errors to Storage
* saving errors in separate sqlite table * use MessageShowErrors to show the errors in the UI * show error count permanently in the right side of the status bar with click to show * fixed clicking of error locations * fixed expanding of files with errors
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -36,8 +36,8 @@ bool MouseWheelOverScrollbarFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
QRect scrollbarArea(scrollbar->pos(), scrollbar->size());
|
||||
QPoint globalMousePos = dynamic_cast<QWheelEvent*>(event)->globalPos();
|
||||
QPoint localMousePos = scrollbar->mapFromGlobal(globalMousePos);
|
||||
|
||||
// instead of "scrollbar->underMouse()" we need this check implemented here because "underMouse()"
|
||||
|
||||
// instead of "scrollbar->underMouse()" we need this check implemented here because "underMouse()"
|
||||
// does not work when the mouse enters the area without being moved
|
||||
if (scrollbarArea.contains(localMousePos))
|
||||
{
|
||||
@@ -114,7 +114,7 @@ QtCodeArea::QtCodeArea(
|
||||
this->setMouseTracking(true);
|
||||
|
||||
// MouseWheelOverScrollbarFilter is deleted by parent.
|
||||
horizontalScrollBar()->installEventFilter(new MouseWheelOverScrollbarFilter(this));
|
||||
horizontalScrollBar()->installEventFilter(new MouseWheelOverScrollbarFilter(this));
|
||||
}
|
||||
|
||||
QtCodeArea::~QtCodeArea()
|
||||
@@ -289,7 +289,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||
std::vector<Id> locationIds = findLocationIdsForPosition(cursor.position());
|
||||
if (locationIds.size())
|
||||
if (locationIds.size() && !m_fileWidget->getErrorMessages().size())
|
||||
{
|
||||
MessageActivateTokenLocations(locationIds).dispatch();
|
||||
}
|
||||
@@ -301,7 +301,7 @@ void QtCodeArea::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
MessageShowFile(m_fileWidget->getFilePath().str(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch();
|
||||
MessageShowFile(m_fileWidget->getFilePath().str(), (m_fileWidget->getErrorMessages().size() > 0)).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ void QtCodeFile::clickedMaximizeButton()
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageShowFile(m_filePath, 0, 0).dispatch();
|
||||
MessageShowFile(m_filePath, (getErrorMessages().size() > 0)).dispatch();
|
||||
}
|
||||
|
||||
m_minimizeButton->setEnabled(true);
|
||||
@@ -449,7 +449,7 @@ void QtCodeFile::doUpdateTitleBar()
|
||||
m_title->setStyleSheet("background-image: url(data/gui/code_view/images/pattern.png);");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
m_title->setStyleSheet("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ void QtCodeSnippet::clickedTitle()
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageShowFile(FilePath(m_titleString), 0, 0).dispatch();
|
||||
MessageShowFile(FilePath(m_titleString), (dynamic_cast<QtCodeFile*>(parent())->getErrorMessages().size() > 0)).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <QMovie>
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
|
||||
QtStatusBar::QtStatusBar()
|
||||
: m_text(this)
|
||||
{
|
||||
@@ -19,6 +22,17 @@ QtStatusBar::QtStatusBar()
|
||||
|
||||
m_text.setText("");
|
||||
addWidget(&m_text);
|
||||
|
||||
m_errorButton.hide();
|
||||
m_errorButton.setFlat(true);
|
||||
m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }");
|
||||
m_errorButton.setIcon(utility::colorizePixmap(
|
||||
QPixmap("data/gui/statusbar_view/octagon.png"),
|
||||
"#D00000"
|
||||
).scaledToHeight(10));
|
||||
addPermanentWidget(&m_errorButton);
|
||||
|
||||
connect(&m_errorButton, SIGNAL(clicked()), this, SLOT(showErrors()));
|
||||
}
|
||||
|
||||
QtStatusBar::~QtStatusBar()
|
||||
@@ -29,7 +43,7 @@ void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader
|
||||
{
|
||||
if (isError)
|
||||
{
|
||||
m_text.setStyleSheet("QLabel { color: #E00000 }");
|
||||
m_text.setStyleSheet("QLabel { color: #D00000 }");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -47,3 +61,21 @@ void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader
|
||||
|
||||
m_text.setText(text.c_str());
|
||||
}
|
||||
|
||||
void QtStatusBar::setErrorCount(size_t count)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
m_errorButton.setText(QString::number(count) + " error(s)");
|
||||
m_errorButton.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_errorButton.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void QtStatusBar::showErrors()
|
||||
{
|
||||
MessageShowErrors().dispatch();
|
||||
}
|
||||
|
||||
@@ -2,21 +2,30 @@
|
||||
#define QT_STATUS_BAR_H
|
||||
|
||||
#include <string>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QStatusBar>
|
||||
|
||||
class QtStatusBar
|
||||
: public QStatusBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtStatusBar(void);
|
||||
~QtStatusBar(void);
|
||||
virtual ~QtStatusBar(void);
|
||||
|
||||
void setText(const std::string& text, bool isError, bool showLoader);
|
||||
void setErrorCount(size_t count);
|
||||
|
||||
private slots:
|
||||
void showErrors();
|
||||
|
||||
private:
|
||||
QLabel m_text;
|
||||
QLabel m_loader;
|
||||
QPushButton m_errorButton;
|
||||
};
|
||||
|
||||
#endif // QT_STATUS_BAR_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "qt/view/QtStatusBarView.h"
|
||||
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "qt/view/QtMainView.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
|
||||
@@ -8,12 +9,14 @@ QtStatusBarView::QtStatusBarView(ViewLayout* viewLayout)
|
||||
: StatusBarView(viewLayout)
|
||||
, m_showMessageFunctor(std::bind(
|
||||
&QtStatusBarView::doShowMessage, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))
|
||||
, m_setErrorCountFunctor(std::bind(&QtStatusBarView::doSetErrorCount, this, std::placeholders::_1))
|
||||
{
|
||||
QtMainView* mw = static_cast<QtMainView*>(viewLayout);
|
||||
m_widget = std::make_shared<QtStatusBar>();
|
||||
m_widget->show();
|
||||
|
||||
QtMainView* mw = static_cast<QtMainView*>(viewLayout);
|
||||
QStatusBar* sb = static_cast<QStatusBar*>(m_widget.get());
|
||||
mw->setStatusBar(sb);
|
||||
m_widget->show();
|
||||
}
|
||||
|
||||
QtStatusBarView::~QtStatusBarView()
|
||||
@@ -32,12 +35,22 @@ void QtStatusBarView::refreshView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtStatusBarView::showMessage(const std::string& message, bool isError, bool showLoader)
|
||||
{
|
||||
m_showMessageFunctor(message, isError, showLoader);
|
||||
}
|
||||
|
||||
void QtStatusBarView::setErrorCount(size_t count)
|
||||
{
|
||||
m_setErrorCountFunctor(count);
|
||||
}
|
||||
|
||||
void QtStatusBarView::doShowMessage(const std::string& message, bool isError, bool showLoader)
|
||||
{
|
||||
m_widget->setText(message, isError, showLoader);
|
||||
}
|
||||
|
||||
void QtStatusBarView::showMessage(const std::string& message, bool isError, bool showLoader)
|
||||
void QtStatusBarView::doSetErrorCount(size_t count)
|
||||
{
|
||||
m_showMessageFunctor(message, isError, showLoader);
|
||||
m_widget->setErrorCount(count);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include "qt/element/QtStatusBar.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QtStatusBarView : public StatusBarView
|
||||
class QtStatusBarView
|
||||
: public StatusBarView
|
||||
{
|
||||
public:
|
||||
QtStatusBarView(ViewLayout* viewLayout);
|
||||
@@ -21,12 +22,16 @@ public:
|
||||
|
||||
// StatusBar view implementation
|
||||
virtual void showMessage(const std::string& message, bool isError, bool showLoader);
|
||||
virtual void setErrorCount(size_t count);
|
||||
|
||||
private:
|
||||
void doShowMessage(const std::string& message, bool isError, bool showLoader);
|
||||
std::shared_ptr<QtStatusBar> m_widget;
|
||||
void doSetErrorCount(size_t count);
|
||||
|
||||
QtThreadedFunctor<const std::string&, bool, bool> m_showMessageFunctor;
|
||||
QtThreadedFunctor<size_t> m_setErrorCountFunctor;
|
||||
|
||||
std::shared_ptr<QtStatusBar> m_widget;
|
||||
};
|
||||
|
||||
#endif // !QT_STATUS_BAR_VIEW_H
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/scheduling/TaskScheduler.h"
|
||||
#include "utility/Version.h"
|
||||
@@ -115,6 +116,10 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageShowErrors().dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageLoadProject* message)
|
||||
|
||||
@@ -265,6 +265,7 @@ add_files(
|
||||
utility/messaging/type/MessageSaveProject.h
|
||||
utility/messaging/type/MessageSearch.h
|
||||
utility/messaging/type/MessageSearchAutocomplete.h
|
||||
utility/messaging/type/MessageShowErrors.h
|
||||
utility/messaging/type/MessageShowFile.h
|
||||
utility/messaging/type/MessageShowScope.h
|
||||
utility/messaging/type/MessageShowSnippets.h
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ void Project::loadStorage()
|
||||
{
|
||||
m_storage->startParsing();
|
||||
m_storage->finishParsing();
|
||||
MessageFinishedParsing(0, 0, 0, 0).dispatch();
|
||||
MessageFinishedParsing(0, 0, 0, m_storage->getErrorCount()).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -78,30 +78,6 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
if (message->errorCount > 0)
|
||||
{
|
||||
std::vector<std::string> errorMessages;
|
||||
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(&errorMessages);
|
||||
|
||||
std::vector<CodeView::CodeSnippetParams> snippets;
|
||||
|
||||
errorCollection.forEachTokenLocationFile(
|
||||
[&](std::shared_ptr<TokenLocationFile> file) -> void
|
||||
{
|
||||
std::vector<CodeView::CodeSnippetParams> fileSnippets = getSnippetsForFile(file);
|
||||
snippets.insert(snippets.end(), fileSnippets.begin(), fileSnippets.end());
|
||||
}
|
||||
);
|
||||
|
||||
CodeView* view = getView();
|
||||
view->setActiveTokenIds(std::vector<Id>());
|
||||
view->setErrorMessages(errorMessages);
|
||||
view->showCodeSnippets(snippets);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageFocusIn* message)
|
||||
{
|
||||
getView()->focusToken(message->tokenId);
|
||||
@@ -112,17 +88,49 @@ void CodeController::handleMessage(MessageFocusOut* message)
|
||||
getView()->defocusToken();
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
std::vector<std::string> errorMessages;
|
||||
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(&errorMessages);
|
||||
|
||||
std::vector<CodeView::CodeSnippetParams> snippets;
|
||||
|
||||
errorCollection.forEachTokenLocationFile(
|
||||
[&](std::shared_ptr<TokenLocationFile> file) -> void
|
||||
{
|
||||
std::vector<CodeView::CodeSnippetParams> fileSnippets = getSnippetsForFile(file);
|
||||
snippets.insert(snippets.end(), fileSnippets.begin(), fileSnippets.end());
|
||||
}
|
||||
);
|
||||
|
||||
CodeView* view = getView();
|
||||
view->setActiveTokenIds(std::vector<Id>());
|
||||
view->setErrorMessages(errorMessages);
|
||||
view->showCodeSnippets(snippets);
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageShowFile* message)
|
||||
{
|
||||
CodeView::CodeSnippetParams params;
|
||||
params.startLineNumber = message->startLineNumber;
|
||||
params.endLineNumber = message->endLineNumber;
|
||||
params.startLineNumber = 0;
|
||||
params.endLineNumber = 0;
|
||||
|
||||
std::shared_ptr<TextAccess> textAccess = m_storageAccess->getFileContent(message->filePath);
|
||||
params.code = textAccess->getText();
|
||||
|
||||
params.modificationTime = m_storageAccess->getFileModificationTime(message->filePath);
|
||||
params.locationFile = m_storageAccess->getTokenLocationsForFile(message->filePath.str());
|
||||
|
||||
if (message->showErrors)
|
||||
{
|
||||
std::vector<std::string> errorMessages;
|
||||
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(&errorMessages);
|
||||
params.locationFile = std::make_shared<TokenLocationFile>(*errorCollection.findTokenLocationFileByPath(message->filePath));
|
||||
params.locationFile->isWholeCopy = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.locationFile = m_storageAccess->getTokenLocationsForFile(message->filePath.str());
|
||||
}
|
||||
|
||||
getView()->showCodeFile(params);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageShowFile.h"
|
||||
#include "utility/messaging/type/MessageShowScope.h"
|
||||
#include "utility/messaging/type/MessageShowSnippets.h"
|
||||
@@ -25,9 +25,9 @@ class TokenLocationFile;
|
||||
class CodeController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageFocusIn>
|
||||
, public MessageListener<MessageFocusOut>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
, public MessageListener<MessageShowFile>
|
||||
, public MessageListener<MessageShowScope>
|
||||
, public MessageListener<MessageShowSnippets>
|
||||
@@ -40,9 +40,9 @@ private:
|
||||
static const uint s_lineRadius;
|
||||
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
virtual void handleMessage(MessageFocusIn* message);
|
||||
virtual void handleMessage(MessageFocusOut* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
virtual void handleMessage(MessageShowFile* message);
|
||||
virtual void handleMessage(MessageShowScope* message);
|
||||
virtual void handleMessage(MessageShowSnippets* message);
|
||||
|
||||
@@ -134,6 +134,11 @@ void GraphController::handleMessage(MessageGraphNodeMove* message)
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
GraphView* GraphController::getView() const
|
||||
{
|
||||
return Controller::getView<GraphView>();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeExpand.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/view/GraphView.h"
|
||||
@@ -32,6 +33,7 @@ class GraphController
|
||||
, public MessageListener<MessageGraphNodeBundleSplit>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeMove>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
{
|
||||
public:
|
||||
GraphController(StorageAccess* storageAccess);
|
||||
@@ -45,6 +47,7 @@ private:
|
||||
virtual void handleMessage(MessageGraphNodeBundleSplit* message);
|
||||
virtual void handleMessage(MessageGraphNodeExpand* message);
|
||||
virtual void handleMessage(MessageGraphNodeMove* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
|
||||
GraphView* getView() const;
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ void SearchController::handleMessage(MessageSearchAutocomplete* message)
|
||||
getView()->setAutocompletionList(m_storageAccess->getAutocompletionMatches(message->query));
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
getView()->setMatches(std::vector<SearchMatch>());
|
||||
}
|
||||
|
||||
SearchView* SearchController::getView()
|
||||
{
|
||||
return Controller::getView<SearchView>();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
#include "utility/messaging/type/MessageSearchAutocomplete.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
|
||||
class StorageAccess;
|
||||
class SearchView;
|
||||
@@ -15,6 +16,7 @@ class SearchController
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageFind>
|
||||
, public MessageListener<MessageSearchAutocomplete>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
{
|
||||
public:
|
||||
SearchController(StorageAccess* storageAccess);
|
||||
@@ -24,6 +26,7 @@ private:
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageFind* message);
|
||||
virtual void handleMessage(MessageSearchAutocomplete* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
|
||||
SearchView* getView();
|
||||
|
||||
|
||||
@@ -17,6 +17,11 @@ StatusBarView* StatusBarController::getView()
|
||||
return Controller::getView<StatusBarView>();
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
getView()->setErrorCount(message->errorCount);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageStatus* message)
|
||||
{
|
||||
setStatus(message->status, message->isError, message->showLoader);
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
class StatusBarView;
|
||||
|
||||
class StatusBarController
|
||||
: public Controller
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageStatus>
|
||||
{
|
||||
public:
|
||||
@@ -21,6 +23,7 @@ public:
|
||||
StatusBarView* getView();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
virtual void handleMessage(MessageStatus* message);
|
||||
|
||||
void setStatus(const std::string& status, bool isError, bool showLoader);
|
||||
|
||||
@@ -196,6 +196,17 @@ void UndoRedoController::handleMessage(MessageSearch* message)
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (m_lastCommand.message && m_lastCommand.message->getType() == message->getType())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageShowErrors>(*message), 0);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageShowFile* message)
|
||||
{
|
||||
if (m_lastCommand.message && m_lastCommand.message->getType() == message->getType() &&
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageShowFile.h"
|
||||
#include "utility/messaging/type/MessageShowScope.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
@@ -39,6 +40,7 @@ class UndoRedoController
|
||||
, public MessageListener<MessageRedo>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
, public MessageListener<MessageShowFile>
|
||||
, public MessageListener<MessageShowScope>
|
||||
, public MessageListener<MessageUndo>
|
||||
@@ -69,6 +71,7 @@ private:
|
||||
virtual void handleMessage(MessageRedo* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
virtual void handleMessage(MessageShowFile* message);
|
||||
virtual void handleMessage(MessageShowScope* message);
|
||||
virtual void handleMessage(MessageUndo* message);
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
|
||||
virtual std::string getName() const;
|
||||
virtual void showMessage(const std::string& message, bool isError, bool showLoader) = 0;
|
||||
virtual void setErrorCount(size_t count) = 0;
|
||||
|
||||
protected:
|
||||
StatusBarController* getController();
|
||||
|
||||
@@ -164,6 +164,35 @@ Id SqliteStorage::addSignature(Id nodeId, const std::string& signature)
|
||||
return m_database.lastRowId();
|
||||
}
|
||||
|
||||
Id SqliteStorage::addError(const std::string& message, const std::string& filePath, uint lineNumber, uint columnNumber)
|
||||
{
|
||||
std::string sanitizedMessage = utility::replace(message, "'", "''");
|
||||
|
||||
// check for duplicate
|
||||
CppSQLite3Query q = m_database.execQuery((
|
||||
"SELECT * FROM error WHERE "
|
||||
"message == '" + sanitizedMessage + "' AND "
|
||||
"file_path == '" + filePath + "' AND "
|
||||
"line_number == " + std::to_string(lineNumber) + " AND "
|
||||
"column_number == " + std::to_string(columnNumber) + ";"
|
||||
).c_str());
|
||||
|
||||
if (!q.eof())
|
||||
{
|
||||
return q.getIntField(0, -1);
|
||||
}
|
||||
|
||||
std::cout << ("INSERT INTO error(message, file_path, line_number, column_number) "
|
||||
"VALUES ('" + sanitizedMessage + "', '" + filePath + "', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");") << std::endl;
|
||||
|
||||
m_database.execDML((
|
||||
"INSERT INTO error(message, file_path, line_number, column_number) "
|
||||
"VALUES ('" + sanitizedMessage + "', '" + filePath + "', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");"
|
||||
).c_str());
|
||||
|
||||
return m_database.lastRowId();
|
||||
}
|
||||
|
||||
void SqliteStorage::removeElement(Id id)
|
||||
{
|
||||
m_database.execDML((
|
||||
@@ -231,6 +260,13 @@ void SqliteStorage::removeUnusedNameHierarchyElements()
|
||||
);
|
||||
}
|
||||
|
||||
void SqliteStorage::removeErrorsInFiles(const std::vector<FilePath>& filePaths)
|
||||
{
|
||||
m_database.execDML((
|
||||
"DELETE FROM error WHERE file_path IN ('" + utility::join(utility::toStrings(filePaths), "', '") + "');"
|
||||
).c_str());
|
||||
}
|
||||
|
||||
StorageNode SqliteStorage::getFirstNode() const
|
||||
{
|
||||
std::vector<StorageNode> nodes = getAllNodes("LIMIT 1");
|
||||
@@ -691,6 +727,28 @@ Id SqliteStorage::getNodeIdBySignature(const std::string& signature) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<StorageError> SqliteStorage::getAllErrors() const
|
||||
{
|
||||
CppSQLite3Query q = m_database.execQuery(
|
||||
"SELECT message, file_path, line_number, column_number FROM error;"
|
||||
);
|
||||
|
||||
std::vector<StorageError> errors;
|
||||
while (!q.eof())
|
||||
{
|
||||
const std::string message = q.getStringField(0, "");
|
||||
const std::string filePath = q.getStringField(1, "");
|
||||
const uint lineNumber = q.getIntField(2, 0);
|
||||
const uint columnNumber = q.getIntField(3, 0);
|
||||
|
||||
errors.push_back(StorageError(message, filePath, lineNumber, columnNumber));
|
||||
|
||||
q.nextRow();
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
int SqliteStorage::getNodeCount() const
|
||||
{
|
||||
return m_database.execScalar("SELECT COUNT(*) FROM node;");
|
||||
@@ -718,6 +776,7 @@ int SqliteStorage::getSourceLocationCount() const
|
||||
|
||||
void SqliteStorage::clearTables()
|
||||
{
|
||||
m_database.execDML("DROP TABLE IF EXISTS main.error;");
|
||||
m_database.execDML("DROP TABLE IF EXISTS main.function_signature;");
|
||||
m_database.execDML("DROP TABLE IF EXISTS main.component_access;");
|
||||
m_database.execDML("DROP TABLE IF EXISTS main.source_location;");
|
||||
@@ -818,6 +877,16 @@ void SqliteStorage::setupTables()
|
||||
"PRIMARY KEY(id), "
|
||||
"FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE);"
|
||||
);
|
||||
|
||||
m_database.execDML(
|
||||
"CREATE TABLE IF NOT EXISTS error("
|
||||
"id INTEGER NOT NULL, "
|
||||
"message TEXT, "
|
||||
"file_path TEXT, "
|
||||
"line_number INTEGER, "
|
||||
"column_number INTEGER, "
|
||||
"PRIMARY KEY(id));"
|
||||
);
|
||||
}
|
||||
|
||||
bool SqliteStorage::hasTable(const std::string& tableName) const
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
Id addComponentAccess(Id memberEdgeId, int type);
|
||||
Id addSignature(Id nodeId, const std::string& signature);
|
||||
|
||||
Id addError(const std::string& message, const std::string& filePath, uint lineNumber, uint columnNumber);
|
||||
|
||||
void removeElement(Id id);
|
||||
void removeNameHierarchyElement(Id id);
|
||||
void removeElementsWithLocationInFiles(const std::vector<Id>& fileIds);
|
||||
@@ -49,6 +51,8 @@ public:
|
||||
void removeFiles(const std::vector<Id>& fileIds);
|
||||
void removeUnusedNameHierarchyElements();
|
||||
|
||||
void removeErrorsInFiles(const std::vector<FilePath>& filePaths);
|
||||
|
||||
StorageNode getFirstNode() const;
|
||||
std::vector<StorageNode> getAllNodes() const;
|
||||
|
||||
@@ -101,6 +105,8 @@ public:
|
||||
std::vector<StorageComponentAccess> getComponentAccessByMemberEdgeIds(const std::vector<Id>& memberEdgeIds) const;
|
||||
Id getNodeIdBySignature(const std::string& signature) const;
|
||||
|
||||
std::vector<StorageError> getAllErrors() const;
|
||||
|
||||
int getNodeCount() const;
|
||||
int getEdgeCount() const;
|
||||
int getFileCount() const;
|
||||
|
||||
+16
-36
@@ -41,9 +41,6 @@ void Storage::clear()
|
||||
m_sqliteStorage.clear();
|
||||
|
||||
clearCaches();
|
||||
|
||||
m_errorMessages.clear();
|
||||
m_errorLocationCollection.clear();
|
||||
}
|
||||
|
||||
void Storage::clearCaches()
|
||||
@@ -96,6 +93,8 @@ void Storage::clearFileElements(const std::vector<FilePath>& filePaths)
|
||||
{
|
||||
m_sqliteStorage.removeElementsWithLocationInFiles(fileNodeIds);
|
||||
m_sqliteStorage.removeFiles(fileNodeIds);
|
||||
|
||||
m_sqliteStorage.removeErrorsInFiles(filePaths);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,41 +182,12 @@ void Storage::onError(const ParseLocation& location, const std::string& message)
|
||||
return;
|
||||
}
|
||||
|
||||
bool duplicate = false;
|
||||
TokenLocationFile* file = m_errorLocationCollection.findTokenLocationFileByPath(location.filePath);
|
||||
|
||||
if (file)
|
||||
{
|
||||
file->forEachStartTokenLocation(
|
||||
[&](TokenLocation* loc)
|
||||
{
|
||||
if (loc->getLineNumber() == location.startLineNumber &&
|
||||
loc->getColumnNumber() == location.startColumnNumber &&
|
||||
m_errorMessages[loc->getTokenId()] == message)
|
||||
{
|
||||
duplicate = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!duplicate)
|
||||
{
|
||||
Id errorId = m_errorMessages.size();
|
||||
|
||||
m_errorLocationCollection.addTokenLocation(
|
||||
getErrorCount(), errorId, location.filePath,
|
||||
location.startLineNumber, location.startColumnNumber,
|
||||
location.endLineNumber, location.endColumnNumber
|
||||
);
|
||||
|
||||
m_errorMessages.push_back(message);
|
||||
}
|
||||
m_sqliteStorage.addError(message, location.filePath.str(), location.startLineNumber, location.startColumnNumber);
|
||||
}
|
||||
|
||||
size_t Storage::getErrorCount() const
|
||||
{
|
||||
return m_errorLocationCollection.getTokenLocationCount();
|
||||
return m_sqliteStorage.getAllErrors().size();
|
||||
}
|
||||
|
||||
Id Storage::onTypedefParsed(
|
||||
@@ -1176,8 +1146,18 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationsForLinesInFile(
|
||||
|
||||
TokenLocationCollection Storage::getErrorTokenLocations(std::vector<std::string>* errorMessages) const
|
||||
{
|
||||
errorMessages->insert(errorMessages->begin(), m_errorMessages.begin(), m_errorMessages.end());
|
||||
return m_errorLocationCollection;
|
||||
TokenLocationCollection errorCollection;
|
||||
|
||||
std::vector<StorageError> errors = m_sqliteStorage.getAllErrors();
|
||||
for (size_t i = 0; i < errors.size(); i++)
|
||||
{
|
||||
const StorageError& error = errors[i];
|
||||
errorCollection.addTokenLocation(
|
||||
i, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber);
|
||||
errorMessages->push_back(error.message);
|
||||
}
|
||||
|
||||
return errorCollection;
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationFile> Storage::getTokenLocationOfParentScope(const TokenLocation* child) const
|
||||
|
||||
@@ -203,9 +203,6 @@ private:
|
||||
mutable std::map <FilePath, Id> m_fileNodeIds;
|
||||
HierarchyCache m_hierarchyCache;
|
||||
|
||||
TokenLocationCollection m_errorLocationCollection;
|
||||
std::vector<std::string> m_errorMessages;
|
||||
|
||||
mutable SearchResults m_cachedResults;
|
||||
mutable std::string m_cachedQuery;
|
||||
};
|
||||
|
||||
@@ -80,4 +80,19 @@ struct StorageComponentAccess
|
||||
int type;
|
||||
};
|
||||
|
||||
struct StorageError
|
||||
{
|
||||
StorageError(const std::string& message, const std::string& filePath, uint lineNumber, uint columnNumber)
|
||||
: message(message)
|
||||
, filePath(filePath)
|
||||
, lineNumber(lineNumber)
|
||||
, columnNumber(columnNumber)
|
||||
{}
|
||||
|
||||
std::string message;
|
||||
std::string filePath;
|
||||
uint lineNumber;
|
||||
uint columnNumber;
|
||||
};
|
||||
|
||||
#endif // STORAGE_TYPES_H
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MESSAGE_SHOW_ERRORS_H
|
||||
#define MESSAGE_SHOW_ERRORS_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageShowErrors
|
||||
: public Message<MessageShowErrors>
|
||||
{
|
||||
public:
|
||||
MessageShowErrors()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowErrors";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERRORS_H
|
||||
@@ -9,10 +9,9 @@ class MessageShowFile
|
||||
: public Message<MessageShowFile>
|
||||
{
|
||||
public:
|
||||
MessageShowFile(const FilePath& filePath, uint startLineNumber, uint endLineNumber)
|
||||
MessageShowFile(const FilePath& filePath, bool showErrors)
|
||||
: filePath(filePath)
|
||||
, startLineNumber(startLineNumber)
|
||||
, endLineNumber(endLineNumber)
|
||||
, showErrors(showErrors)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,8 +21,7 @@ public:
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
const uint startLineNumber;
|
||||
const uint endLineNumber;
|
||||
const bool showErrors;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_FILE_H
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/math/Vector2.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
@@ -81,4 +82,15 @@ std::vector<std::string> utility::toStrings(const std::vector<T>& d)
|
||||
return v;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::vector<std::string> utility::toStrings<FilePath>(const std::vector<FilePath>& d)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
for (const FilePath& t : d)
|
||||
{
|
||||
v.push_back(t.str());
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
#endif // UTILITY_H
|
||||
|
||||
Reference in New Issue
Block a user