data: fixed issues with errors in incomplete files

* fixed intermediatestorage merges might lose file indexed/complete information
* fixed changing file complete to true only possible if the file has no errors
* fixed clicking show errors for a file where no asociated errors were found showed all errors
This commit is contained in:
Eberhard Graether
2018-06-18 20:31:52 +02:00
parent 009404dd37
commit c4901b6a7f
11 changed files with 91 additions and 28 deletions
@@ -1,4 +1,4 @@
#include "field.h"
#include "fied.h"
#include "io.h"
+1 -1
View File
@@ -2,7 +2,7 @@
#define _PLAYER_
#include "field.h"
#include "game_object.h"
#include "game_objec.h"
class Player : public GameObject {
public:
@@ -301,7 +301,12 @@ void CodeController::handleMessage(MessageShowErrors* message)
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
view->scrollTo(scrollParams);
std::vector<ErrorInfo> errors = m_storageAccess->getErrorsLimited(message->errorIds);
std::vector<ErrorInfo> errors;
if (!message->showsOnlyErrorIds || message->errorIds.size())
{
errors = m_storageAccess->getErrorsLimited(message->errorIds);
}
m_collection = m_storageAccess->getErrorSourceLocations(errors);
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
@@ -80,7 +80,12 @@ void ErrorController::handleMessage(MessageShowErrors* message)
clear();
std::vector<ErrorInfo> errors = m_storageAccess->getErrorsLimited(message->errorIds);
std::vector<ErrorInfo> errors;
if (!message->showsOnlyErrorIds || message->errorIds.size())
{
errors = m_storageAccess->getErrorsLimited(message->errorIds);
}
if (errors.size())
{
getView()->showDockWidget();
+18 -2
View File
@@ -126,10 +126,26 @@ void IntermediateStorage::addSymbol(const StorageSymbol& symbol)
void IntermediateStorage::addFile(const StorageFile& file)
{
const std::wstring serialized = serialize(file);
if (m_serializedFiles.find(serialized) == m_serializedFiles.end())
std::unordered_map<std::wstring, size_t>::const_iterator it = m_serializedFiles.find(serialized);
if (it == m_serializedFiles.end())
{
m_serializedFiles.emplace(serialized, m_files.size());
m_files.push_back(file);
m_serializedFiles.insert(serialized);
}
else
{
StorageFile& storedFile = m_files[it->second];
if (file.indexed)
{
storedFile.indexed = true;
}
if (file.complete)
{
storedFile.complete = true;
}
}
}
+1 -1
View File
@@ -96,7 +96,7 @@ private:
std::unordered_map<std::wstring, size_t> m_nodesIndex;
std::vector<StorageNode> m_nodes;
std::unordered_set<std::wstring> m_serializedFiles; // this is used to prevent duplicates (unique)
std::unordered_map<std::wstring, size_t> m_serializedFiles; // this is used to prevent duplicates (unique)
std::vector<StorageFile> m_files;
std::vector<StorageSymbol> m_symbols;
+40 -12
View File
@@ -92,7 +92,7 @@ void PersistentStorage::addFile(const StorageFile& data)
if (!storedFile.complete && data.complete)
{
m_sqliteIndexStorage.setFileComplete(storedFile.id, data.complete);
m_sqliteIndexStorage.setFileCompleteIfNoError(storedFile.id, storedFile.filePath, data.complete);
}
}
}
@@ -1604,36 +1604,64 @@ std::vector<ErrorInfo> PersistentStorage::getErrorsLimited(const std::vector<Id>
std::vector<Id> PersistentStorage::getErrorIdsForFile(const FilePath& filePath) const
{
std::unordered_map<Id, std::set<Id>> includingMap = getFileIdToIncludedFileIdMap();
Id fileId = getFileNodeId(filePath);
std::set<Id> fileIds = { fileId };
std::vector<Id> errorIds;
std::set<FilePath> filePaths;
filePaths.insert(filePath);
std::set<Id> fileIdsToProcess = includingMap[getFileNodeId(filePath)];
std::unordered_map<Id, std::set<Id>> includedMap = getFileIdToIncludedFileIdMap();
std::set<Id> fileIdsToProcess = includedMap[getFileNodeId(filePath)];
std::set<Id> processedFileIds;
while (fileIdsToProcess.size())
{
std::set<Id> nextFileIdsToProcess;
for (Id id : fileIdsToProcess)
{
if (filePaths.insert(getFileNodePath(id)).second)
if (fileIds.insert(id).second)
{
utility::append(nextFileIdsToProcess, includingMap[id]);
utility::append(nextFileIdsToProcess, includedMap[id]);
}
}
fileIdsToProcess = nextFileIdsToProcess;
}
std::vector<Id> errorIds;
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
std::vector<StorageError> errors = m_sqliteIndexStorage.getAll<StorageError>();
for (const StorageError& error : errors)
{
if (m_errorFilter.filter(error) && filePaths.find(FilePath(error.filePath)) != filePaths.end())
if (m_errorFilter.filter(error) && fileIds.find(getFileNodeId(FilePath(error.filePath))) != fileIds.end())
{
errorIds.push_back(error.id);
}
}
if (errorIds.empty())
{
std::unordered_map<Id, std::set<Id>> includingMap = getFileIdToIncludingFileIdMap();
fileIds.clear();
fileIdsToProcess = includingMap[fileId];
while (fileIdsToProcess.size())
{
std::set<Id> nextFileIdsToProcess;
for (Id id : fileIdsToProcess)
{
if (fileIds.insert(id).second)
{
utility::append(nextFileIdsToProcess, includingMap[id]);
}
}
fileIdsToProcess = nextFileIdsToProcess;
}
for (const ErrorInfo& error : errors)
{
if (error.fatal && m_errorFilter.filter(error) && fileIds.find(getFileNodeId(FilePath(error.filePath))) != fileIds.end())
{
errorIds.push_back(error.id);
}
}
}
return errorIds;
}
+7 -7
View File
@@ -29,6 +29,13 @@ void Storage::inject(Storage* injected)
TRACE();
startInjection();
injected->forEachError(
[&](const StorageErrorData& injectedData)
{
addError(injectedData);
}
);
std::unordered_map<Id, Id> injectedIdToOwnId;
injected->forEachNode(
@@ -189,13 +196,6 @@ void Storage::inject(Storage* injected)
}
);
injected->forEachError(
[&](const StorageErrorData& injectedData)
{
addError(injectedData);
}
);
finishInjection();
}
@@ -648,8 +648,14 @@ void SqliteIndexStorage::setFileIndexed(Id fileId, bool indexed)
);
}
void SqliteIndexStorage::setFileComplete(Id fileId, bool complete)
void SqliteIndexStorage::setFileCompleteIfNoError(Id fileId, const std::wstring& filePath, bool complete)
{
StorageError error = doGetFirst<StorageError>("WHERE file_path == '" + utility::encodeToUtf8(filePath) + "'");
if (error.id)
{
return;
}
executeStatement(
"UPDATE file SET complete = " + std::to_string(complete) + " WHERE id == " + std::to_string(fileId) + ";"
);
@@ -88,7 +88,7 @@ public:
std::shared_ptr<TextAccess> getFileContentById(Id fileId) const;
void setFileIndexed(Id fileId, bool indexed);
void setFileComplete(Id fileId, bool complete);
void setFileCompleteIfNoError(Id fileId, const std::wstring& filePath, bool complete);
void setNodeType(int type, Id nodeId);
std::shared_ptr<SourceLocationFile> getSourceLocationsForFile(
@@ -18,6 +18,7 @@ public:
MessageShowErrors(const std::vector<Id>& errorIds)
: errorIds(errorIds)
, errorId(0)
, showsOnlyErrorIds(true)
{
}
@@ -34,6 +35,8 @@ public:
const ErrorCountInfo errorCount;
const std::vector<Id> errorIds;
const Id errorId;
bool showsOnlyErrorIds = false;
};
#endif // MESSAGE_SHOW_ERRORS_H