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( ...@@ -49,6 +49,7 @@ ClangCodeModelConnectionClient::ClangCodeModelConnectionClient(
m_client(client) m_client(client)
{ {
m_processCreator.setTemporaryDirectoryPattern("clangbackend-XXXXXX"); m_processCreator.setTemporaryDirectoryPattern("clangbackend-XXXXXX");
m_processCreator.setArguments({connectionName()});
stdErrPrefixer().setPrefix("clangbackend.stderr: "); stdErrPrefixer().setPrefix("clangbackend.stderr: ");
stdOutPrefixer().setPrefix("clangbackend.stdout: "); stdOutPrefixer().setPrefix("clangbackend.stdout: ");
......
...@@ -41,7 +41,6 @@ namespace ClangBackEnd { ...@@ -41,7 +41,6 @@ namespace ClangBackEnd {
ConnectionClient::ConnectionClient(const QString &connectionName) ConnectionClient::ConnectionClient(const QString &connectionName)
: m_connectionName(connectionName) : m_connectionName(connectionName)
{ {
m_processCreator.setArguments({connectionName});
m_processCreator.setObserver(this); m_processCreator.setObserver(this);
listenForConnections(); listenForConnections();
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "pchmanagerconnectionclient.h" #include "pchmanagerconnectionclient.h"
#include <coreplugin/icore.h>
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
#include <QCoreApplication> #include <QCoreApplication>
...@@ -48,6 +50,8 @@ ClangPchManager::PchManagerConnectionClient::PchManagerConnectionClient( ...@@ -48,6 +50,8 @@ ClangPchManager::PchManagerConnectionClient::PchManagerConnectionClient(
m_serverProxy(client, ioDevice()) m_serverProxy(client, ioDevice())
{ {
m_processCreator.setTemporaryDirectoryPattern("clangpchmanagerbackend-XXXXXX"); m_processCreator.setTemporaryDirectoryPattern("clangpchmanagerbackend-XXXXXX");
m_processCreator.setArguments({connectionName(),
Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"});
stdErrPrefixer().setPrefix("PchManagerConnectionClient.stderr: "); stdErrPrefixer().setPrefix("PchManagerConnectionClient.stderr: ");
stdOutPrefixer().setPrefix("PchManagerConnectionClient.stdout: "); stdOutPrefixer().setPrefix("PchManagerConnectionClient.stdout: ");
......
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
using QuerySqliteReadStatementFactory = QuerySqliteStatementFactory<Sqlite::Database, using QuerySqliteReadStatementFactory = QuerySqliteStatementFactory<Sqlite::Database,
Sqlite::ReadStatement>; 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::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database}; ClangBackEnd::FilePathCaching filePathCache{database};
RefactoringClient refactoringClient; RefactoringClient refactoringClient;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "refactoringconnectionclient.h" #include "refactoringconnectionclient.h"
#include <coreplugin/icore.h>
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
#include <QCoreApplication> #include <QCoreApplication>
...@@ -47,6 +49,8 @@ RefactoringConnectionClient::RefactoringConnectionClient(RefactoringClientInterf ...@@ -47,6 +49,8 @@ RefactoringConnectionClient::RefactoringConnectionClient(RefactoringClientInterf
m_serverProxy(client, nullptr) m_serverProxy(client, nullptr)
{ {
m_processCreator.setTemporaryDirectoryPattern("clangrefactoringbackend-XXXXXX"); m_processCreator.setTemporaryDirectoryPattern("clangrefactoringbackend-XXXXXX");
m_processCreator.setArguments({connectionName(),
Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"});
stdErrPrefixer().setPrefix("RefactoringConnectionClient.stderr: "); stdErrPrefixer().setPrefix("RefactoringConnectionClient.stderr: ");
stdOutPrefixer().setPrefix("RefactoringConnectionClient.stdout: "); stdOutPrefixer().setPrefix("RefactoringConnectionClient.stdout: ");
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <refactoringdatabaseinitializer.h> #include <refactoringdatabaseinitializer.h>
#include <sqlitedatabase.h> #include <sqlitedatabase.h>
#include <coreplugin/icore.h>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QCoreApplication> #include <QCoreApplication>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
...@@ -76,20 +78,21 @@ private: ...@@ -76,20 +78,21 @@ private:
QTemporaryDir temporaryDirectory; QTemporaryDir temporaryDirectory;
}; };
QString processArguments(QCoreApplication &application) QStringList processArguments(QCoreApplication &application)
{ {
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("Qt Creator Clang PchManager Backend")); parser.setApplicationDescription(QStringLiteral("Qt Creator Clang PchManager Backend"));
parser.addHelpOption(); parser.addHelpOption();
parser.addVersionOption(); parser.addVersionOption();
parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection")); parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection"));
parser.addPositionalArgument(QStringLiteral("databasepath"), QStringLiteral("Database path"));
parser.process(application); parser.process(application);
if (parser.positionalArguments().isEmpty()) if (parser.positionalArguments().isEmpty())
parser.showHelp(1); parser.showHelp(1);
return parser.positionalArguments().first(); return parser.positionalArguments();
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
...@@ -103,9 +106,11 @@ int main(int argc, char *argv[]) ...@@ -103,9 +106,11 @@ int main(int argc, char *argv[])
QCoreApplication application(argc, 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::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database}; ClangBackEnd::FilePathCaching filePathCache{database};
ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache); ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache);
......
...@@ -42,7 +42,7 @@ using ClangBackEnd::RefactoringDatabaseInitializer; ...@@ -42,7 +42,7 @@ using ClangBackEnd::RefactoringDatabaseInitializer;
using ClangBackEnd::ConnectionServer; using ClangBackEnd::ConnectionServer;
using ClangBackEnd::SymbolIndexing; using ClangBackEnd::SymbolIndexing;
QString processArguments(QCoreApplication &application) QStringList processArguments(QCoreApplication &application)
{ {
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("Qt Creator Clang Refactoring Backend")); parser.setApplicationDescription(QStringLiteral("Qt Creator Clang Refactoring Backend"));
...@@ -55,7 +55,7 @@ QString processArguments(QCoreApplication &application) ...@@ -55,7 +55,7 @@ QString processArguments(QCoreApplication &application)
if (parser.positionalArguments().isEmpty()) if (parser.positionalArguments().isEmpty())
parser.showHelp(1); parser.showHelp(1);
return parser.positionalArguments().first(); return parser.positionalArguments();
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
...@@ -69,16 +69,18 @@ try { ...@@ -69,16 +69,18 @@ try {
QCoreApplication application(argc, argv); 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}; RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
FilePathCaching filePathCache{database}; FilePathCaching filePathCache{database};
SymbolIndexing symbolIndexing{database, filePathCache}; SymbolIndexing symbolIndexing{database, filePathCache};
RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache}; RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache};
ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer; ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer;
connectionServer.setServer(&clangCodeModelServer); connectionServer.setServer(&clangCodeModelServer);
connectionServer.start(connection); connectionServer.start(connectionName);
return application.exec(); 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