ui: Improved user experience of error display
* label errors as errors instead of references in file snippet headers * show number of fatal errors in file snippet headers as well * only show the first 10 error snippets open, remaining collapsed * don't show status message after parsing in red on errors * don't show stats of parsing when project was only loaded
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#ifndef ERROR_INFO_H
|
||||
#define ERROR_INFO_H
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
struct ErrorInfo
|
||||
{
|
||||
ErrorInfo()
|
||||
: id(0)
|
||||
, isFatal(false)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorInfo(const std::string& message, const FilePath& filePath, Id id, bool isFatal)
|
||||
: message(message)
|
||||
, filePath(filePath)
|
||||
, id(id)
|
||||
, isFatal(isFatal)
|
||||
{
|
||||
}
|
||||
|
||||
std::string message;
|
||||
FilePath filePath;
|
||||
Id id;
|
||||
bool isFatal;
|
||||
};
|
||||
|
||||
#endif // ERROR_INFO_H
|
||||
@@ -643,17 +643,17 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationsForLinesInFile(
|
||||
return m_sqliteStorage.getTokenLocationsForFile(filePath)->getFilteredByLines(firstLineNumber, lastLineNumber);
|
||||
}
|
||||
|
||||
TokenLocationCollection Storage::getErrorTokenLocations(std::vector<std::string>* errorMessages) const
|
||||
TokenLocationCollection Storage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
|
||||
{
|
||||
TokenLocationCollection errorCollection;
|
||||
|
||||
std::vector<StorageError> errors = m_sqliteStorage.getAllErrors();
|
||||
for (size_t i = 0; i < errors.size(); i++)
|
||||
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
|
||||
for (size_t i = 0; i < storageErrors.size(); i++)
|
||||
{
|
||||
const StorageError& error = errors[i];
|
||||
const StorageError& error = storageErrors[i];
|
||||
errorCollection.addTokenLocation(
|
||||
i, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber);
|
||||
errorMessages->push_back(error.message);
|
||||
errors->push_back(ErrorInfo(error.message, error.filePath, i, error.fatal));
|
||||
}
|
||||
|
||||
return errorCollection;
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const;
|
||||
|
||||
virtual TokenLocationCollection getErrorTokenLocations(std::vector<std::string>* errorMessages) const;
|
||||
virtual 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;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/search/SearchMatch.h"
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
#include "data/StorageStats.h"
|
||||
|
||||
struct FileInfo;
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForLinesInFile(
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0;
|
||||
|
||||
virtual TokenLocationCollection getErrorTokenLocations(std::vector<std::string>* errorMessages) const = 0;
|
||||
virtual 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;
|
||||
|
||||
@@ -225,11 +225,11 @@ std::shared_ptr<TokenLocationFile> StorageAccessProxy::getTokenLocationsForLines
|
||||
return std::make_shared<TokenLocationFile>("");
|
||||
}
|
||||
|
||||
TokenLocationCollection StorageAccessProxy::getErrorTokenLocations(std::vector<std::string>* errorMessages) const
|
||||
TokenLocationCollection StorageAccessProxy::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorTokenLocations(errorMessages);
|
||||
return m_subject->getErrorTokenLocations(errors);
|
||||
}
|
||||
|
||||
return TokenLocationCollection();
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const;
|
||||
|
||||
virtual TokenLocationCollection getErrorTokenLocations(std::vector<std::string>* errorMessages) const;
|
||||
virtual 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;
|
||||
|
||||
Reference in New Issue
Block a user