data: Save command line info for CXX indexer commands to errors and show within errors table (issue #351)
bug id = 351
This commit is contained in:
@@ -143,7 +143,7 @@ void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
is->addError("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, 1, 1, true, true);
|
||||
"setup.", "", path, 1, 1, true, true);
|
||||
LOG_INFO_STREAM(<< "crashed translation unit: " << path.str());
|
||||
}
|
||||
m_storageProvider->insert(is);
|
||||
|
||||
@@ -108,6 +108,7 @@ struct SharedStorageError
|
||||
SharedStorageError(
|
||||
Id id,
|
||||
const std::string& message,
|
||||
const std::string& commandline,
|
||||
const std::string& filePath,
|
||||
uint lineNumber,
|
||||
uint columnNumber,
|
||||
@@ -117,6 +118,7 @@ struct SharedStorageError
|
||||
)
|
||||
: id(id)
|
||||
, message(message.c_str(), allocator)
|
||||
, commandline(commandline.c_str(), allocator)
|
||||
, filePath(filePath.c_str(), allocator)
|
||||
, lineNumber(lineNumber)
|
||||
, columnNumber(columnNumber)
|
||||
@@ -126,6 +128,7 @@ struct SharedStorageError
|
||||
|
||||
Id id;
|
||||
SharedMemory::String message;
|
||||
SharedMemory::String commandline;
|
||||
|
||||
SharedMemory::String filePath;
|
||||
uint lineNumber;
|
||||
@@ -138,14 +141,14 @@ struct SharedStorageError
|
||||
inline SharedStorageError toShared(const StorageError& error, SharedMemory::Allocator* allocator)
|
||||
{
|
||||
return SharedStorageError(
|
||||
error.id, error.message, error.filePath.str(),
|
||||
error.id, error.message, error.commandline, error.filePath.str(),
|
||||
error.lineNumber, error.columnNumber, error.fatal, error.indexed, allocator);
|
||||
}
|
||||
|
||||
inline StorageError fromShared(const SharedStorageError& error)
|
||||
{
|
||||
return StorageError(
|
||||
error.id, error.message.c_str(), FilePath(error.filePath.c_str()),
|
||||
error.id, error.message.c_str(), error.commandline.c_str(), FilePath(error.filePath.c_str()),
|
||||
error.lineNumber, error.columnNumber, error.fatal, error.indexed);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,10 @@ ParserClient::~ParserClient()
|
||||
{
|
||||
}
|
||||
|
||||
void ParserClient::onErrorParsed(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
void ParserClient::onErrorParsed(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline, bool fatal, bool indexed)
|
||||
{
|
||||
this->onError(location, message, fatal, indexed);
|
||||
this->onError(location, message, commandline, fatal, indexed);
|
||||
|
||||
if (fatal)
|
||||
{
|
||||
|
||||
@@ -46,12 +46,14 @@ public:
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location) = 0;
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0;
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) = 0;
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location) = 0;
|
||||
virtual void onFileParsed(const FileInfo& fileInfo) = 0;
|
||||
virtual void onCommentParsed(const ParseLocation& location) = 0;
|
||||
|
||||
void onErrorParsed(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
|
||||
void onErrorParsed(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed);
|
||||
|
||||
bool hasFatalErrors() const;
|
||||
|
||||
|
||||
@@ -67,11 +67,12 @@ void ParserClientImpl::recordReference(
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
void ParserClientImpl::onError(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline,bool fatal, bool indexed)
|
||||
{
|
||||
if (location.isValid())
|
||||
{
|
||||
addError(message, fatal, indexed, location);
|
||||
addError(message, commandline, fatal, indexed, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,12 +326,14 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location)
|
||||
);
|
||||
}
|
||||
|
||||
void ParserClientImpl::addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location)
|
||||
void ParserClientImpl::addError(
|
||||
const std::string& message, const std::string& commandline, bool fatal, bool indexed, const ParseLocation& location)
|
||||
{
|
||||
if (!m_storage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_storage->addError(message, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed);
|
||||
m_storage->addError(
|
||||
message, commandline, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location);
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed);
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location);
|
||||
virtual void onFileParsed(const FileInfo& fileInfo);
|
||||
virtual void onCommentParsed(const ParseLocation& location);
|
||||
@@ -55,7 +56,8 @@ private:
|
||||
void addSourceLocation(Id elementId, const ParseLocation& location, int type);
|
||||
void addComponentAccess(Id nodeId , int type);
|
||||
void addCommentLocation(const ParseLocation& location);
|
||||
void addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location);
|
||||
void addError(const std::string& message, const std::string& commandline, bool fatal, bool indexed,
|
||||
const ParseLocation& location);
|
||||
|
||||
std::shared_ptr<IntermediateStorage> m_storage;
|
||||
};
|
||||
|
||||
@@ -44,6 +44,7 @@ size_t IntermediateStorage::getByteSize() const
|
||||
byteSize += sizeof(StorageError);
|
||||
byteSize += storageError.filePath.str().size();
|
||||
byteSize += storageError.message.size();
|
||||
byteSize += storageError.commandline.size();
|
||||
}
|
||||
|
||||
for (const StorageNode& storageNode: getStorageNodes())
|
||||
@@ -244,11 +245,13 @@ void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint
|
||||
}
|
||||
|
||||
void IntermediateStorage::addError(
|
||||
const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
{
|
||||
const StorageError error(
|
||||
0,
|
||||
message,
|
||||
commandline,
|
||||
filePath,
|
||||
startLine,
|
||||
startCol,
|
||||
@@ -558,6 +561,3 @@ std::string IntermediateStorage::serialize(const StorageError& error) const
|
||||
std::to_string(error.columnNumber)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ public:
|
||||
virtual void addOccurrence(Id elementId, Id sourceLocationId);
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
virtual void addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const;
|
||||
|
||||
@@ -135,10 +135,12 @@ void PersistentStorage::addCommentLocation(Id fileNodeId, uint startLine, uint s
|
||||
}
|
||||
|
||||
void PersistentStorage::addError(
|
||||
const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
{
|
||||
m_sqliteIndexStorage.addError(
|
||||
message,
|
||||
commandline,
|
||||
filePath,
|
||||
startLine,
|
||||
startCol,
|
||||
|
||||
@@ -29,7 +29,8 @@ public:
|
||||
virtual void addOccurrence(Id elementId, Id sourceLocationId);
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
virtual void addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const;
|
||||
|
||||
@@ -190,6 +190,7 @@ void Storage::inject(Storage* injected)
|
||||
{
|
||||
addError(
|
||||
injectedData.message,
|
||||
injectedData.commandline,
|
||||
injectedData.filePath,
|
||||
injectedData.lineNumber,
|
||||
injectedData.columnNumber,
|
||||
|
||||
@@ -23,7 +23,8 @@ public:
|
||||
virtual void addOccurrence(Id elementId, Id sourceLocationId) = 0;
|
||||
virtual void addComponentAccess(Id nodeId , int type) = 0;
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0;
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed) = 0;
|
||||
virtual void addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed) = 0;
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const = 0;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const = 0;
|
||||
|
||||
@@ -211,6 +211,7 @@ struct StorageError
|
||||
StorageError(
|
||||
Id id,
|
||||
const std::string& message,
|
||||
const std::string& commandline,
|
||||
const FilePath& filePath,
|
||||
uint lineNumber,
|
||||
uint columnNumber,
|
||||
@@ -219,6 +220,7 @@ struct StorageError
|
||||
)
|
||||
: id(id)
|
||||
, message(message)
|
||||
, commandline(commandline)
|
||||
, filePath(filePath)
|
||||
, lineNumber(lineNumber)
|
||||
, columnNumber(columnNumber)
|
||||
@@ -228,6 +230,7 @@ struct StorageError
|
||||
|
||||
Id id;
|
||||
std::string message;
|
||||
std::string commandline;
|
||||
|
||||
FilePath filePath;
|
||||
uint lineNumber;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 12;
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 13;
|
||||
|
||||
SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath.canonical())
|
||||
@@ -247,7 +247,8 @@ Id SqliteIndexStorage::addCommentLocation(Id fileNodeId, uint startLine, uint st
|
||||
return id;
|
||||
}
|
||||
|
||||
Id SqliteIndexStorage::addError(const std::string& message, const FilePath& filePath, uint lineNumber, uint columnNumber, bool fatal, bool indexed)
|
||||
Id SqliteIndexStorage::addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint lineNumber, uint columnNumber, bool fatal, bool indexed)
|
||||
{
|
||||
const std::string sanitizedMessage = utility::replace(message, "'", "''");
|
||||
|
||||
@@ -270,12 +271,15 @@ Id SqliteIndexStorage::addError(const std::string& message, const FilePath& file
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
const std::string sanitizedCommandline = utility::replace(commandline, "'", "''");
|
||||
|
||||
m_insertErrorStmt.bind(1, sanitizedMessage.c_str());
|
||||
m_insertErrorStmt.bind(2, fatal);
|
||||
m_insertErrorStmt.bind(3, indexed);
|
||||
m_insertErrorStmt.bind(4, filePath.str().c_str());
|
||||
m_insertErrorStmt.bind(5, int(lineNumber));
|
||||
m_insertErrorStmt.bind(6, int(columnNumber));
|
||||
m_insertErrorStmt.bind(2, sanitizedCommandline.c_str());
|
||||
m_insertErrorStmt.bind(3, fatal);
|
||||
m_insertErrorStmt.bind(4, indexed);
|
||||
m_insertErrorStmt.bind(5, filePath.str().c_str());
|
||||
m_insertErrorStmt.bind(6, int(lineNumber));
|
||||
m_insertErrorStmt.bind(7, int(columnNumber));
|
||||
|
||||
const bool success = executeStatement(m_insertErrorStmt);
|
||||
if (success)
|
||||
@@ -952,6 +956,7 @@ void SqliteIndexStorage::setupTables()
|
||||
"CREATE TABLE IF NOT EXISTS error("
|
||||
"id INTEGER NOT NULL, "
|
||||
"message TEXT, "
|
||||
"commandline TEXT, "
|
||||
"fatal INTEGER NOT NULL, "
|
||||
"indexed INTEGER NOT NULL, "
|
||||
"file_path TEXT, "
|
||||
@@ -1039,7 +1044,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, commandline, fatal, indexed, file_path, line_number, column_number) VALUES(?, ?, ?, ?, ?, ?, ?);"
|
||||
);
|
||||
}
|
||||
catch (CppSQLite3Exception& e)
|
||||
@@ -1285,7 +1290,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, commandline, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";"
|
||||
);
|
||||
|
||||
std::vector<StorageError> errors;
|
||||
@@ -1293,15 +1298,17 @@ std::vector<StorageError> SqliteIndexStorage::doGetAll<StorageError>(const std::
|
||||
while (!q.eof())
|
||||
{
|
||||
const std::string message = q.getStringField(0, "");
|
||||
const bool fatal = q.getIntField(1, 0);
|
||||
const bool indexed = q.getIntField(2, 0);
|
||||
const std::string filePath = q.getStringField(3, "");
|
||||
const int lineNumber = q.getIntField(4, -1);
|
||||
const int columnNumber = q.getIntField(5, -1);
|
||||
const std::string commandline = q.getStringField(1, "");
|
||||
const bool fatal = q.getIntField(2, 0);
|
||||
const bool indexed = q.getIntField(3, 0);
|
||||
const std::string filePath = q.getStringField(4, "");
|
||||
const int lineNumber = q.getIntField(5, -1);
|
||||
const int columnNumber = q.getIntField(6, -1);
|
||||
|
||||
if (lineNumber != -1 && columnNumber != -1)
|
||||
{
|
||||
errors.push_back(StorageError(id, message, FilePath(filePath), lineNumber, columnNumber, fatal, indexed));
|
||||
errors.push_back(StorageError(
|
||||
id, message, commandline, FilePath(filePath), lineNumber, columnNumber, fatal, indexed));
|
||||
id++;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
bool addOccurrence(Id elementId, Id sourceLocationId);
|
||||
Id addComponentAccess(Id nodeId, int type);
|
||||
Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
Id addError(const std::string& message, const FilePath& filePath, uint lineNumber, uint columnNumber, bool fatal, bool indexed);
|
||||
Id addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint lineNumber, uint columnNumber, bool fatal, bool indexed);
|
||||
|
||||
void removeElement(Id id);
|
||||
void removeElements(const std::vector<Id>& ids);
|
||||
|
||||
@@ -31,8 +31,13 @@ void SqliteStorage::setup()
|
||||
|
||||
executeStatement("PRAGMA foreign_keys=ON;");
|
||||
setupMetaTable();
|
||||
setupTables();
|
||||
setupPrecompiledStatements();
|
||||
|
||||
if (isEmpty() || !isIncompatible())
|
||||
{
|
||||
setupTables();
|
||||
setupPrecompiledStatements();
|
||||
}
|
||||
|
||||
m_mode = STORAGE_MODE_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user