summaryrefslogtreecommitdiff
path: root/src/tools/clangrefactoringbackend/source/symbolstorage.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolstorage.h')
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolstorage.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolstorage.h b/src/tools/clangrefactoringbackend/source/symbolstorage.h
index adf2afdef9..5445a82f80 100644
--- a/src/tools/clangrefactoringbackend/source/symbolstorage.h
+++ b/src/tools/clangrefactoringbackend/source/symbolstorage.h
@@ -31,8 +31,9 @@
#include <sqlitetransaction.h>
#include <filepathcachingfwd.h>
-#include <QJsonDocument>
#include <QJsonArray>
+#include <QJsonDocument>
+#include <QJsonObject>
namespace ClangBackEnd {
@@ -67,25 +68,25 @@ public:
void insertOrUpdateProjectPart(Utils::SmallStringView projectPartName,
const Utils::SmallStringVector &commandLineArguments,
- const Utils::SmallStringVector &macroNames) override
+ const CompilerMacros &compilerMacros) override
{
m_statementFactory.database.setLastInsertedRowId(-1);
Utils::SmallString compilerArguementsAsJson = toJson(commandLineArguments);
- Utils::SmallString macroNamesAsJson = toJson(macroNames);
+ Utils::SmallString compilerMacrosAsJson = toJson(compilerMacros);
WriteStatement &insertStatement = m_statementFactory.insertProjectPartStatement;
- insertStatement.write(projectPartName, compilerArguementsAsJson, macroNamesAsJson);
+ insertStatement.write(projectPartName, compilerArguementsAsJson, compilerMacrosAsJson);
if (m_statementFactory.database.lastInsertedRowId() == -1) {
WriteStatement &updateStatement = m_statementFactory.updateProjectPartStatement;
- updateStatement.write(compilerArguementsAsJson, macroNamesAsJson, projectPartName);
+ updateStatement.write(compilerArguementsAsJson, compilerMacrosAsJson, projectPartName);
}
}
Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(FilePathId sourceId) const override
{
- ReadStatement &statement = m_statementFactory.getProjectPartCompilerArgumentsAndMacroNames;
+ ReadStatement &statement = m_statementFactory.getProjectPartCompilerArgumentsAndCompilerMacrosBySourceId;
return statement.template value<ProjectPartArtefact, 3>(sourceId.filePathId);
}
@@ -157,6 +158,19 @@ public:
return document.toJson(QJsonDocument::Compact);
}
+ static Utils::SmallString toJson(const CompilerMacros &compilerMacros)
+ {
+ QJsonDocument document;
+ QJsonObject object;
+
+ for (const CompilerMacro &macro : compilerMacros)
+ object.insert(QString(macro.key), QString(macro.value));
+
+ document.setObject(object);
+
+ return document.toJson(QJsonDocument::Compact);
+ }
+
void fillTemporarySymbolsTable(const SymbolEntries &symbolEntries)
{
WriteStatement &statement = m_statementFactory.insertSymbolsToNewSymbolsStatement;