ui: Added show errors button to title bar of incomplete files (issue #246)
* Shows all errors within the file and all included files.
This commit is contained in:
@@ -446,6 +446,7 @@ add_files(
|
||||
utility/messaging/type/MessageSearchFullText.h
|
||||
utility/messaging/type/MessageShowErrorHelpMessage.h
|
||||
utility/messaging/type/MessageShowErrors.h
|
||||
utility/messaging/type/MessageShowErrorsForFile.h
|
||||
utility/messaging/type/MessageShowReference.h
|
||||
utility/messaging/type/MessageShowScope.h
|
||||
utility/messaging/type/MessageShowStatus.h
|
||||
|
||||
@@ -90,38 +90,6 @@ void ActivationController::handleMessage(MessageActivateNodes* message)
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void ActivationController::handleMessage(MessageSearch* message)
|
||||
{
|
||||
const std::vector<SearchMatch>& matches = message->getMatches();
|
||||
|
||||
if (matches.size() && matches.back().searchType == SearchMatch::SEARCH_COMMAND)
|
||||
{
|
||||
switch (matches.back().getCommandType())
|
||||
{
|
||||
case SearchMatch::COMMAND_ALL:
|
||||
case SearchMatch::COMMAND_NODE_FILTER:
|
||||
{
|
||||
MessageActivateAll(message->acceptedNodeTypes).dispatchImmediately();
|
||||
return;
|
||||
}
|
||||
|
||||
case SearchMatch::COMMAND_ERROR:
|
||||
{
|
||||
MessageShowErrors(m_storageAccess->getErrorCount()).dispatch();
|
||||
MessageFlushUpdates().dispatch();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds = message->getTokenIdsOfMatches();
|
||||
m.searchMatches = matches;
|
||||
m.tokenNames = m_storageAccess->getNameHierarchiesForNodeIds(m.tokenIds);
|
||||
m.isFromSearch = message->isFromSearch;
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void ActivationController::handleMessage(MessageActivateTokenIds* message)
|
||||
{
|
||||
MessageActivateTokens m(message);
|
||||
@@ -154,10 +122,47 @@ void ActivationController::handleMessage(MessageResetZoom* message)
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageStatus(L"Font size: " + std::to_wstring(fontSizeStd)).dispatch();
|
||||
}
|
||||
|
||||
void ActivationController::handleMessage(MessageSearch* message)
|
||||
{
|
||||
const std::vector<SearchMatch>& matches = message->getMatches();
|
||||
|
||||
if (matches.size() && matches.back().searchType == SearchMatch::SEARCH_COMMAND)
|
||||
{
|
||||
switch (matches.back().getCommandType())
|
||||
{
|
||||
case SearchMatch::COMMAND_ALL:
|
||||
case SearchMatch::COMMAND_NODE_FILTER:
|
||||
{
|
||||
MessageActivateAll(message->acceptedNodeTypes).dispatchImmediately();
|
||||
return;
|
||||
}
|
||||
|
||||
case SearchMatch::COMMAND_ERROR:
|
||||
{
|
||||
MessageShowErrors(m_storageAccess->getErrorCount()).dispatch();
|
||||
MessageFlushUpdates().dispatch();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds = message->getTokenIdsOfMatches();
|
||||
m.searchMatches = matches;
|
||||
m.tokenNames = m_storageAccess->getNameHierarchiesForNodeIds(m.tokenIds);
|
||||
m.isFromSearch = message->isFromSearch;
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void ActivationController::handleMessage(MessageShowErrorsForFile* message)
|
||||
{
|
||||
MessageShowErrors(m_storageAccess->getErrorsForFileLimited(message->filePath)).dispatch();
|
||||
}
|
||||
|
||||
void ActivationController::handleMessage(MessageZoom* message)
|
||||
{
|
||||
bool zoomIn = message->zoomIn;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "utility/messaging/type/MessageActivateSourceLocations.h"
|
||||
#include "utility/messaging/type/MessageResetZoom.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageShowErrorsForFile.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
|
||||
class StorageAccess;
|
||||
@@ -26,6 +27,7 @@ class ActivationController
|
||||
, public MessageListener<MessageActivateSourceLocations>
|
||||
, public MessageListener<MessageResetZoom>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageShowErrorsForFile>
|
||||
, public MessageListener<MessageZoom>
|
||||
{
|
||||
public:
|
||||
@@ -38,10 +40,11 @@ private:
|
||||
virtual void handleMessage(MessageActivateEdge* message);
|
||||
virtual void handleMessage(MessageActivateFile* message);
|
||||
virtual void handleMessage(MessageActivateNodes* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageActivateTokenIds* message);
|
||||
virtual void handleMessage(MessageActivateSourceLocations* message);
|
||||
virtual void handleMessage(MessageResetZoom* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageShowErrorsForFile* message);
|
||||
virtual void handleMessage(MessageZoom* message);
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
|
||||
@@ -307,8 +307,13 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
||||
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
|
||||
view->scrollTo(scrollParams);
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
m_collection = m_storageAccess->getErrorSourceLocationsLimited(&errors);
|
||||
std::vector<ErrorInfo> errors = message->errors;
|
||||
if (!errors.size())
|
||||
{
|
||||
errors = m_storageAccess->getErrorsLimited();
|
||||
}
|
||||
|
||||
m_collection = m_storageAccess->getErrorSourceLocations(errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
|
||||
std::sort(snippets.begin(), snippets.end(), CodeSnippetParams::sortById);
|
||||
|
||||
@@ -80,7 +80,12 @@ void ErrorController::handleMessage(MessageShowErrors* message)
|
||||
|
||||
clear();
|
||||
|
||||
std::vector<ErrorInfo> errors = m_storageAccess->getErrorsLimited();
|
||||
std::vector<ErrorInfo> errors = message->errors;
|
||||
if (!errors.size())
|
||||
{
|
||||
errors = m_storageAccess->getErrorsLimited();
|
||||
}
|
||||
|
||||
if (errors.size())
|
||||
{
|
||||
getView()->showDockWidget();
|
||||
|
||||
@@ -59,7 +59,7 @@ void StatusBarController::handleMessage(MessageRefresh* message)
|
||||
|
||||
void StatusBarController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (message->errorId || message->isReplayed())
|
||||
if (message->errorId || message->errors.size() || message->isReplayed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,8 @@ void UndoRedoController::handleMessage(MessageSearchFullText* message)
|
||||
void UndoRedoController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageShowErrors*>(lastMessage())->errorId == message->errorId)
|
||||
static_cast<MessageShowErrors*>(lastMessage())->errorId == message->errorId &&
|
||||
static_cast<MessageShowErrors*>(lastMessage())->errors.size() == message->errors.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ public:
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const = 0;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrorsForFileLimited(const FilePath& filePath) const = 0;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const = 0;
|
||||
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
|
||||
@@ -332,11 +332,22 @@ std::vector<ErrorInfo> StorageAccessProxy::getErrorsLimited() const
|
||||
return std::vector<ErrorInfo>();
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> StorageAccessProxy::getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrorsForFileLimited(const FilePath& filePath) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorSourceLocationsLimited(errors);
|
||||
return m_subject->getErrorsForFileLimited(filePath);
|
||||
}
|
||||
|
||||
return std::vector<ErrorInfo>();
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> StorageAccessProxy::getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorSourceLocations(errors);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationCollection>();
|
||||
|
||||
@@ -68,7 +68,9 @@ public:
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const override;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsForFileLimited(const FilePath& filePath) const override;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const override;
|
||||
|
||||
// TODO: remove these from access because it's not a getter!
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark) override;
|
||||
|
||||
@@ -1452,44 +1452,83 @@ std::vector<ErrorInfo> PersistentStorage::getErrorsLimited() const
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
errors.push_back(error);
|
||||
}
|
||||
|
||||
if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit)
|
||||
{
|
||||
break;
|
||||
if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> PersistentStorage::getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrorsForFileLimited(const FilePath& filePath) const
|
||||
{
|
||||
std::unordered_map<Id, std::set<Id>> includingMap = getFileIdToIncludedFileIdMap();
|
||||
|
||||
std::set<FilePath> filePaths;
|
||||
filePaths.insert(filePath);
|
||||
|
||||
std::set<Id> fileIdsToProcess = includingMap[getFileNodeId(filePath)];
|
||||
std::set<Id> processedFileIds;
|
||||
while (fileIdsToProcess.size())
|
||||
{
|
||||
std::set<Id> nextFileIdsToProcess;
|
||||
for (Id id : fileIdsToProcess)
|
||||
{
|
||||
if (filePaths.insert(getFileNodePath(id)).second)
|
||||
{
|
||||
utility::append(nextFileIdsToProcess, includingMap[id]);
|
||||
}
|
||||
}
|
||||
fileIdsToProcess = nextFileIdsToProcess;
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
|
||||
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
|
||||
{
|
||||
if (m_errorFilter.filter(error) && filePaths.find(FilePath(error.filePath)) != filePaths.end())
|
||||
{
|
||||
errors.push_back(error);
|
||||
|
||||
if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> PersistentStorage::getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> collection = std::make_shared<SourceLocationCollection>();
|
||||
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
|
||||
size_t count = 0;
|
||||
for (const ErrorInfo& error : errors)
|
||||
{
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
errors->push_back(error);
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id locationId = ~(~Id(0) >> 1) + error.id;
|
||||
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id locationId = ~(~Id(0) >> 1) + error.id;
|
||||
collection->addSourceLocation(
|
||||
LOCATION_ERROR,
|
||||
locationId,
|
||||
std::vector<Id>(1, error.id),
|
||||
FilePath(error.filePath),
|
||||
error.lineNumber,
|
||||
error.columnNumber,
|
||||
error.lineNumber,
|
||||
error.columnNumber
|
||||
);
|
||||
|
||||
collection->addSourceLocation(
|
||||
LOCATION_ERROR,
|
||||
locationId,
|
||||
std::vector<Id>(1, error.id),
|
||||
FilePath(error.filePath),
|
||||
error.lineNumber,
|
||||
error.columnNumber,
|
||||
error.lineNumber,
|
||||
error.columnNumber
|
||||
);
|
||||
}
|
||||
count++;
|
||||
|
||||
if (m_errorFilter.limit > 0 && errors->size() >= m_errorFilter.limit)
|
||||
if (m_errorFilter.limit > 0 && count >= m_errorFilter.limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2002,6 +2041,16 @@ std::unordered_map<Id, std::set<Id>> PersistentStorage::getFileIdToIncludingFile
|
||||
return fileIdToIncludingFileIdMap;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, std::set<Id>> PersistentStorage::getFileIdToIncludedFileIdMap() const
|
||||
{
|
||||
std::unordered_map<Id, std::set<Id>> fileIdToIncludingFileIdMap;
|
||||
for (const StorageEdge& includeEdge : m_sqliteIndexStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_INCLUDE)))
|
||||
{
|
||||
fileIdToIncludingFileIdMap[includeEdge.sourceNodeId].insert(includeEdge.targetNodeId);
|
||||
}
|
||||
return fileIdToIncludingFileIdMap;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, std::set<Id>> PersistentStorage::getFileIdToImportingFileIdMap() const
|
||||
{
|
||||
std::unordered_map<Id, std::set<Id>> fileIdToImportingFileIdMap;
|
||||
@@ -2589,13 +2638,13 @@ void PersistentStorage::buildFullTextSearchIndex() const
|
||||
TextCodec codec(ApplicationSettings::getInstance()->getTextEncoding());
|
||||
|
||||
m_fullTextSearchCodec = codec.getName();
|
||||
|
||||
|
||||
m_fullTextSearchIndex.clear();
|
||||
for (StorageFile& file : m_sqliteIndexStorage.getAll<StorageFile>())
|
||||
{
|
||||
|
||||
m_fullTextSearchIndex.addFile(
|
||||
file.id,
|
||||
file.id,
|
||||
codec.decode(m_sqliteIndexStorage.getFileContentById(file.id)->getText())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,9 @@ public:
|
||||
virtual ErrorCountInfo getErrorCount(const std::vector<ErrorInfo>& errors) const;
|
||||
virtual std::vector<ErrorInfo> getErrors() const;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const override;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsForFileLimited(const FilePath& filePath) const override;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const override;
|
||||
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark) override;
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark) override;
|
||||
@@ -153,6 +155,7 @@ private:
|
||||
bool getFileNodeComplete(Id fileId) const;
|
||||
|
||||
std::unordered_map<Id, std::set<Id>> getFileIdToIncludingFileIdMap() const;
|
||||
std::unordered_map<Id, std::set<Id>> getFileIdToIncludedFileIdMap() const;
|
||||
std::unordered_map<Id, std::set<Id>> getFileIdToImportingFileIdMap() const;
|
||||
std::set<Id> getReferenced(const std::set<Id>& filePaths, std::unordered_map<Id, std::set<Id>> idToReferencingIdMap) const;
|
||||
std::set<Id> getReferencing(const std::set<Id>& filePaths, std::unordered_map<Id, std::set<Id>> idToReferencingIdMap) const;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
|
||||
class MessageShowErrors
|
||||
: public Message<MessageShowErrors>
|
||||
@@ -15,6 +16,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
MessageShowErrors(const std::vector<ErrorInfo>& errors)
|
||||
: errors(errors)
|
||||
, errorId(0)
|
||||
{
|
||||
}
|
||||
|
||||
MessageShowErrors(Id errorId)
|
||||
: errorId(errorId)
|
||||
{
|
||||
@@ -25,8 +32,9 @@ public:
|
||||
return "MessageShowErrors";
|
||||
}
|
||||
|
||||
ErrorCountInfo errorCount;
|
||||
Id errorId;
|
||||
const ErrorCountInfo errorCount;
|
||||
const std::vector<ErrorInfo> errors;
|
||||
const Id errorId;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERRORS_H
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef MESSAGE_SHOW_ERRORS_FOR_FILE_H
|
||||
#define MESSAGE_SHOW_ERRORS_FOR_FILE_H
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageShowErrorsForFile
|
||||
: public Message<MessageShowErrorsForFile>
|
||||
{
|
||||
public:
|
||||
MessageShowErrorsForFile(const FilePath& filePath)
|
||||
: filePath(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowErrorsForFile";
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_ERRORS_FOR_FILE_H
|
||||
Reference in New Issue
Block a user