Commit 9ad760ef authored by Marco Bubke's avatar Marco Bubke

Clang: Store the database in user resources

We used temporary directories but this can be different paths.

Task-number: QTCREATORBUG-19372
Change-Id: Id6ac18e6eecdc5bb354bda3741e16cb87c552ba6
Reviewed-by: Ivan Donchevskii's avatarIvan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent c90e5b50
......@@ -49,6 +49,7 @@ ClangCodeModelConnectionClient::ClangCodeModelConnectionClient(
m_client(client)
{
m_processCreator.setTemporaryDirectoryPattern("clangbackend-XXXXXX");
m_processCreator.setArguments({connectionName()});
stdErrPrefixer().setPrefix("clangbackend.stderr: ");
stdOutPrefixer().setPrefix("clangbackend.stdout: ");
......
......@@ -41,7 +41,6 @@ namespace ClangBackEnd {
ConnectionClient::ConnectionClient(const QString &connectionName)
: m_connectionName(connectionName)
{
m_processCreator.setArguments({connectionName});
m_processCreator.setObserver(this);
listenForConnections();
......
......@@ -25,6 +25,8 @@
#include "pchmanagerconnectionclient.h"
#include <coreplugin/icore.h>
#include <utils/temporarydirectory.h>
#include <QCoreApplication>
......@@ -48,6 +50,8 @@ ClangPchManager::PchManagerConnectionClient::PchManagerConnectionClient(
m_serverProxy(client, ioDevice())
{
m_processCreator.setTemporaryDirectoryPattern("clangpchmanagerbackend-XXXXXX");
m_processCreator.setArguments({connectionName(),
Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"});
stdErrPrefixer().setPrefix("PchManagerConnectionClient.stderr: ");
stdOutPrefixer().setPrefix("PchManagerConnectionClient.stdout: ");
......
......@@ -70,7 +70,7 @@ public:
using QuerySqliteReadStatementFactory = QuerySqliteStatementFactory<Sqlite::Database,
Sqlite::ReadStatement>;
Sqlite::Database database{Utils::PathString{QDir::tempPath() + "/symbol.db"}};
Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
RefactoringClient refactoringClient;
......
......@@ -25,6 +25,8 @@
#include "refactoringconnectionclient.h"
#include <coreplugin/icore.h>
#include <utils/temporarydirectory.h>
#include <QCoreApplication>
......@@ -47,6 +49,8 @@ RefactoringConnectionClient::RefactoringConnectionClient(RefactoringClientInterf
m_serverProxy(client, nullptr)
{
m_processCreator.setTemporaryDirectoryPattern("clangrefactoringbackend-XXXXXX");
m_processCreator.setArguments({connectionName(),
Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"});
stdErrPrefixer().setPrefix("RefactoringConnectionClient.stderr: ");
stdOutPrefixer().setPrefix("RefactoringConnectionClient.stdout: ");
......
......@@ -35,6 +35,8 @@
#include <refactoringdatabaseinitializer.h>
#include <sqlitedatabase.h>
#include <coreplugin/icore.h>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QFileSystemWatcher>
......@@ -76,20 +78,21 @@ private:
QTemporaryDir temporaryDirectory;
};
QString processArguments(QCoreApplication &application)
QStringList processArguments(QCoreApplication &application)
{
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("Qt Creator Clang PchManager Backend"));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection"));
parser.addPositionalArgument(QStringLiteral("databasepath"), QStringLiteral("Database path"));
parser.process(application);
if (parser.positionalArguments().isEmpty())
parser.showHelp(1);
return parser.positionalArguments().first();
return parser.positionalArguments();
}
int main(int argc, char *argv[])
......@@ -103,9 +106,11 @@ int main(int argc, char *argv[])
QCoreApplication application(argc, argv);
const QString connectionName = processArguments(application);
const QStringList arguments = processArguments(application);
const QString connectionName = arguments[0];
const QString databasePath = arguments[1];
Sqlite::Database database{Utils::PathString{QDir::tempPath() + "/symbol.db"}};
Sqlite::Database database{Utils::PathString{databasePath}};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache);
......
......@@ -42,7 +42,7 @@ using ClangBackEnd::RefactoringDatabaseInitializer;
using ClangBackEnd::ConnectionServer;
using ClangBackEnd::SymbolIndexing;
QString processArguments(QCoreApplication &application)
QStringList processArguments(QCoreApplication &application)
{
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("Qt Creator Clang Refactoring Backend"));
......@@ -55,7 +55,7 @@ QString processArguments(QCoreApplication &application)
if (parser.positionalArguments().isEmpty())
parser.showHelp(1);
return parser.positionalArguments().first();
return parser.positionalArguments();
}
int main(int argc, char *argv[])
......@@ -69,16 +69,18 @@ try {
QCoreApplication application(argc, argv);
const QString connection = processArguments(application);
const QStringList arguments = processArguments(application);
const QString connectionName = arguments[0];
const QString databasePath = arguments[1];
Sqlite::Database database{Utils::PathString{QDir::tempPath() + "/symbol.db"}};
Sqlite::Database database{Utils::PathString{databasePath}};
RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
FilePathCaching filePathCache{database};
SymbolIndexing symbolIndexing{database, filePathCache};
RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache};
ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer;
connectionServer.setServer(&clangCodeModelServer);
connectionServer.start(connection);
connectionServer.start(connectionName);
return application.exec();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment