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:
Eberhard Graether
2017-08-09 12:16:16 +02:00
parent 1ac63f0158
commit 2e375112e6
26 changed files with 149 additions and 77 deletions
+4 -4
View File
@@ -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)
);
}
+2 -1
View File
@@ -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;
+3 -1
View File
@@ -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,
+2 -1
View File
@@ -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;
+1
View File
@@ -190,6 +190,7 @@ void Storage::inject(Storage* injected)
{
addError(
injectedData.message,
injectedData.commandline,
injectedData.filePath,
injectedData.lineNumber,
injectedData.columnNumber,
+2 -1
View File
@@ -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;
+3
View File
@@ -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;
}