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:
@@ -155,6 +155,7 @@ add_files(
|
|||||||
data/DefinitionType.cpp
|
data/DefinitionType.cpp
|
||||||
data/DefinitionType.h
|
data/DefinitionType.h
|
||||||
data/ErrorCountInfo.h
|
data/ErrorCountInfo.h
|
||||||
|
data/ErrorInfo.h
|
||||||
data/HierarchyCache.cpp
|
data/HierarchyCache.cpp
|
||||||
data/HierarchyCache.h
|
data/HierarchyCache.h
|
||||||
data/IntermediateStorage.cpp
|
data/IntermediateStorage.cpp
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ bool Project::load(const FilePath& projectSettingsFile)
|
|||||||
{
|
{
|
||||||
m_storage->startParsing();
|
m_storage->startParsing();
|
||||||
m_storage->finishParsing();
|
m_storage->finishParsing();
|
||||||
MessageFinishedParsing(0, 0, 0).dispatch();
|
MessageFinishedParsing(0, 0, 0, true).dispatch();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ const uint CodeController::s_lineRadius = 2;
|
|||||||
|
|
||||||
void CodeController::handleMessage(MessageActivateAll* message)
|
void CodeController::handleMessage(MessageActivateAll* message)
|
||||||
{
|
{
|
||||||
std::vector<std::string> errorMessages;
|
std::vector<ErrorInfo> errors;
|
||||||
std::vector<CodeSnippetParams> snippets = getSnippetsForErrorLocations(&errorMessages);
|
std::vector<CodeSnippetParams> snippets = getSnippetsForErrorLocations(&errors);
|
||||||
|
|
||||||
StorageStats stats = m_storageAccess->getStorageStats();
|
StorageStats stats = m_storageAccess->getStorageStats();
|
||||||
CodeSnippetParams statsSnippet;
|
CodeSnippetParams statsSnippet;
|
||||||
@@ -80,7 +80,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
|||||||
snippets.insert(snippets.begin(), statsSnippet);
|
snippets.insert(snippets.begin(), statsSnippet);
|
||||||
|
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
view->setErrorMessages(errorMessages);
|
view->setErrorInfos(errors);
|
||||||
view->showCodeSnippets(snippets, std::vector<Id>());
|
view->showCodeSnippets(snippets, std::vector<Id>());
|
||||||
|
|
||||||
showContents(message);
|
showContents(message);
|
||||||
@@ -95,7 +95,7 @@ void CodeController::handleMessage(MessageActivateLocalSymbols* message)
|
|||||||
void CodeController::handleMessage(MessageActivateTokens* message)
|
void CodeController::handleMessage(MessageActivateTokens* message)
|
||||||
{
|
{
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
view->setErrorMessages(std::vector<std::string>());
|
view->setErrorInfos(std::vector<ErrorInfo>());
|
||||||
|
|
||||||
std::vector<Id> activeTokenIds = message->tokenIds;
|
std::vector<Id> activeTokenIds = message->tokenIds;
|
||||||
Id declarationId = 0; // 0 means that no token is found.
|
Id declarationId = 0; // 0 means that no token is found.
|
||||||
@@ -162,7 +162,14 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
|||||||
case MessageChangeFileView::FILE_SNIPPETS:
|
case MessageChangeFileView::FILE_SNIPPETS:
|
||||||
if (message->needsData)
|
if (message->needsData)
|
||||||
{
|
{
|
||||||
view->addCodeSnippets(getSnippetsForActiveTokenLocationsInFile(message->locationFile), false);
|
if (message->showErrors)
|
||||||
|
{
|
||||||
|
view->addCodeSnippets(getSnippetsForFile(message->locationFile), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view->addCodeSnippets(getSnippetsForActiveTokenLocationsInFile(message->locationFile), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
view->setFileState(message->filePath, CodeView::FILE_SNIPPETS);
|
view->setFileState(message->filePath, CodeView::FILE_SNIPPETS);
|
||||||
break;
|
break;
|
||||||
@@ -181,8 +188,8 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
|||||||
|
|
||||||
if (message->showErrors)
|
if (message->showErrors)
|
||||||
{
|
{
|
||||||
std::vector<std::string> errorMessages;
|
std::vector<ErrorInfo> errors;
|
||||||
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(&errorMessages);
|
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(&errors);
|
||||||
params.locationFile = std::make_shared<TokenLocationFile>(*errorCollection.findTokenLocationFileByPath(message->filePath));
|
params.locationFile = std::make_shared<TokenLocationFile>(*errorCollection.findTokenLocationFileByPath(message->filePath));
|
||||||
params.locationFile->isWholeCopy = true;
|
params.locationFile->isWholeCopy = true;
|
||||||
}
|
}
|
||||||
@@ -225,11 +232,11 @@ void CodeController::handleMessage(MessageScrollCode* message)
|
|||||||
|
|
||||||
void CodeController::handleMessage(MessageShowErrors* message)
|
void CodeController::handleMessage(MessageShowErrors* message)
|
||||||
{
|
{
|
||||||
std::vector<std::string> errorMessages;
|
std::vector<ErrorInfo> errors;
|
||||||
std::vector<CodeSnippetParams> snippets = getSnippetsForErrorLocations(&errorMessages);
|
std::vector<CodeSnippetParams> snippets = getSnippetsForErrorLocations(&errors);
|
||||||
|
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
view->setErrorMessages(errorMessages);
|
view->setErrorInfos(errors);
|
||||||
view->showCodeSnippets(snippets, std::vector<Id>());
|
view->showCodeSnippets(snippets, std::vector<Id>());
|
||||||
|
|
||||||
showContents(message);
|
showContents(message);
|
||||||
@@ -256,8 +263,8 @@ void CodeController::handleMessage(MessageShowScope* message)
|
|||||||
|
|
||||||
if (message->showErrors)
|
if (message->showErrors)
|
||||||
{
|
{
|
||||||
std::vector<std::string> errorMessages;
|
std::vector<ErrorInfo> errors;
|
||||||
std::vector<CodeSnippetParams> errorSnippets = getSnippetsForErrorLocations(&errorMessages);
|
std::vector<CodeSnippetParams> errorSnippets = getSnippetsForErrorLocations(&errors);
|
||||||
|
|
||||||
for (const CodeSnippetParams& error : errorSnippets)
|
for (const CodeSnippetParams& error : errorSnippets)
|
||||||
{
|
{
|
||||||
@@ -556,17 +563,30 @@ std::shared_ptr<TokenLocationFile> CodeController::getTokenLocationOfParentScope
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CodeSnippetParams> CodeController::getSnippetsForErrorLocations(
|
std::vector<CodeSnippetParams> CodeController::getSnippetsForErrorLocations(
|
||||||
std::vector<std::string>* errorMessages) const
|
std::vector<ErrorInfo>* errors) const
|
||||||
{
|
{
|
||||||
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(errorMessages);
|
TokenLocationCollection errorCollection = m_storageAccess->getErrorTokenLocations(errors);
|
||||||
|
|
||||||
std::vector<CodeSnippetParams> snippets;
|
std::vector<CodeSnippetParams> snippets;
|
||||||
|
|
||||||
errorCollection.forEachTokenLocationFile(
|
errorCollection.forEachTokenLocationFile(
|
||||||
[&](std::shared_ptr<TokenLocationFile> file) -> void
|
[&](std::shared_ptr<TokenLocationFile> file) -> void
|
||||||
{
|
{
|
||||||
std::vector<CodeSnippetParams> fileSnippets = getSnippetsForFile(file);
|
if (snippets.size() < 10)
|
||||||
snippets.insert(snippets.end(), fileSnippets.begin(), fileSnippets.end());
|
{
|
||||||
|
std::vector<CodeSnippetParams> fileSnippets = getSnippetsForFile(file);
|
||||||
|
snippets.insert(snippets.end(), fileSnippets.begin(), fileSnippets.end());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CodeSnippetParams params;
|
||||||
|
params.locationFile = file;
|
||||||
|
params.refCount = file->getUnscopedStartTokenLocationCount();
|
||||||
|
params.modificationTime = m_storageAccess->getFileModificationTime(file->getFilePath());
|
||||||
|
|
||||||
|
params.isCollapsed = true;
|
||||||
|
snippets.push_back(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ private:
|
|||||||
TokenLocation* location, std::shared_ptr<TokenLocationFile> context, SnippetMerger& fileScopedMerger, std::map<int, std::shared_ptr<SnippetMerger>>& mergers) const;
|
TokenLocation* location, std::shared_ptr<TokenLocationFile> context, SnippetMerger& fileScopedMerger, std::map<int, std::shared_ptr<SnippetMerger>>& mergers) const;
|
||||||
std::shared_ptr<TokenLocationFile> getTokenLocationOfParentScope(const TokenLocation* location, std::shared_ptr<TokenLocationFile> context) const;
|
std::shared_ptr<TokenLocationFile> getTokenLocationOfParentScope(const TokenLocation* location, std::shared_ptr<TokenLocationFile> context) const;
|
||||||
|
|
||||||
std::vector<CodeSnippetParams> getSnippetsForErrorLocations(std::vector<std::string>* errorMessages) const;
|
std::vector<CodeSnippetParams> getSnippetsForErrorLocations(std::vector<ErrorInfo>* errors) const;
|
||||||
|
|
||||||
std::vector<std::string> getProjectDescription(TokenLocationFile* locationFile) const;
|
std::vector<std::string> getProjectDescription(TokenLocationFile* locationFile) const;
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
|||||||
getView()->setErrorCount(errorCount);
|
getView()->setErrorCount(errorCount);
|
||||||
|
|
||||||
std::string status = message->getStatusStr();
|
std::string status = message->getStatusStr();
|
||||||
status += " " + std::to_string(errorCount.total) + " error" + (errorCount.total != 1 ? "s" : "");
|
status += "; " + std::to_string(errorCount.total) + " error" + (errorCount.total != 1 ? "s" : "");
|
||||||
if (errorCount.fatal > 0)
|
if (errorCount.fatal > 0)
|
||||||
{
|
{
|
||||||
status += " (" + std::to_string(errorCount.fatal) + " fatal)";
|
status += " (" + std::to_string(errorCount.fatal) + " fatal)";
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageStatus(status, errorCount.total > 0).dispatch();
|
MessageStatus(status, false).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBarController::handleMessage(MessageShowErrors* message)
|
void StatusBarController::handleMessage(MessageShowErrors* message)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "data/ErrorInfo.h"
|
||||||
#include "utility/file/FilePath.h"
|
#include "utility/file/FilePath.h"
|
||||||
|
|
||||||
#include "component/view/helper/CodeSnippetParams.h"
|
#include "component/view/helper/CodeSnippetParams.h"
|
||||||
@@ -29,7 +30,7 @@ public:
|
|||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
|
||||||
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds) = 0;
|
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds) = 0;
|
||||||
virtual void setErrorMessages(const std::vector<std::string>& errorMessages) = 0;
|
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos) = 0;
|
||||||
|
|
||||||
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds) = 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;
|
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert) = 0;
|
||||||
|
|||||||
@@ -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);
|
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;
|
TokenLocationCollection errorCollection;
|
||||||
|
|
||||||
std::vector<StorageError> errors = m_sqliteStorage.getAllErrors();
|
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
|
||||||
for (size_t i = 0; i < errors.size(); i++)
|
for (size_t i = 0; i < storageErrors.size(); i++)
|
||||||
{
|
{
|
||||||
const StorageError& error = errors[i];
|
const StorageError& error = storageErrors[i];
|
||||||
errorCollection.addTokenLocation(
|
errorCollection.addTokenLocation(
|
||||||
i, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber);
|
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;
|
return errorCollection;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||||
) const;
|
) 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<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
|
||||||
|
|
||||||
virtual std::shared_ptr<TextAccess> getFileContent(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/graph/Node.h"
|
||||||
#include "data/search/SearchMatch.h"
|
#include "data/search/SearchMatch.h"
|
||||||
#include "data/ErrorCountInfo.h"
|
#include "data/ErrorCountInfo.h"
|
||||||
|
#include "data/ErrorInfo.h"
|
||||||
#include "data/StorageStats.h"
|
#include "data/StorageStats.h"
|
||||||
|
|
||||||
struct FileInfo;
|
struct FileInfo;
|
||||||
@@ -56,7 +57,7 @@ public:
|
|||||||
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForLinesInFile(
|
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForLinesInFile(
|
||||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0;
|
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<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<TextAccess> getFileContent(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>("");
|
return std::make_shared<TokenLocationFile>("");
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenLocationCollection StorageAccessProxy::getErrorTokenLocations(std::vector<std::string>* errorMessages) const
|
TokenLocationCollection StorageAccessProxy::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
|
||||||
{
|
{
|
||||||
if (hasSubject())
|
if (hasSubject())
|
||||||
{
|
{
|
||||||
return m_subject->getErrorTokenLocations(errorMessages);
|
return m_subject->getErrorTokenLocations(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TokenLocationCollection();
|
return TokenLocationCollection();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||||
) const;
|
) 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<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
|
||||||
|
|
||||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
|
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ class MessageFinishedParsing
|
|||||||
: public Message<MessageFinishedParsing>
|
: public Message<MessageFinishedParsing>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime)
|
MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime, bool loadedOnly = false)
|
||||||
: fileCount(fileCount)
|
: fileCount(fileCount)
|
||||||
, totalFileCount(totalFileCount)
|
, totalFileCount(totalFileCount)
|
||||||
, parseTime(parseTime)
|
, parseTime(parseTime)
|
||||||
|
, loadedOnly(loadedOnly)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +32,11 @@ public:
|
|||||||
|
|
||||||
std::string getStatusStr() const
|
std::string getStatusStr() const
|
||||||
{
|
{
|
||||||
|
if (loadedOnly)
|
||||||
|
{
|
||||||
|
return "Finished loading";
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Finished analysis: ";
|
ss << "Finished analysis: ";
|
||||||
ss << fileCount << "/" << totalFileCount << " files; ";
|
ss << fileCount << "/" << totalFileCount << " files; ";
|
||||||
@@ -41,6 +47,8 @@ public:
|
|||||||
int minutes = int(secondsLeft / 60);
|
int minutes = int(secondsLeft / 60);
|
||||||
secondsLeft -= minutes * 60;
|
secondsLeft -= minutes * 60;
|
||||||
int seconds = int(secondsLeft);
|
int seconds = int(secondsLeft);
|
||||||
|
secondsLeft -= seconds;
|
||||||
|
int milliSeconds = secondsLeft * 1000;
|
||||||
|
|
||||||
if (hours > 9)
|
if (hours > 9)
|
||||||
{
|
{
|
||||||
@@ -51,7 +59,12 @@ public:
|
|||||||
ss << std::setw(2) << std::setfill('0') << hours;
|
ss << std::setw(2) << std::setfill('0') << hours;
|
||||||
}
|
}
|
||||||
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
|
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
|
||||||
ss << ":" << std::setw(2) << std::setfill('0') << seconds << ". ";
|
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
|
||||||
|
|
||||||
|
if (!hours && !minutes)
|
||||||
|
{
|
||||||
|
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
@@ -64,6 +77,7 @@ public:
|
|||||||
size_t fileCount;
|
size_t fileCount;
|
||||||
size_t totalFileCount;
|
size_t totalFileCount;
|
||||||
float parseTime;
|
float parseTime;
|
||||||
|
bool loadedOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_FINISHED_PARSING_H
|
#endif // MESSAGE_FINISHED_PARSING_H
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
m_eventPosition = event->pos();
|
m_eventPosition = event->pos();
|
||||||
setIDECursorPosition();
|
setIDECursorPosition();
|
||||||
}
|
}
|
||||||
else if (!m_fileWidget->getErrorMessages().size())
|
else if (!m_fileWidget->hasErrors())
|
||||||
{
|
{
|
||||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||||
std::vector<const Annotation*> annotations = getNonScopeAnnotationsForPosition(cursor.position());
|
std::vector<const Annotation*> annotations = getNonScopeAnnotationsForPosition(cursor.position());
|
||||||
@@ -471,7 +471,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
|||||||
|
|
||||||
setHoveredAnnotations(annotations);
|
setHoveredAnnotations(annotations);
|
||||||
|
|
||||||
const std::vector<std::string>& errorMessages = m_fileWidget->getErrorMessages();
|
std::vector<std::string> errorMessages = m_fileWidget->getErrorMessages();
|
||||||
if (annotations.size() == 1 && errorMessages.size() > annotations[0]->tokenId)
|
if (annotations.size() == 1 && errorMessages.size() > annotations[0]->tokenId)
|
||||||
{
|
{
|
||||||
QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessages[annotations[0]->tokenId]));
|
QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessages[annotations[0]->tokenId]));
|
||||||
|
|||||||
@@ -139,14 +139,14 @@ const std::vector<Id>& QtCodeFile::getFocusedTokenIds() const
|
|||||||
return m_parent->getFocusedTokenIds();
|
return m_parent->getFocusedTokenIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string>& QtCodeFile::getErrorMessages() const
|
std::vector<std::string> QtCodeFile::getErrorMessages() const
|
||||||
{
|
{
|
||||||
return m_parent->getErrorMessages();
|
return m_parent->getErrorMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtCodeFile::hasErrors() const
|
bool QtCodeFile::hasErrors() const
|
||||||
{
|
{
|
||||||
return getErrorMessages().size() > 0;
|
return m_parent->hasErrors();;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
||||||
@@ -472,7 +472,19 @@ void QtCodeFile::updateRefCount(int refCount)
|
|||||||
{
|
{
|
||||||
if (refCount > 0)
|
if (refCount > 0)
|
||||||
{
|
{
|
||||||
m_referenceCount->setText(QString::fromStdString(std::to_string(refCount) + (refCount == 1 ? " reference" : " references")));
|
QString label = hasErrors() ? "error" : "reference";
|
||||||
|
if (refCount > 1)
|
||||||
|
{
|
||||||
|
label += "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t fatalErrorCount = m_parent->getFatalErrorCountForFile(m_filePath);
|
||||||
|
if (fatalErrorCount > 0)
|
||||||
|
{
|
||||||
|
label += " (" + QString::number(fatalErrorCount) + " fatal)";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_referenceCount->setText(QString::number(refCount) + " " + label);
|
||||||
m_referenceCount->show();
|
m_referenceCount->show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||||
#include "qt/utility/QtThreadedFunctor.h"
|
#include "qt/utility/QtThreadedFunctor.h"
|
||||||
|
|
||||||
|
#include "data/ErrorInfo.h"
|
||||||
#include "component/view/helper/CodeSnippetParams.h"
|
#include "component/view/helper/CodeSnippetParams.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
@@ -42,7 +43,7 @@ public:
|
|||||||
const std::vector<Id>& getActiveLocalSymbolIds() const;
|
const std::vector<Id>& getActiveLocalSymbolIds() const;
|
||||||
const std::vector<Id>& getFocusedTokenIds() const;
|
const std::vector<Id>& getFocusedTokenIds() const;
|
||||||
|
|
||||||
const std::vector<std::string>& getErrorMessages() const;
|
std::vector<std::string> getErrorMessages() const;
|
||||||
bool hasErrors() const;
|
bool hasErrors() const;
|
||||||
|
|
||||||
void addCodeSnippet(const CodeSnippetParams& params);
|
void addCodeSnippet(const CodeSnippetParams& params);
|
||||||
|
|||||||
@@ -108,14 +108,37 @@ void QtCodeFileList::setFocusedTokenIds(const std::vector<Id>& focusedTokenIds)
|
|||||||
m_focusedTokenIds = focusedTokenIds;
|
m_focusedTokenIds = focusedTokenIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string>& QtCodeFileList::getErrorMessages() const
|
std::vector<std::string> QtCodeFileList::getErrorMessages() const
|
||||||
{
|
{
|
||||||
return m_errorMessages;
|
std::vector<std::string> errorMessages;
|
||||||
|
for (const ErrorInfo& error : m_errorInfos)
|
||||||
|
{
|
||||||
|
errorMessages.push_back(error.message);
|
||||||
|
}
|
||||||
|
return errorMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileList::setErrorMessages(const std::vector<std::string>& errorMessages)
|
void QtCodeFileList::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
|
||||||
{
|
{
|
||||||
m_errorMessages = errorMessages;
|
m_errorInfos = errorInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtCodeFileList::hasErrors() const
|
||||||
|
{
|
||||||
|
return m_errorInfos.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t QtCodeFileList::getFatalErrorCountForFile(const FilePath& filePath) const
|
||||||
|
{
|
||||||
|
size_t fatalErrorCount = 0;
|
||||||
|
for (const ErrorInfo& error : m_errorInfos)
|
||||||
|
{
|
||||||
|
if (error.filePath == filePath && error.isFatal)
|
||||||
|
{
|
||||||
|
fatalErrorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fatalErrorCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileList::showActiveTokenIds()
|
void QtCodeFileList::showActiveTokenIds()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "utility/TimePoint.h"
|
#include "utility/TimePoint.h"
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
|
#include "data/ErrorInfo.h"
|
||||||
#include "component/view/helper/CodeSnippetParams.h"
|
#include "component/view/helper/CodeSnippetParams.h"
|
||||||
|
|
||||||
class QtCodeFile;
|
class QtCodeFile;
|
||||||
@@ -45,8 +46,11 @@ public:
|
|||||||
const std::vector<Id>& getFocusedTokenIds() const;
|
const std::vector<Id>& getFocusedTokenIds() const;
|
||||||
void setFocusedTokenIds(const std::vector<Id>& focusedTokenIds);
|
void setFocusedTokenIds(const std::vector<Id>& focusedTokenIds);
|
||||||
|
|
||||||
const std::vector<std::string>& getErrorMessages() const;
|
std::vector<std::string> getErrorMessages() const;
|
||||||
void setErrorMessages(const std::vector<std::string>& errorMessages);
|
void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
|
||||||
|
|
||||||
|
bool hasErrors() const;
|
||||||
|
size_t getFatalErrorCountForFile(const FilePath& filePath) const;
|
||||||
|
|
||||||
void showActiveTokenIds();
|
void showActiveTokenIds();
|
||||||
|
|
||||||
@@ -82,7 +86,7 @@ private:
|
|||||||
std::vector<Id> m_activeTokenIds;
|
std::vector<Id> m_activeTokenIds;
|
||||||
std::vector<Id> m_activeLocalSymbolIds;
|
std::vector<Id> m_activeLocalSymbolIds;
|
||||||
std::vector<Id> m_focusedTokenIds;
|
std::vector<Id> m_focusedTokenIds;
|
||||||
std::vector<std::string> m_errorMessages;
|
std::vector<ErrorInfo> m_errorInfos;
|
||||||
|
|
||||||
QtCodeFile* m_scrollToFile;
|
QtCodeFile* m_scrollToFile;
|
||||||
int m_value;
|
int m_value;
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
|
|||||||
if (errorCount.total > 0)
|
if (errorCount.total > 0)
|
||||||
{
|
{
|
||||||
m_errorButton.setText(
|
m_errorButton.setText(
|
||||||
QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") +
|
QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") +
|
||||||
(errorCount.fatal > 0 ? "(" + QString::number(errorCount.fatal) + " fatal)" : ""));
|
(errorCount.fatal > 0 ? " (" + QString::number(errorCount.fatal) + " fatal)" : ""));
|
||||||
m_errorButton.show();
|
m_errorButton.show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ void QtCodeView::setActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
|||||||
m_activeTokenIds = activeTokenIds;
|
m_activeTokenIds = activeTokenIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeView::setErrorMessages(const std::vector<std::string>& errorMessages)
|
void QtCodeView::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
|
||||||
{
|
{
|
||||||
m_errorMessages = errorMessages;
|
m_errorInfos = errorInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds)
|
void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds)
|
||||||
@@ -134,7 +134,7 @@ void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippe
|
|||||||
m_widget->clearCodeSnippets();
|
m_widget->clearCodeSnippets();
|
||||||
|
|
||||||
m_widget->setActiveTokenIds(activeTokenIds);
|
m_widget->setActiveTokenIds(activeTokenIds);
|
||||||
m_widget->setErrorMessages(m_errorMessages);
|
m_widget->setErrorInfos(m_errorInfos);
|
||||||
|
|
||||||
for (const CodeSnippetParams& params : snippets)
|
for (const CodeSnippetParams& params : snippets)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
||||||
virtual void setErrorMessages(const std::vector<std::string>& errorMessages);
|
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
|
||||||
|
|
||||||
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds);
|
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds);
|
||||||
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert);
|
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert);
|
||||||
@@ -88,7 +88,7 @@ private:
|
|||||||
QtCodeFileList* m_widget;
|
QtCodeFileList* m_widget;
|
||||||
|
|
||||||
std::vector<Id> m_activeTokenIds;
|
std::vector<Id> m_activeTokenIds;
|
||||||
std::vector<std::string> m_errorMessages;
|
std::vector<ErrorInfo> m_errorInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
# endif // QT_CODE_VIEW_H
|
# endif // QT_CODE_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user