ui: Fixed error locations and messages not matching
This commit is contained in:
@@ -477,10 +477,10 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
||||
|
||||
setHoveredAnnotations(annotations);
|
||||
|
||||
std::vector<std::string> errorMessages = m_navigator->getErrorMessages();
|
||||
if (annotations.size() == 1 && errorMessages.size() > annotations[0]->tokenId)
|
||||
if (annotations.size() == 1)
|
||||
{
|
||||
QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessages[annotations[0]->tokenId]));
|
||||
std::string errorMessage = m_navigator->getErrorMessageForId(annotations[0]->tokenId);
|
||||
QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,19 +198,26 @@ void QtCodeNavigator::setFocusedTokenIds(const std::vector<Id>& focusedTokenIds)
|
||||
m_focusedTokenIds = focusedTokenIds;
|
||||
}
|
||||
|
||||
std::vector<std::string> QtCodeNavigator::getErrorMessages() const
|
||||
std::string QtCodeNavigator::getErrorMessageForId(Id errorId) const
|
||||
{
|
||||
std::vector<std::string> errorMessages;
|
||||
for (const ErrorInfo& error : m_errorInfos)
|
||||
std::map<Id, ErrorInfo>::const_iterator it = m_errorInfos.find(errorId);
|
||||
|
||||
if (it != m_errorInfos.end())
|
||||
{
|
||||
errorMessages.push_back(error.message);
|
||||
return it->second.message;
|
||||
}
|
||||
return errorMessages;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void QtCodeNavigator::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
|
||||
{
|
||||
m_errorInfos = errorInfos;
|
||||
m_errorInfos.clear();
|
||||
|
||||
for (const ErrorInfo& info : errorInfos)
|
||||
{
|
||||
m_errorInfos.emplace(info.id, info);
|
||||
}
|
||||
}
|
||||
|
||||
bool QtCodeNavigator::hasErrors() const
|
||||
@@ -221,8 +228,9 @@ bool QtCodeNavigator::hasErrors() const
|
||||
size_t QtCodeNavigator::getFatalErrorCountForFile(const FilePath& filePath) const
|
||||
{
|
||||
size_t fatalErrorCount = 0;
|
||||
for (const ErrorInfo& error : m_errorInfos)
|
||||
for (const std::pair<Id, ErrorInfo>& p : m_errorInfos)
|
||||
{
|
||||
const ErrorInfo& error = p.second;
|
||||
if (error.filePath == filePath && error.isFatal)
|
||||
{
|
||||
fatalErrorCount++;
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
const std::vector<Id>& getFocusedTokenIds() const;
|
||||
void setFocusedTokenIds(const std::vector<Id>& focusedTokenIds);
|
||||
|
||||
std::vector<std::string> getErrorMessages() const;
|
||||
std::string getErrorMessageForId(Id errorId) const;
|
||||
void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
|
||||
|
||||
bool hasErrors() const;
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
std::vector<Id> m_activeTokenIds;
|
||||
std::vector<Id> m_activeLocalSymbolIds;
|
||||
std::vector<Id> m_focusedTokenIds;
|
||||
std::vector<ErrorInfo> m_errorInfos;
|
||||
std::map<Id, ErrorInfo> m_errorInfos;
|
||||
|
||||
int m_value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user