ui: Errorview

Tabbed view with errorview as tab
This commit is contained in:
Andreas Stallinger
2016-10-13 12:37:10 +02:00
parent 97b151371b
commit dc064e4756
82 changed files with 1641 additions and 197 deletions
+13 -1
View File
@@ -17,13 +17,16 @@ add_files(
component/controller/CodeController.h
component/controller/Controller.cpp
component/controller/Controller.h
component/controller/ErrorController.cpp
component/controller/ErrorController.h
component/controller/FeatureController.cpp
component/controller/FeatureController.h
component/controller/GraphController.cpp
component/controller/GraphController.h
component/controller/IDECommunicationController.cpp
component/controller/IDECommunicationController.h
component/controller/LogController.cpp
component/controller/LogController.h
component/controller/NetworkFactory.cpp
component/controller/NetworkFactory.h
component/controller/RefreshController.cpp
@@ -43,11 +46,15 @@ add_files(
component/view/CompositeView.h
component/view/DialogView.cpp
component/view/DialogView.h
component/view/ErrorView.cpp
component/view/ErrorView.h
component/view/GraphView.cpp
component/view/GraphView.h
component/view/GraphViewStyle.cpp
component/view/GraphViewStyle.h
component/view/GraphViewStyleImpl.h
component/view/LogView.cpp
component/view/LogView.h
component/view/MainView.cpp
component/view/MainView.h
component/view/RefreshView.cpp
@@ -56,6 +63,8 @@ add_files(
component/view/SearchView.h
component/view/StatusBarView.cpp
component/view/StatusBarView.h
component/view/TabbedView.cpp
component/view/TabbedView.h
component/view/UndoRedoView.cpp
component/view/UndoRedoView.h
component/view/View.cpp
@@ -165,6 +174,7 @@ add_files(
data/DefinitionType.cpp
data/DefinitionType.h
data/ErrorCountInfo.h
data/ErrorFilter.h
data/ErrorInfo.h
data/HierarchyCache.cpp
data/HierarchyCache.h
@@ -260,6 +270,7 @@ add_files(
utility/messaging/type/MessageDeactivateEdge.h
utility/messaging/type/MessageDispatchWhenLicenseValid.h
utility/messaging/type/MessageEnteredLicense.h
utility/messaging/type/MessageErrorFilterChanged.h
utility/messaging/type/MessageFind.h
utility/messaging/type/MessageFinishedParsing.h
utility/messaging/type/MessageFlushUpdates.h
@@ -272,6 +283,7 @@ add_files(
utility/messaging/type/MessageInterruptTasks.h
utility/messaging/type/MessageLoadProject.h
utility/messaging/type/MessageMoveIDECursor.h
utility/messaging/type/MessageNewErrors.h
utility/messaging/type/MessagePluginPortChange.h
utility/messaging/type/MessageProjectEdit.h
utility/messaging/type/MessageProjectNew.h
+3 -5
View File
@@ -289,10 +289,6 @@ bool Project::buildIndex(bool forceRefresh)
MessageStatus("Nothing to refresh, all files are up-to-date.").dispatch();
return false;
}
else
{
MessageClearErrorCount().dispatch();
}
if (Application::getInstance()->hasGUI())
{
@@ -304,6 +300,8 @@ bool Project::buildIndex(bool forceRefresh)
}
}
MessageClearErrorCount().dispatch();
if (forceRefresh)
{
m_storage->clear();
@@ -353,7 +351,7 @@ bool Project::buildIndex(bool forceRefresh)
taskRepeat->setTask(std::make_shared<TaskInjectStorage>(storageProvider, m_storage));
}
taskSequential->addTask(std::make_shared<TaskFinishParsing>(m_storage.get(), fileRegister, m_dialogView));
taskSequential->addTask(std::make_shared<TaskFinishParsing>(m_storage.get(), m_storageAccessProxy, fileRegister, m_dialogView));
Task::dispatch(taskSequential);
+20
View File
@@ -2,14 +2,18 @@
#include "component/Component.h"
#include "component/controller/CodeController.h"
#include "component/controller/ErrorController.h"
#include "component/controller/FeatureController.h"
#include "component/controller/GraphController.h"
#include "component/controller/LogController.h"
#include "component/controller/RefreshController.h"
#include "component/controller/SearchController.h"
#include "component/controller/StatusBarController.h"
#include "component/controller/UndoRedoController.h"
#include "component/view/CodeView.h"
#include "component/view/ErrorView.h"
#include "component/view/GraphView.h"
#include "component/view/LogView.h"
#include "component/view/RefreshView.h"
#include "component/view/SearchView.h"
#include "component/view/StatusBarView.h"
@@ -43,6 +47,22 @@ std::shared_ptr<Component> ComponentFactory::createCodeComponent(ViewLayout* vie
return std::make_shared<Component>(view, controller);
}
std::shared_ptr<Component> ComponentFactory::createErrorComponent(ViewLayout* viewLayout)
{
std::shared_ptr<ErrorView> view = m_viewFactory->createErrorView(viewLayout);
std::shared_ptr<ErrorController> controller = std::make_shared<ErrorController>(m_storageAccess);
return std::make_shared<Component>(view, controller);
}
std::shared_ptr<Component> ComponentFactory::createLogComponent(ViewLayout* viewLayout)
{
std::shared_ptr<LogView> view = m_viewFactory->createLogView(viewLayout);
std::shared_ptr<LogController> controller = std::make_shared<LogController>(m_storageAccess);
return std::make_shared<Component>(view, controller);
}
std::shared_ptr<Component> ComponentFactory::createFeatureComponent()
{
std::shared_ptr<Controller> controller = std::make_shared<FeatureController>(m_storageAccess);
+2
View File
@@ -19,8 +19,10 @@ public:
ViewFactory* getViewFactory() const;
std::shared_ptr<Component> createCodeComponent(ViewLayout* viewLayout);
std::shared_ptr<Component> createErrorComponent(ViewLayout* viewLayout);
std::shared_ptr<Component> createFeatureComponent();
std::shared_ptr<Component> createGraphComponent(ViewLayout* viewLayout);
std::shared_ptr<Component> createLogComponent(ViewLayout* viewLayout);
std::shared_ptr<Component> createRefreshComponent(ViewLayout* viewLayout);
std::shared_ptr<Component> createSearchComponent(ViewLayout* viewLayout);
std::shared_ptr<Component> createStatusBarComponent(ViewLayout* viewLayout);
+17
View File
@@ -7,8 +7,10 @@
#include "component/view/CompositeView.h"
#include "component/view/DialogView.h"
#include "component/view/GraphView.h"
#include "component/view/LogView.h"
#include "component/view/RefreshView.h"
#include "component/view/SearchView.h"
#include "component/view/TabbedView.h"
#include "component/view/UndoRedoView.h"
#include "component/view/ViewFactory.h"
@@ -53,6 +55,16 @@ void ComponentManager::setup(ViewLayout* viewLayout)
m_components.push_back(featureComponent);
m_dialogView = m_componentFactory->getViewFactory()->createDialogView(viewLayout);
std::shared_ptr<TabbedView> tabbedView =
m_componentFactory->getViewFactory()->createTabbedView(viewLayout, "Log");
m_tabbedViews.push_back(tabbedView);
std::shared_ptr<Component> errorComponent = m_componentFactory->createErrorComponent(tabbedView.get());
m_components.push_back(errorComponent);
//std::shared_ptr<Component> logComponent = m_componentFactory->createLogComponent(tabbedView.get());
//m_components.push_back(logComponent);
}
void ComponentManager::clearComponents()
@@ -84,6 +96,11 @@ void ComponentManager::refreshViews()
{
view->refreshView();
}
for (std::shared_ptr<TabbedView> view : m_tabbedViews)
{
view->refreshView();
}
}
DialogView* ComponentManager::getDialogView() const
+2
View File
@@ -11,6 +11,7 @@ class CompositeView;
class DialogView;
class NetworkFactory;
class StorageAccess;
class TabbedView;
class View;
class ViewFactory;
class ViewLayout;
@@ -36,6 +37,7 @@ private:
std::shared_ptr<ComponentFactory> m_componentFactory;
std::vector<std::shared_ptr<CompositeView>> m_compositeViews;
std::vector<std::shared_ptr<TabbedView>> m_tabbedViews;
std::vector<std::shared_ptr<Component>> m_components;
std::shared_ptr<DialogView> m_dialogView;
@@ -272,16 +272,24 @@ void CodeController::handleMessage(MessageShowErrors* message)
{
TRACE("code errors");
std::vector<ErrorInfo> errors;
m_collection = m_storageAccess->getErrorTokenLocations(&errors);
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
CodeView* view = getView();
view->clear();
view->setErrorInfos(errors);
view->showCodeSnippets(snippets, std::vector<Id>());
if (!view->showsErrors() || !message->errorId)
{
std::vector<ErrorInfo> errors;
m_collection = m_storageAccess->getErrorTokenLocations(&errors);
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
showContents(message);
view->clear();
view->setErrorInfos(errors);
view->showCodeSnippets(snippets, std::vector<Id>());
showContents(message);
}
if (message->errorId)
{
view->showActiveSnippet(std::vector<Id>(1, message->errorId), m_collection, true);
}
}
void CodeController::handleMessage(MessageSearchFullText* message)
@@ -0,0 +1,68 @@
#include "component/controller/ErrorController.h"
#include "data/access/StorageAccess.h"
ErrorController::ErrorController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
{
}
ErrorController::~ErrorController()
{
}
void ErrorController::handleMessage(MessageClearErrorCount* message)
{
clear();
}
void ErrorController::handleMessage(MessageFinishedParsing* message)
{
clear();
auto errors = m_storageAccess->getAllErrors();
for (const StorageError& error : errors)
{
getView()->addError(error);
}
}
void ErrorController::handleMessage(MessageNewErrors* message)
{
for (const StorageError& error : message->errors)
{
getView()->addError(error);
}
getView()->showDockWidget();
}
void ErrorController::handleMessage(MessageShowErrors* message)
{
if (message->errorId)
{
return;
}
clear();
auto errors = m_storageAccess->getAllErrors();
for (const StorageError& error : errors)
{
getView()->addError(error);
}
getView()->showDockWidget();
}
ErrorView* ErrorController::getView() const
{
return Controller::getView<ErrorView>();
}
void ErrorController::clear()
{
getView()->clear();
}
@@ -0,0 +1,39 @@
#ifndef ERROR_CONTROLLER_H
#define ERROR_CONTROLLER_H
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageClearErrorCount.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageNewErrors.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "component/controller/Controller.h"
#include "component/view/ErrorView.h"
class StorageAccess;
class ErrorController
: public Controller
, public MessageListener<MessageClearErrorCount>
, public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageNewErrors>
, public MessageListener<MessageShowErrors>
{
public:
ErrorController(StorageAccess* storageAccess);
~ErrorController();
private:
virtual void handleMessage(MessageClearErrorCount* message);
virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageNewErrors* message);
virtual void handleMessage(MessageShowErrors* message);
ErrorView* getView() const;
virtual void clear();
StorageAccess* m_storageAccess;
};
#endif // ERROR_CONTROLLER_H
@@ -137,7 +137,7 @@ void FeatureController::handleMessage(MessageSearch* message)
case SearchMatch::COMMAND_ERROR:
{
MessageShowErrors msg(m_storageAccess->getErrorCount());
MessageShowErrors msg(m_storageAccess->getFilteredErrorCount());
msg.setIsReplayed(message->isReplayed());
msg.dispatchImmediately();
return;
@@ -0,0 +1,22 @@
#include "component/controller/LogController.h"
#include "data/access/StorageAccess.h"
LogController::LogController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
{
}
LogController::~LogController()
{
}
LogView* LogController::getView() const
{
return Controller::getView<LogView>();
}
void LogController::clear()
{
getView()->clear();
}
@@ -0,0 +1,24 @@
#ifndef LOG_CONTROLLER_H
#define LOG_CONTROLLER_H
#include "component/controller/Controller.h"
#include "component/view/LogView.h"
class StorageAccess;
class LogController
: public Controller
{
public:
LogController(StorageAccess* storageAccess);
~LogController();
private:
LogView* getView() const;
virtual void clear();
StorageAccess* m_storageAccess;
};
#endif // LOG_CONTROLLER_H
@@ -31,17 +31,22 @@ void StatusBarController::handleMessage(MessageClearErrorCount* message)
void StatusBarController::handleMessage(MessageFinishedParsing* message)
{
ErrorCountInfo errorCount = m_storageAccess->getErrorCount();
ErrorCountInfo errorCount = m_storageAccess->getFilteredErrorCount();
getView()->setErrorCount(errorCount);
}
void StatusBarController::handleMessage(MessageRefresh* message)
{
getView()->setErrorCount(m_storageAccess->getErrorCount());
getView()->setErrorCount(m_storageAccess->getFilteredErrorCount());
}
void StatusBarController::handleMessage(MessageShowErrors* message)
{
if (message->errorId)
{
return;
}
getView()->setErrorCount(message->errorCount);
}
+1
View File
@@ -31,6 +31,7 @@ public:
virtual void clear() = 0;
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos) = 0;
virtual bool showsErrors() const = 0;
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds) = 0;
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert) = 0;
+2 -12
View File
@@ -1,5 +1,7 @@
#include "component/view/CompositeView.h"
#include <algorithm>
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name)
: View(viewLayout)
, m_direction(direction)
@@ -46,20 +48,8 @@ void CompositeView::removeView(View* view)
void CompositeView::showView(View* view)
{
getViewLayout()->showView(view);
}
void CompositeView::hideView(View* view)
{
getViewLayout()->hideView(view);
}
void CompositeView::loadLayout()
{
getViewLayout()->loadLayout();
}
void CompositeView::saveLayout()
{
getViewLayout()->saveLayout();
}
-3
View File
@@ -35,9 +35,6 @@ public:
virtual void showView(View* view);
virtual void hideView(View* view);
virtual void loadLayout();
virtual void saveLayout();
private:
std::vector<View*> m_views;
CompositeDirection m_direction;
+20
View File
@@ -0,0 +1,20 @@
#include "component/view/ErrorView.h"
ErrorView::ErrorView(ViewLayout* viewLayout)
: View(viewLayout)
{
}
ErrorView::~ErrorView()
{
}
std::string ErrorView::getName() const
{
return "Errors";
}
void ErrorView::showDockWidget()
{
getViewLayout()->showView(this);
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef ERROR_VIEW_H
#define ERROR_VIEW_H
#include "component/view/View.h"
#include "data/StorageTypes.h"
class ErrorView
: public View
{
public:
ErrorView(ViewLayout* viewLayout);
virtual ~ErrorView();
virtual std::string getName() const;
virtual void showDockWidget();
virtual void clear() = 0;
virtual void addError(const StorageError& error) = 0;
};
#endif // ERROR_VIEW_H
+3
View File
@@ -1,6 +1,9 @@
#ifndef GRAPH_VIEW_H
#define GRAPH_VIEW_H
#include <vector>
#include "utility/math/Vector2.h"
#include "utility/types.h"
#include "component/view/View.h"
+15
View File
@@ -0,0 +1,15 @@
#include "component/view/LogView.h"
LogView::LogView(ViewLayout* viewLayout)
: View(viewLayout)
{
}
LogView::~LogView()
{
}
std::string LogView::getName() const
{
return "Logs";
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef LOG_VIEW_H
#define LOG_VIEW_H
#include "component/view/View.h"
class LogView
: public View
{
public:
LogView(ViewLayout* viewLayout);
virtual ~LogView();
virtual std::string getName() const;
virtual void clear() = 0;
};
#endif // LOG_VIEW_H
+3
View File
@@ -13,6 +13,9 @@ public:
MainView();
virtual ~MainView();
virtual void loadLayout() = 0;
virtual void saveLayout() = 0;
virtual void hideStartScreen() = 0;
virtual void setTitle(const std::string& title) = 0;
virtual void activateWindow() = 0;
+51
View File
@@ -0,0 +1,51 @@
#include "component/view/TabbedView.h"
#include <algorithm>
TabbedView::TabbedView(ViewLayout* viewLayout, const std::string& name)
: View(viewLayout)
, m_name(name)
{
}
TabbedView::~TabbedView()
{
}
const std::vector<View*>& TabbedView::getViews() const
{
return m_views;
}
std::string TabbedView::getName() const
{
return m_name;
}
void TabbedView::addView(View* view)
{
m_views.push_back(view);
addViewWidget(view);
}
void TabbedView::removeView(View* view)
{
std::vector<View*>::iterator it = std::find(m_views.begin(), m_views.end(), view);
if (it == m_views.end())
{
return;
}
m_views.erase(it);
}
void TabbedView::showView(View* view)
{
getViewLayout()->showView(view);
}
void TabbedView::hideView(View* view)
{
getViewLayout()->hideView(view);
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef TABBED_VIEW_H
#define TABBED_VIEW_H
#include <vector>
#include "component/view/View.h"
#include "component/view/ViewLayout.h"
class TabbedView
: public View
, public ViewLayout
{
public:
TabbedView(ViewLayout* viewLayout, const std::string& name);
virtual ~TabbedView();
const std::vector<View*>& getViews() const;
virtual void addViewWidget(View* view) = 0;
// View implementation
virtual std::string getName() const;
// ViewLayout implementation
virtual void addView(View* view);
virtual void removeView(View* view);
virtual void showView(View* view);
virtual void hideView(View* view);
private:
std::vector<View*> m_views;
std::string m_name;
};
#endif // TABBED_VIEW_H
-1
View File
@@ -6,7 +6,6 @@
#include "component/Component.h"
#include "component/view/ViewLayout.h"
#include "utility/math/Vector2.h"
class ViewWidgetWrapper;
+6
View File
@@ -7,11 +7,14 @@
class CodeView;
class DialogView;
class ErrorView;
class GraphView;
class MainView;
class LogView;
class RefreshView;
class SearchView;
class StatusBarView;
class TabbedView;
class UndoRedoView;
class ViewLayout;
@@ -24,9 +27,12 @@ public:
virtual std::shared_ptr<MainView> createMainView() const = 0;
virtual std::shared_ptr<CompositeView> createCompositeView(
ViewLayout* viewLayout, CompositeView::CompositeDirection direction, const std::string& name) const = 0;
virtual std::shared_ptr<TabbedView> createTabbedView(ViewLayout* viewLayout, const std::string& name) const = 0;
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<ErrorView> createErrorView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<LogView> createLogView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const = 0;
-3
View File
@@ -14,9 +14,6 @@ public:
virtual void showView(View* view) = 0;
virtual void hideView(View* view) = 0;
virtual void loadLayout() = 0;
virtual void saveLayout() = 0;
};
#endif // VIEW_LAYOUT_H
+50
View File
@@ -0,0 +1,50 @@
#ifndef ERROR_FILTER_H
#define ERROR_FILTER_H
#include "data/ErrorInfo.h"
#include "data/StorageTypes.h"
struct ErrorFilter
{
ErrorFilter()
: error(true)
, fatal(true)
, unindexedError(false)
, unindexedFatal(true)
{
}
bool filter(const ErrorInfo& info) const
{
if (!error && !info.isFatal && info.isIndexed)
return false;
if (!fatal && info.isFatal && info.isIndexed)
return false;
if (!unindexedError && !info.isFatal && !info.isIndexed)
return false;
if (!unindexedFatal && info.isFatal && !info.isIndexed)
return false;
return true;
}
bool filter(const StorageError& storageError) const
{
if (!error && !storageError.fatal && storageError.indexed)
return false;
if (!fatal && storageError.fatal && storageError.indexed)
return false;
if (!unindexedError && !storageError.fatal && !storageError.indexed)
return false;
if (!unindexedFatal && storageError.fatal && !storageError.indexed)
return false;
return true;
}
bool error;
bool fatal;
bool unindexedError;
bool unindexedFatal;
};
#endif // ERROR_FILTER_H
+4 -1
View File
@@ -9,14 +9,16 @@ struct ErrorInfo
ErrorInfo()
: id(0)
, isFatal(false)
, isIndexed(false)
{
}
ErrorInfo(const std::string& message, const FilePath& filePath, Id id, bool isFatal)
ErrorInfo(const std::string& message, const FilePath& filePath, Id id, bool isFatal, bool isIndexed)
: message(message)
, filePath(filePath)
, id(id)
, isFatal(isFatal)
, isIndexed(isIndexed)
{
}
@@ -24,6 +26,7 @@ struct ErrorInfo
FilePath filePath;
Id id;
bool isFatal;
bool isIndexed;
};
#endif // ERROR_INFO_H
+1
View File
@@ -163,6 +163,7 @@ void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint
void IntermediateStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol)
{
m_errors.push_back(StorageError(
0,
message,
fatal,
indexed,
+51 -57
View File
@@ -6,6 +6,8 @@
#include "utility/Cache.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageClearErrorCount.h"
#include "utility/messaging/type/MessageNewErrors.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/text/TextAccess.h"
@@ -24,7 +26,6 @@
#include "data/location/TokenLocationLine.h"
#include "data/parser/ParseLocation.h"
#include "data/type/DataType.h"
#include "settings/ApplicationSettings.h"
PersistentStorage::PersistentStorage(const FilePath& dbPath)
: m_sqliteStorage(dbPath)
@@ -217,7 +218,7 @@ void PersistentStorage::forEachError(std::function<void(const StorageError& /*da
void PersistentStorage::startInjection()
{
m_preInjectionErrorCount = getErrorCount().total;
m_preInjectionErrorCount = m_sqliteStorage.getAllErrors().size();
m_sqliteStorage.beginTransaction();
}
@@ -226,12 +227,11 @@ void PersistentStorage::finishInjection()
{
m_sqliteStorage.commitTransaction();
ErrorCountInfo errorCount = getErrorCount();
if (m_preInjectionErrorCount != errorCount.total)
auto errors = m_sqliteStorage.getAllErrors();
if (m_preInjectionErrorCount != errors.size())
{
MessageShowErrors msg(errorCount);
msg.setSendAsTask(false);
msg.dispatchImmediately();
MessageNewErrors(std::vector<StorageError>(errors.begin() + m_preInjectionErrorCount, errors.end())).dispatchImmediately();
}
}
@@ -994,33 +994,6 @@ std::shared_ptr<TokenLocationFile> PersistentStorage::getTokenLocationsForLinesI
return getTokenLocationsForFile(filePath)->getFilteredByLines(firstLineNumber, lastLineNumber);
}
std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
TRACE();
std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>();
bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors();
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (size_t i = 0; i < storageErrors.size(); i++)
{
const StorageError& error = storageErrors[i];
if (error.fatal || error.indexed || showExternalNonFatalErrors)
{
// Set first bit to 1 to avoid collisions
Id locationId = ~(~size_t(0) >> 1) + i;
errorCollection->addTokenLocation(
locationId, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber
)->setType(LOCATION_ERROR);
errors->push_back(ErrorInfo(error.message, error.filePath, i, error.fatal));
}
}
return errorCollection;
}
std::shared_ptr<TokenLocationFile> PersistentStorage::getCommentLocationsInFile(const FilePath& filePath) const
{
TRACE();
@@ -1066,29 +1039,6 @@ std::vector<FileInfo> PersistentStorage::getFileInfosForFilePaths(const std::vec
return fileInfos;
}
ErrorCountInfo PersistentStorage::getErrorCount() const
{
bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors();
ErrorCountInfo info;
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (const StorageError& error : storageErrors)
{
if (error.fatal || error.indexed || showExternalNonFatalErrors)
{
info.total++;
}
if (error.fatal)
{
info.fatal++;
}
}
return info;
}
StorageStats PersistentStorage::getStorageStats() const
{
TRACE();
@@ -1104,6 +1054,50 @@ StorageStats PersistentStorage::getStorageStats() const
return stats;
}
ErrorCountInfo PersistentStorage::getErrorCount() const
{
LOG_ERROR("This should never be called.");
return ErrorCountInfo();
}
ErrorCountInfo PersistentStorage::getFilteredErrorCount() const
{
LOG_ERROR("This should never be called.");
return ErrorCountInfo();
}
std::vector<StorageError> PersistentStorage::getAllErrors() const
{
return m_sqliteStorage.getAllErrors();
}
std::vector<StorageError> PersistentStorage::getFilteredErrors() const
{
LOG_ERROR("This should never be called.");
return std::vector<StorageError>();
}
std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
TRACE();
std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>();
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (const StorageError& error : storageErrors)
{
// Set first bit to 1 to avoid collisions
Id locationId = ~(~size_t(0) >> 1) + error.id;
errorCollection->addTokenLocation(
locationId, error.id, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber
)->setType(LOCATION_ERROR);
errors->push_back(ErrorInfo(error.message, error.filePath, error.id, error.fatal, error.indexed));
}
return errorCollection;
}
Id PersistentStorage::getFileNodeId(const FilePath& filePath) const
{
if (filePath.empty())
+8 -2
View File
@@ -106,7 +106,6 @@ public:
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
) const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
virtual std::shared_ptr<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
@@ -114,9 +113,16 @@ public:
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const;
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const;
virtual ErrorCountInfo getErrorCount() const;
virtual StorageStats getStorageStats() const;
virtual ErrorCountInfo getErrorCount() const;
virtual ErrorCountInfo getFilteredErrorCount() const;
virtual std::vector<StorageError> getAllErrors() const;
virtual std::vector<StorageError> getFilteredErrors() const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
private:
Id getFileNodeId(const FilePath& filePath) const;
FilePath getFileNodePath(Id fileId) const;
+4 -2
View File
@@ -217,7 +217,7 @@ Id SqliteStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCo
Id SqliteStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
{
std::string sanitizedMessage = utility::replace((fatal ? "Fatal: " : "Error: ") + message, "'", "''");
std::string sanitizedMessage = utility::replace(message, "'", "''");
// check for duplicate
CppSQLite3Statement stmt = m_database.compileStatement((
@@ -1072,6 +1072,7 @@ std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string&
).c_str());
std::vector<StorageError> errors;
Id id = 1;
while (!q.eof())
{
const std::string message = q.getStringField(0, "");
@@ -1083,7 +1084,8 @@ std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string&
if (lineNumber != -1 && columnNumber != -1)
{
errors.push_back(StorageError(message, fatal, indexed, filePath, lineNumber, columnNumber));
errors.push_back(StorageError(id, message, fatal, indexed, filePath, lineNumber, columnNumber));
id++;
}
q.nextRow();
+6 -3
View File
@@ -169,7 +169,8 @@ struct StorageCommentLocation
struct StorageError
{
StorageError()
: message("")
: id(0)
, message("")
, fatal(0)
, indexed(0)
, filePath("")
@@ -177,8 +178,9 @@ struct StorageError
, columnNumber(-1)
{}
StorageError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
: message(message)
StorageError(Id id, const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
: id(id)
, message(message)
, fatal(fatal)
, indexed(indexed)
, filePath(filePath)
@@ -186,6 +188,7 @@ struct StorageError
, columnNumber(columnNumber)
{}
Id id;
std::string message;
bool fatal;
bool indexed;
+3 -1
View File
@@ -9,10 +9,12 @@
TaskFinishParsing::TaskFinishParsing(
PersistentStorage* storage,
StorageAccess* storageAccess,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
)
: m_storage(storage)
, m_storageAccess(storageAccess)
, m_fileRegister(fileRegister)
, m_dialogView(dialogView)
{
@@ -59,7 +61,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
m_fileRegister->getParsedSourceFilesCount(),
m_fileRegister->getSourceFilesCount(),
time,
m_storage->getErrorCount()
m_storageAccess->getFilteredErrorCount()
);
return STATE_SUCCESS;
+3
View File
@@ -9,6 +9,7 @@
class DialogView;
class FileRegister;
class PersistentStorage;
class StorageAccess;
class TaskFinishParsing
: public Task
@@ -16,6 +17,7 @@ class TaskFinishParsing
public:
TaskFinishParsing(
PersistentStorage* storage,
StorageAccess* storageAccess,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
);
@@ -29,6 +31,7 @@ private:
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
PersistentStorage* m_storage;
StorageAccess* m_storageAccess;
std::shared_ptr<FileRegister> m_fileRegister;
DialogView* m_dialogView;
};
+9 -2
View File
@@ -15,6 +15,7 @@
#include "data/ErrorCountInfo.h"
#include "data/ErrorInfo.h"
#include "data/StorageStats.h"
#include "data/StorageTypes.h"
class Graph;
class TextAccess;
@@ -59,7 +60,6 @@ public:
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForLinesInFile(
const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const = 0;
virtual std::shared_ptr<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const = 0;
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const = 0;
@@ -67,8 +67,15 @@ public:
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const = 0;
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const = 0;
virtual ErrorCountInfo getErrorCount() const = 0;
virtual StorageStats getStorageStats() const = 0;
virtual ErrorCountInfo getErrorCount() const = 0;
virtual ErrorCountInfo getFilteredErrorCount() const = 0;
virtual std::vector<StorageError> getAllErrors() const = 0;
virtual std::vector<StorageError> getFilteredErrors() const = 0;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const = 0;
};
#endif // STORAGE_ACCESS_H
+103 -20
View File
@@ -6,6 +6,7 @@
#include "utility/logging/logging.h"
#include "utility/file/FileInfo.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/TimePoint.h"
StorageAccessProxy::StorageAccessProxy()
@@ -218,16 +219,6 @@ std::shared_ptr<TokenLocationFile> StorageAccessProxy::getTokenLocationsForLines
return std::make_shared<TokenLocationFile>("");
}
std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
if (hasSubject())
{
return m_subject->getErrorTokenLocations(errors);
}
return std::make_shared<TokenLocationCollection>();
}
std::shared_ptr<TokenLocationFile> StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const
{
if (hasSubject())
@@ -268,16 +259,6 @@ std::vector<FileInfo> StorageAccessProxy::getFileInfosForFilePaths(const std::ve
return std::vector<FileInfo>();
}
ErrorCountInfo StorageAccessProxy::getErrorCount() const
{
if (hasSubject())
{
return m_subject->getErrorCount();
}
return ErrorCountInfo();
}
StorageStats StorageAccessProxy::getStorageStats() const
{
if (hasSubject())
@@ -287,3 +268,105 @@ StorageStats StorageAccessProxy::getStorageStats() const
return StorageStats();
}
ErrorCountInfo StorageAccessProxy::getErrorCount() const
{
ErrorCountInfo info;
std::vector<StorageError> storageErrors = getAllErrors();
for (const StorageError& error : storageErrors)
{
info.total++;
if (error.fatal)
{
info.fatal++;
}
}
return info;
}
ErrorCountInfo StorageAccessProxy::getFilteredErrorCount() const
{
ErrorCountInfo info;
std::vector<StorageError> storageErrors = getAllErrors();
for (const StorageError& error : storageErrors)
{
if (!m_errorFilter.filter(error))
{
continue;
}
info.total++;
if (error.fatal)
{
info.fatal++;
}
}
return info;
}
std::vector<StorageError> StorageAccessProxy::getAllErrors() const
{
if (hasSubject())
{
return m_subject->getAllErrors();
}
return std::vector<StorageError>();
}
std::vector<StorageError> StorageAccessProxy::getFilteredErrors() const
{
std::vector<StorageError> errors = getAllErrors();
std::vector<StorageError> filteredErrors;
for (const StorageError& error : errors)
{
if (m_errorFilter.filter(error))
{
filteredErrors.push_back(error);
}
}
return filteredErrors;
}
std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
if (hasSubject())
{
std::shared_ptr<TokenLocationCollection> collection = m_subject->getErrorTokenLocations(errors);
std::vector<ErrorInfo> unfilteredErrors = *errors;
errors->clear();
for (const ErrorInfo& error : unfilteredErrors)
{
if (m_errorFilter.filter(error))
{
errors->push_back(error);
}
else
{
// Set first bit to 1 to avoid collisions
Id locationId = ~(~size_t(0) >> 1) + error.id;
collection->removeTokenLocation(collection->findTokenLocationById(locationId));
}
}
return collection;
}
return std::make_shared<TokenLocationCollection>();
}
void StorageAccessProxy::handleMessage(MessageErrorFilterChanged* message)
{
m_errorFilter = message->errorFilter;
MessageShowErrors(getFilteredErrorCount()).dispatch();
}
+21 -3
View File
@@ -3,7 +3,15 @@
#include "data/access/StorageAccess.h"
class StorageAccessProxy: public StorageAccess
#include "data/ErrorFilter.h"
#include "data/StorageTypes.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageErrorFilterChanged.h"
class StorageAccessProxy
: public StorageAccess
, public MessageListener<MessageErrorFilterChanged>
{
public:
StorageAccessProxy();
@@ -47,7 +55,6 @@ public:
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
) const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
virtual std::shared_ptr<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
@@ -55,11 +62,22 @@ public:
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const;
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const;
virtual ErrorCountInfo getErrorCount() const;
virtual StorageStats getStorageStats() const;
virtual ErrorCountInfo getErrorCount() const;
virtual ErrorCountInfo getFilteredErrorCount() const;
virtual std::vector<StorageError> getAllErrors() const;
virtual std::vector<StorageError> getFilteredErrors() const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
private:
void handleMessage(MessageErrorFilterChanged* message);
StorageAccess* m_subject;
ErrorFilter m_errorFilter;
};
#endif // STORAGE_ACCESS_PROXY_H
@@ -89,7 +89,7 @@ TokenLocation* TokenLocationCollection::addTokenLocation(
void TokenLocationCollection::removeTokenLocation(TokenLocation* location)
{
if (!findTokenLocationById(location->getId()))
if (!location || !findTokenLocationById(location->getId()))
{
LOG_ERROR("TokenLocation is not part of this TokenLocationCollection.");
return;
+1 -1
View File
@@ -57,7 +57,7 @@ Id ParserClientImpl::recordSymbol(
Id ParserClientImpl::recordSymbol(
const NameHierarchy& symbolName, SymbolKind symbolType,
const ParseLocation& location, const ParseLocation& scopeLocation,
const ParseLocation& location, const ParseLocation& scopeLocation,
AccessKind access, bool isImplicit
)
{
-10
View File
@@ -175,16 +175,6 @@ void ApplicationSettings::setIndexerThreadCount(const int count)
setValue<int>("indexing/indexer_thread_count", count);
}
bool ApplicationSettings::getShowExternalNonFatalErrors() const
{
return getValue<bool>("indexing/show_external_non_fatal_errors", false);
}
void ApplicationSettings::setShowExternalNonFatalErrors(const bool show)
{
setValue<bool>("indexing/show_external_non_fatal_errors", show);
}
std::string ApplicationSettings::getJavaPath() const
{
return getValue<std::string>("indexing/java/java_path", "");
-3
View File
@@ -54,9 +54,6 @@ public:
int getIndexerThreadCount() const;
void setIndexerThreadCount(const int count);
bool getShowExternalNonFatalErrors() const;
void setShowExternalNonFatalErrors(const bool show);
std::string getJavaPath() const;
void setJavaPath(const std::string path);
+4 -4
View File
@@ -192,10 +192,10 @@ bool FilePath::contains(const FilePath& other) const
boost::filesystem::path dir = m_path;
const boost::filesystem::path& dir2 = other.m_path;
if (dir.filename() == ".")
{
dir.remove_filename();
}
if (dir.filename() == ".")
{
dir.remove_filename();
}
auto it = dir.begin();
auto it2 = dir2.begin();
@@ -0,0 +1,24 @@
#ifndef MESSAGE_ERROR_FILTER_CHANGED_H
#define MESSAGE_ERROR_FILTER_CHANGED_H
#include "utility/messaging/Message.h"
#include "data/ErrorFilter.h"
class MessageErrorFilterChanged
: public Message<MessageErrorFilterChanged>
{
public:
MessageErrorFilterChanged(const ErrorFilter& filter)
: errorFilter(filter)
{
}
static const std::string getStaticType()
{
return "MessageErrorFilterChanged";
}
const ErrorFilter errorFilter;
};
#endif // MESSAGE_ERROR_FILTER_CHANGED_H
@@ -0,0 +1,31 @@
#ifndef MESSAGE_NEW_ERRORS_H
#define MESSAGE_NEW_ERRORS_H
#include "utility/messaging/Message.h"
#include "data/StorageTypes.h"
class MessageNewErrors
: public Message<MessageNewErrors>
{
public:
MessageNewErrors(const std::vector<StorageError>& errors)
: errors(errors)
{
setSendAsTask(false);
}
static const std::string getStaticType()
{
return "MessageNewErrors";
}
virtual void print(std::ostream& os) const
{
os << errors.size() << " errors";
}
const std::vector<StorageError> errors;
};
#endif // MESSAGE_NEW_ERRORS_H
@@ -10,6 +10,12 @@ class MessageShowErrors
public:
MessageShowErrors(ErrorCountInfo errorCount)
: errorCount(errorCount)
, errorId(0)
{
}
MessageShowErrors(Id errorId)
: errorId(errorId)
{
}
@@ -19,6 +25,7 @@ public:
}
ErrorCountInfo errorCount;
Id errorId;
};
#endif // MESSAGE_SHOW_ERRORS_H