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
@@ -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++;
}