ui: store and display translation unit of recorded indexing errors

This commit is contained in:
mlangkabel
2018-07-02 13:00:41 +02:00
parent 6794b61fab
commit 7c09f3339b
17 changed files with 77 additions and 49 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
is->addError(StorageErrorData(
L"The translation unit threw an exception during indexing. Please check if the source file "
"conforms to the specified language standard and all necessary options are defined within your project "
"setup.", path.wstr(), 1, 1, true, true
"setup.", path.wstr(), 1, 1, path.wstr(), true, true
));
LOG_INFO(L"crashed translation unit: " + path.wstr());
}
@@ -123,6 +123,7 @@ struct SharedStorageErrorData
const std::string& filePath,
uint lineNumber,
uint columnNumber,
const std::string& sourceFilePath,
bool fatal,
bool indexed,
SharedMemory::Allocator* allocator
@@ -131,6 +132,7 @@ struct SharedStorageErrorData
, filePath(filePath.c_str(), allocator)
, lineNumber(lineNumber)
, columnNumber(columnNumber)
, translationUnit(sourceFilePath.c_str(), allocator)
, fatal(fatal)
, indexed(indexed)
{}
@@ -141,6 +143,7 @@ struct SharedStorageErrorData
uint lineNumber;
uint columnNumber;
SharedMemory::String translationUnit;
bool fatal;
bool indexed;
};
@@ -152,6 +155,7 @@ inline SharedStorageErrorData toShared(const StorageErrorData& error, SharedMemo
utility::encodeToUtf8(error.filePath),
error.lineNumber,
error.columnNumber,
utility::encodeToUtf8(error.translationUnit),
error.fatal,
error.indexed, allocator
);
@@ -164,6 +168,7 @@ inline StorageErrorData fromShared(const SharedStorageErrorData& error)
utility::decodeFromUtf8(error.filePath.c_str()),
error.lineNumber,
error.columnNumber,
utility::decodeFromUtf8(error.translationUnit.c_str()),
error.fatal,
error.indexed
);
+2 -6
View File
@@ -75,14 +75,10 @@ ParserClient::ParserClient()
{
}
ParserClient::~ParserClient()
{
}
void ParserClient::recordError(
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed)
const ParseLocation& errorLocation, const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit)
{
doRecordError(location, message, fatal, indexed);
doRecordError(errorLocation, message, fatal, indexed, translationUnit);
if (fatal)
{
+3 -3
View File
@@ -26,7 +26,7 @@ public:
const std::wstring& str, const ParseLocation& location, const ParseLocation& scopeLocation);
ParserClient();
virtual ~ParserClient();
virtual ~ParserClient() = default;
virtual Id recordSymbol(
const NameHierarchy& symbolName, SymbolKind symbolKind,
@@ -50,7 +50,7 @@ public:
const NameHierarchy& qualifierName, const ParseLocation& location) = 0;
void recordError(
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed);
const ParseLocation& errorLocation, const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit);
virtual void recordLocalSymbol(const std::wstring& name, const ParseLocation& location) = 0;
virtual void recordFile(const FileInfo& fileInfo, bool indexed) = 0;
@@ -60,7 +60,7 @@ public:
protected:
virtual void doRecordError(
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed) = 0;
const ParseLocation& errorLocation, const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit) = 0;
bool m_hasFatalErrors;
};
+4 -4
View File
@@ -91,11 +91,11 @@ void ParserClientImpl::recordComment(const ParseLocation& location)
}
void ParserClientImpl::doRecordError(
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed)
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed, const FilePath& translationUnit)
{
if (location.isValid())
{
addError(message, fatal, indexed, location);
addError(message, fatal, indexed, location, translationUnit);
}
}
@@ -331,7 +331,7 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location)
}
void ParserClientImpl::addError(
const std::wstring& message, bool fatal, bool indexed, const ParseLocation& location)
const std::wstring& message, bool fatal, bool indexed, const ParseLocation& location, const FilePath& translationUnit)
{
if (!m_storage)
{
@@ -339,6 +339,6 @@ void ParserClientImpl::addError(
}
m_storage->addError(StorageErrorData(
message, location.filePath.wstr(), location.startLineNumber, location.startColumnNumber, fatal, indexed
message, location.filePath.wstr(), location.startLineNumber, location.startColumnNumber, translationUnit.wstr(), fatal, indexed
));
}
+2 -2
View File
@@ -45,7 +45,7 @@ public:
private:
virtual void doRecordError(
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed) override;
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed, const FilePath& sourceFilePath) override;
NodeType symbolKindToNodeType(SymbolKind symbolType) const;
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
@@ -61,7 +61,7 @@ private:
void addComponentAccess(Id nodeId , int type);
void addCommentLocation(const ParseLocation& location);
void addError(const std::wstring& message, bool fatal, bool indexed,
const ParseLocation& location);
const ParseLocation& location, const FilePath& sourceFilePath);
std::shared_ptr<IntermediateStorage> m_storage;
};
@@ -9,7 +9,7 @@
#include "data/location/SourceLocationCollection.h"
#include "data/location/SourceLocationFile.h"
const size_t SqliteIndexStorage::s_storageVersion = 16;
const size_t SqliteIndexStorage::s_storageVersion = 17;
SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
: SqliteStorage(dbFilePath.getCanonical())
@@ -281,6 +281,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data)
m_insertErrorStmt.bind(4, utility::encodeToUtf8(data.filePath).c_str());
m_insertErrorStmt.bind(5, int(data.lineNumber));
m_insertErrorStmt.bind(6, int(data.columnNumber));
m_insertErrorStmt.bind(7, utility::encodeToUtf8(data.translationUnit).c_str());
const bool success = executeStatement(m_insertErrorStmt);
if (success)
@@ -1056,6 +1057,7 @@ void SqliteIndexStorage::setupTables()
"file_path TEXT, "
"line_number INTEGER, "
"column_number INTEGER, "
"translation_unit TEXT, "
"PRIMARY KEY(id));"
);
}
@@ -1136,7 +1138,7 @@ void SqliteIndexStorage::setupPrecompiledStatements()
"LIMIT 1;"
);
m_insertErrorStmt = m_database.compileStatement(
"INSERT INTO error(message, fatal, indexed, file_path, line_number, column_number) VALUES(?, ?, ?, ?, ?, ?);"
"INSERT INTO error(message, fatal, indexed, file_path, line_number, column_number, translation_unit) VALUES(?, ?, ?, ?, ?, ?, ?);"
);
}
catch (CppSQLite3Exception& e)
@@ -1383,7 +1385,7 @@ template <>
std::vector<StorageError> SqliteIndexStorage::doGetAll<StorageError>(const std::string& query) const
{
CppSQLite3Query q = executeQuery(
"SELECT message, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";"
"SELECT message, fatal, indexed, file_path, line_number, column_number, translation_unit FROM error " + query + ";"
);
std::vector<StorageError> errors;
@@ -1396,11 +1398,12 @@ std::vector<StorageError> SqliteIndexStorage::doGetAll<StorageError>(const std::
const std::string filePath = q.getStringField(3, "");
const int lineNumber = q.getIntField(4, -1);
const int columnNumber = q.getIntField(5, -1);
const std::string translationUnit = q.getStringField(6, "");
if (lineNumber != -1 && columnNumber != -1)
{
errors.push_back(StorageError(
id, utility::decodeFromUtf8(message), utility::decodeFromUtf8(filePath), lineNumber, columnNumber, fatal, indexed)
id, utility::decodeFromUtf8(message), utility::decodeFromUtf8(filePath), lineNumber, columnNumber, utility::decodeFromUtf8(translationUnit), fatal, indexed)
);
id++;
}
+6
View File
@@ -13,6 +13,7 @@ struct StorageErrorData
, filePath(L"")
, lineNumber(-1)
, columnNumber(-1)
, translationUnit(L"")
, fatal(0)
, indexed(0)
{}
@@ -22,6 +23,7 @@ struct StorageErrorData
const std::wstring& filePath,
uint lineNumber,
uint columnNumber,
const std::wstring& translationUnit,
bool fatal,
bool indexed
)
@@ -29,6 +31,7 @@ struct StorageErrorData
, filePath(filePath)
, lineNumber(lineNumber)
, columnNumber(columnNumber)
, translationUnit(translationUnit)
, fatal(fatal)
, indexed(indexed)
{}
@@ -39,6 +42,7 @@ struct StorageErrorData
uint lineNumber;
uint columnNumber;
std::wstring translationUnit;
bool fatal;
bool indexed;
};
@@ -61,6 +65,7 @@ struct StorageError: public StorageErrorData
const std::wstring& filePath,
uint lineNumber,
uint columnNumber,
const std::wstring& translationUnit,
bool fatal,
bool indexed
)
@@ -69,6 +74,7 @@ struct StorageError: public StorageErrorData
filePath,
lineNumber,
columnNumber,
translationUnit,
fatal,
indexed
)