ui: Fixed expanding file with errors showed all locations as errors

This commit is contained in:
Eberhard Graether
2016-03-11 13:52:24 +01:00
parent a8aaf6950f
commit 8c9b9355d5
6 changed files with 31 additions and 9 deletions
@@ -248,13 +248,26 @@ void CodeController::handleMessage(MessageShowScope* message)
}
std::vector<CodeSnippetParams> snippets = getSnippetsForActiveTokenLocations(collection.get(), 0);
if (snippets.size() != 1)
{
LOG_ERROR("MessageShowScope didn't result in one single snippet to be created");
return;
}
if (message->showErrors)
{
std::vector<std::string> errorMessages;
std::vector<CodeSnippetParams> errorSnippets = getSnippetsForErrorLocations(&errorMessages);
for (const CodeSnippetParams& error : errorSnippets)
{
if (error.locationFile->getFilePath() == snippets[0].locationFile->getFilePath())
{
snippets[0].locationFile = error.locationFile;
}
}
}
getView()->addCodeSnippets(snippets, true);
showContents(message);
@@ -8,8 +8,9 @@ class MessageShowScope
: public Message<MessageShowScope>
{
public:
MessageShowScope(Id scopeLocationId)
MessageShowScope(Id scopeLocationId, bool showErrors)
: scopeLocationId(scopeLocationId)
, showErrors(showErrors)
{
}
@@ -24,6 +25,7 @@ public:
}
const Id scopeLocationId;
const bool showErrors;
};
#endif // MESSAGE_SHOW_SCOPE_H
+1 -1
View File
@@ -640,7 +640,7 @@ void QtCodeArea::annotateText()
const std::vector<Id>& activeIds = m_fileWidget->getActiveTokenIds();
const std::vector<Id>& focusIds = m_fileWidget->getFocusedTokenIds();
bool isError = m_fileWidget->getErrorMessages().size() > 0;
bool isError = m_fileWidget->hasErrors();
bool needsUpdate = false;
for (Annotation& annotation: m_annotations)
+9 -4
View File
@@ -139,6 +139,11 @@ const std::vector<std::string>& QtCodeFile::getErrorMessages() const
return m_parent->getErrorMessages();
}
bool QtCodeFile::hasErrors() const
{
return getErrorMessages().size() > 0;
}
void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
{
m_locationFile.reset();
@@ -376,7 +381,7 @@ void QtCodeFile::clickedMinimizeButton() const
m_filePath,
MessageChangeFileView::FILE_MINIMIZED,
false,
false,
hasErrors(),
nullptr
).dispatch();
}
@@ -387,7 +392,7 @@ void QtCodeFile::clickedSnippetButton() const
m_filePath,
MessageChangeFileView::FILE_SNIPPETS,
(m_locationFile != nullptr),
false,
hasErrors(),
m_locationFile
).dispatch();
}
@@ -398,7 +403,7 @@ void QtCodeFile::clickedMaximizeButton() const
m_filePath,
MessageChangeFileView::FILE_MAXIMIZED,
(m_fileSnippet == nullptr),
false,
hasErrors(),
nullptr
).dispatch();
}
@@ -416,7 +421,7 @@ void QtCodeFile::requestSnippets() const
m_filePath,
MessageChangeFileView::FILE_SNIPPETS,
(m_locationFile != nullptr),
false,
hasErrors(),
m_locationFile
);
msg.undoRedoType = MessageBase::UNDOTYPE_IGNORE;
+2
View File
@@ -40,7 +40,9 @@ public:
const std::vector<Id>& getActiveTokenIds() const;
const std::vector<Id>& getFocusedTokenIds() const;
const std::vector<std::string>& getErrorMessages() const;
bool hasErrors() const;
void addCodeSnippet(const CodeSnippetParams& params);
QtCodeSnippet* insertCodeSnippet(const CodeSnippetParams& params);
+2 -2
View File
@@ -170,7 +170,7 @@ void QtCodeSnippet::clickedTitle()
{
if (m_titleId > 0)
{
MessageShowScope(m_titleId).dispatch();
MessageShowScope(m_titleId, dynamic_cast<QtCodeFile*>(parent())->hasErrors()).dispatch();
}
else
{
@@ -182,7 +182,7 @@ void QtCodeSnippet::clickedFooter()
{
if (m_footerId > 0)
{
MessageShowScope(m_footerId).dispatch();
MessageShowScope(m_footerId, dynamic_cast<QtCodeFile*>(parent())->hasErrors()).dispatch();
}
}