src: Project Refactoring
* Added language specific Project and ProjectSettings * moved project specific code from Application to Project * made Application a singleton * added handleDialog method to Application which displays a dialog window and waits for user input * Added ScopedFunctor that executes a function when deleted
This commit is contained in:
+9
-2
@@ -4,6 +4,7 @@
|
||||
#include "utility/logging/FileLogger.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
@@ -58,7 +59,10 @@ int main(int argc, char *argv[])
|
||||
setupApp(argc, argv);
|
||||
init();
|
||||
|
||||
std::shared_ptr<Application> app = Application::create(version);
|
||||
Application::createInstance(version, nullptr, nullptr);
|
||||
ScopedFunctor f([](){
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
std::shared_ptr<LicenseChecker> checker = LicenseChecker::getInstance();
|
||||
|
||||
@@ -92,7 +96,10 @@ int main(int argc, char *argv[])
|
||||
QtNetworkFactory networkFactory;
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
Application::createInstance(version, &viewFactory, &networkFactory);
|
||||
ScopedFunctor f([](){
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
commandLineParser.projectLoad();
|
||||
|
||||
|
||||
@@ -176,10 +176,11 @@ void CommandLineParser::processProjectfile(const std::string& file)
|
||||
|
||||
void CommandLineParser::projectLoad()
|
||||
{
|
||||
if (!m_projectFile.empty())
|
||||
FilePath path(m_projectFile); // todo: use filepath as datatype for m_projectFile
|
||||
if (path.exists() && path.extension() == ".coatiproject")
|
||||
{
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(m_projectFile, m_force)
|
||||
std::make_shared<MessageLoadProject>(path.str(), m_force)
|
||||
).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
+96
-168
@@ -23,55 +23,56 @@
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
std::shared_ptr<Application> Application::create(
|
||||
void Application::createInstance(
|
||||
const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory
|
||||
){
|
||||
Version::setApplicationVersion(version);
|
||||
loadSettings();
|
||||
|
||||
std::shared_ptr<Application> ptr(new Application());
|
||||
TaskScheduler::getInstance();
|
||||
MessageQueue::getInstance();
|
||||
|
||||
ptr->m_storageCache = std::make_shared<StorageCache>();
|
||||
bool hasGui = (viewFactory != nullptr);
|
||||
s_instance = std::shared_ptr<Application>(new Application(hasGui));
|
||||
|
||||
ptr->m_componentManager = ComponentManager::create(viewFactory, ptr->m_storageCache.get());
|
||||
s_instance->m_storageCache = std::make_shared<StorageCache>();
|
||||
|
||||
ptr->m_mainView = viewFactory->createMainView();
|
||||
ptr->m_mainView->setTitle("Coati");
|
||||
if (viewFactory != nullptr)
|
||||
{
|
||||
s_instance->m_componentManager = ComponentManager::create(viewFactory, s_instance->m_storageCache.get());
|
||||
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageShowStartScreen>()).dispatch();
|
||||
s_instance->m_mainView = viewFactory->createMainView();
|
||||
s_instance->m_mainView->setTitle("Coati");
|
||||
|
||||
ptr->m_componentManager->setup(ptr->m_mainView.get());
|
||||
ptr->m_mainView->loadLayout();
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageShowStartScreen>()).dispatch();
|
||||
|
||||
ptr->m_project = Project::create(ptr->m_storageCache.get());
|
||||
s_instance->m_componentManager->setup(s_instance->m_mainView.get());
|
||||
s_instance->m_mainView->loadLayout();
|
||||
}
|
||||
|
||||
ptr->m_ideCommunicationController = networkFactory->createIDECommunicationController(ptr->m_storageCache.get());
|
||||
if (networkFactory != nullptr)
|
||||
{
|
||||
s_instance->m_ideCommunicationController = networkFactory->createIDECommunicationController(s_instance->m_storageCache.get());
|
||||
}
|
||||
|
||||
ptr->startMessagingAndScheduling();
|
||||
|
||||
return ptr;
|
||||
s_instance->startMessagingAndScheduling();
|
||||
}
|
||||
|
||||
std::shared_ptr<Application> Application::create(const Version& version)
|
||||
std::shared_ptr<Application> Application::getInstance()
|
||||
{
|
||||
Version::setApplicationVersion(version);
|
||||
loadSettings();
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
std::shared_ptr<Application> ptr(new Application(false));
|
||||
|
||||
ptr->m_storageCache = std::make_shared<StorageCache>();
|
||||
ptr->m_project = Project::create(ptr->m_storageCache.get());
|
||||
|
||||
ptr->startMessagingAndScheduling();
|
||||
|
||||
return ptr;
|
||||
void Application::destroyInstance()
|
||||
{
|
||||
s_instance.reset();
|
||||
}
|
||||
|
||||
void Application::loadSettings()
|
||||
{
|
||||
ApplicationSettings::getInstance()->load(FilePath(UserPaths::getAppSettingsPath()));
|
||||
|
||||
loadStyle(ApplicationSettings::getInstance()->getColorSchemePath());
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load(FilePath(UserPaths::getAppSettingsPath()));
|
||||
loadStyle(settings->getColorSchemePath());
|
||||
}
|
||||
|
||||
void Application::loadStyle(const FilePath& colorSchemePath)
|
||||
@@ -80,6 +81,8 @@ void Application::loadStyle(const FilePath& colorSchemePath)
|
||||
GraphViewStyle::loadStyleSettings();
|
||||
}
|
||||
|
||||
std::shared_ptr<Application> Application::s_instance;
|
||||
|
||||
Application::Application(bool withGUI)
|
||||
: m_hasGUI(withGUI)
|
||||
{
|
||||
@@ -96,29 +99,55 @@ Application::~Application()
|
||||
}
|
||||
}
|
||||
|
||||
const std::shared_ptr<Project> Application::getCurrentProject()
|
||||
{
|
||||
return m_project;
|
||||
}
|
||||
|
||||
bool Application::hasGUI()
|
||||
{
|
||||
return m_hasGUI;
|
||||
}
|
||||
|
||||
int Application::handleDialog(const std::string& message)
|
||||
{
|
||||
return m_mainView->confirm(message);
|
||||
}
|
||||
|
||||
int Application::handleDialog(const std::string& message, const std::vector<std::string>& options)
|
||||
{
|
||||
return m_mainView->confirm(message, options);
|
||||
}
|
||||
|
||||
void Application::setTitle(const std::string& title)
|
||||
{
|
||||
m_mainView->setTitle(title);
|
||||
}
|
||||
|
||||
void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
{
|
||||
MessageStatus("Loading Project: " + projectSettingsFilePath.str(), false, true).dispatch();
|
||||
|
||||
loadSettings();
|
||||
updateRecentProjects(projectSettingsFilePath);
|
||||
|
||||
m_storageCache->clear();
|
||||
|
||||
m_project = Project::create(m_storageCache.get());
|
||||
loadProject(projectSettingsFilePath);
|
||||
|
||||
if (m_hasGUI)
|
||||
try
|
||||
{
|
||||
m_mainView->setTitle("Coati - " + projectSettingsFilePath.fileName());
|
||||
m_mainView->hideStartScreen();
|
||||
updateRecentProjects(projectSettingsFilePath);
|
||||
|
||||
m_componentManager->refreshViews();
|
||||
m_storageCache->clear();
|
||||
|
||||
m_project = Project::create(projectSettingsFilePath, m_storageCache.get());
|
||||
loadProject(projectSettingsFilePath);
|
||||
|
||||
if (m_hasGUI)
|
||||
{
|
||||
setTitle("Coati - " + projectSettingsFilePath.fileName());
|
||||
m_mainView->hideStartScreen();
|
||||
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to load project.");
|
||||
MessageStatus("Failed to load project.", true).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,82 +157,25 @@ void Application::loadProject(const FilePath& projectSettingsFilePath)
|
||||
{
|
||||
m_componentManager->clearComponents();
|
||||
}
|
||||
|
||||
bool reparse = false;
|
||||
|
||||
Project::ProjectState state = m_project->load(projectSettingsFilePath);
|
||||
if (state == Project::PROJECT_OUTDATED)
|
||||
{
|
||||
if (m_hasGUI && !isTrial())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_mainView->confirm(
|
||||
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
|
||||
"reflect the current project state. Do you want to reindex the project?", options);
|
||||
|
||||
reparse = (result == 0);
|
||||
}
|
||||
}
|
||||
else if (state == Project::PROJECT_OUTVERSIONED)
|
||||
{
|
||||
MessageStatus("Can't load project").dispatch();
|
||||
|
||||
reparse = true;
|
||||
|
||||
if (m_hasGUI)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_mainView->confirm(
|
||||
"This project was indexed with a different version of Coati. It needs to be fully reindexed to be used "
|
||||
"with this version of Coati. Do you want to reindex the project?", options);
|
||||
|
||||
reparse = (result == 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (reparse)
|
||||
{
|
||||
m_project->clearStorage();
|
||||
m_project->load(projectSettingsFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::refreshProject()
|
||||
void Application::refreshProject(bool force)
|
||||
{
|
||||
MessageStatus("Refreshing Project").dispatch();
|
||||
|
||||
FilePath cdbPath = ProjectSettings::getInstance()->getCompilationDatabasePath();
|
||||
if (!cdbPath.empty() && !cdbPath.exists())
|
||||
{
|
||||
MessageStatus("Can't refresh project").dispatch();
|
||||
|
||||
if (m_hasGUI)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
m_mainView->confirm(
|
||||
"Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.str(),
|
||||
options);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_storageCache->clear();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
|
||||
Project::ProjectState state = m_project->reload();
|
||||
if (state != Project::PROJECT_LOADED)
|
||||
if (force)
|
||||
{
|
||||
MessageStatus("Can't refresh project").dispatch();
|
||||
loadProject(m_project->getProjectSettingsFilePath());
|
||||
m_project->forceRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_project->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,83 +200,41 @@ void Application::handleMessage(MessageLoadProject* message)
|
||||
{
|
||||
TRACE("app load project");
|
||||
|
||||
loadSettings();
|
||||
|
||||
FilePath projectSettingsFilePath(message->projectSettingsFilePath);
|
||||
if (projectSettingsFilePath.empty())
|
||||
{
|
||||
projectSettingsFilePath = m_project->getProjectSettingsFilePath();
|
||||
if (projectSettingsFilePath.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message->forceRefresh && !isTrial())
|
||||
{
|
||||
if (m_hasGUI)
|
||||
{
|
||||
FilePath path = projectSettingsFilePath;
|
||||
FilePath oldPath = m_project->getProjectSettingsFilePath();
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_mainView->confirm(
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?", options);
|
||||
|
||||
if (oldPath.exists() && oldPath != path)
|
||||
if (result == 1)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_mainView->confirm(
|
||||
"You changed the project location. The project file (.coatiproject) and the database file (.coatidb) will "
|
||||
"be moved to the new location. Do you want to keep a copy of the files in the previous location?"
|
||||
, options);
|
||||
|
||||
FilePath dbPath = FilePath(path).replaceExtension("coatidb");
|
||||
FilePath olddbPath = FilePath(oldPath).replaceExtension("coatidb");
|
||||
|
||||
m_project = Project::create(m_storageCache.get());
|
||||
|
||||
if (result == 0)
|
||||
if (!m_project || projectSettingsFilePath != m_project->getProjectSettingsFilePath())
|
||||
{
|
||||
FileSystem::copyFile(olddbPath, dbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileSystem::remove(oldPath);
|
||||
FileSystem::rename(olddbPath, dbPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = m_mainView->confirm(
|
||||
"Some settings were changed, the project needs to be fully reindexed. "
|
||||
"Do you want to reindex the project?", options);
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
m_project->load(projectSettingsFilePath);
|
||||
updateRecentProjects(projectSettingsFilePath);
|
||||
m_mainView->setTitle("Coati - " + projectSettingsFilePath.fileName());
|
||||
createAndLoadProject(projectSettingsFilePath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_project->clearStorage();
|
||||
refreshProject(true);
|
||||
}
|
||||
else if (projectSettingsFilePath == m_project->getProjectSettingsFilePath())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
else if (!m_project || projectSettingsFilePath != m_project->getProjectSettingsFilePath())
|
||||
{
|
||||
createAndLoadProject(projectSettingsFilePath);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to load project.");
|
||||
MessageStatus("Failed to load project.", true).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageRefresh* message)
|
||||
@@ -318,16 +248,14 @@ void Application::handleMessage(MessageRefresh* message)
|
||||
|
||||
if (message->uiOnly)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
else if (message->all)
|
||||
{
|
||||
m_project->clearStorage();
|
||||
refreshProject();
|
||||
if (m_hasGUI)
|
||||
{
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshProject();
|
||||
refreshProject(message->all);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-4
@@ -27,19 +27,30 @@ class Application
|
||||
, public MessageListener<MessageSwitchColorScheme>
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Application> create(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory);
|
||||
static std::shared_ptr<Application> create(const Version& version);
|
||||
static void createInstance(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory);
|
||||
static std::shared_ptr<Application> getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
static void loadSettings();
|
||||
static void loadStyle(const FilePath& colorSchemePath);
|
||||
|
||||
~Application();
|
||||
|
||||
const std::shared_ptr<Project> getCurrentProject();
|
||||
|
||||
void createAndLoadProject(const FilePath& projectSettingsFilePath);
|
||||
void loadProject(const FilePath& projectSettingsFilePath);
|
||||
void refreshProject();
|
||||
void refreshProject(bool force);
|
||||
bool hasGUI();
|
||||
|
||||
int handleDialog(const std::string& message);
|
||||
int handleDialog(const std::string& message, const std::vector<std::string>& options);
|
||||
|
||||
void setTitle(const std::string& title);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Application> s_instance;
|
||||
|
||||
Application(bool withGUI=true);
|
||||
|
||||
virtual void handleMessage(MessageActivateWindow* message);
|
||||
@@ -52,7 +63,7 @@ private:
|
||||
|
||||
void updateRecentProjects(const FilePath& projectSettingsFilePath);
|
||||
|
||||
bool m_hasGUI;
|
||||
const bool m_hasGUI;
|
||||
std::shared_ptr<Project> m_project;
|
||||
std::shared_ptr<StorageCache> m_storageCache;
|
||||
|
||||
|
||||
@@ -195,6 +195,12 @@ add_files(
|
||||
settings/ApplicationSettings.h
|
||||
settings/ColorScheme.cpp
|
||||
settings/ColorScheme.h
|
||||
settings/CxxProjectSettings.cpp
|
||||
settings/CxxProjectSettings.h
|
||||
settings/JavaProjectSettings.cpp
|
||||
settings/JavaProjectSettings.h
|
||||
settings/LanguageType.cpp
|
||||
settings/LanguageType.h
|
||||
settings/ProjectSettings.cpp
|
||||
settings/ProjectSettings.h
|
||||
settings/Settings.cpp
|
||||
@@ -329,6 +335,8 @@ add_files(
|
||||
utility/Property.h
|
||||
utility/ResourcePaths.cpp
|
||||
utility/ResourcePaths.h
|
||||
utility/ScopedFunctor.cpp
|
||||
utility/ScopedFunctor.h
|
||||
utility/ScopedSwitcher.h
|
||||
utility/TimePoint.cpp
|
||||
utility/TimePoint.h
|
||||
@@ -346,7 +354,11 @@ add_files(
|
||||
|
||||
Application.cpp
|
||||
Application.h
|
||||
CxxProject.cpp
|
||||
CxxProject.h
|
||||
isTrial.h
|
||||
JavaProject.cpp
|
||||
JavaProject.h
|
||||
LicenseChecker.cpp
|
||||
LicenseChecker.h
|
||||
Project.cpp
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
#include "CxxProject.h"
|
||||
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
|
||||
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
|
||||
|
||||
|
||||
CxxProject::~CxxProject()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> CxxProject::getProjectSettings()
|
||||
{
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
const std::shared_ptr<ProjectSettings> CxxProject::getProjectSettings() const
|
||||
{
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
CxxProject::CxxProject(std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy)
|
||||
: Project(storageAccessProxy)
|
||||
, m_projectSettings(projectSettings)
|
||||
{
|
||||
}
|
||||
|
||||
bool CxxProject::allowsRefresh()
|
||||
{
|
||||
FilePath cdbPath = m_projectSettings->getCompilationDatabasePath();
|
||||
if (!cdbPath.empty() && !cdbPath.exists())
|
||||
{
|
||||
MessageStatus("Can't refresh project").dispatch();
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
Application::getInstance()->handleDialog(
|
||||
"Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.str(),
|
||||
options
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> CxxProject::createIndexerTask(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister)
|
||||
{
|
||||
return std::make_shared<TaskParseCxx>(
|
||||
storage,
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
getParserArguments()
|
||||
);
|
||||
}
|
||||
|
||||
void CxxProject::updateFileManager(FileManager& fileManager)
|
||||
{
|
||||
std::vector<FilePath> sourcePaths = m_projectSettings->getAbsoluteSourcePaths();
|
||||
std::vector<FilePath> headerPaths = sourcePaths;
|
||||
|
||||
std::vector<std::string> sourceExtensions;
|
||||
|
||||
if (m_projectSettings->getCompilationDatabasePath().exists())
|
||||
{
|
||||
sourcePaths = TaskParseCxx::getSourceFilesFromCDB(m_projectSettings->getCompilationDatabasePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceExtensions = m_projectSettings->getSourceExtensions();
|
||||
}
|
||||
|
||||
std::vector<FilePath> excludePaths = m_projectSettings->getAbsoluteExcludePaths();
|
||||
|
||||
fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
|
||||
Parser::Arguments CxxProject::getParserArguments() const
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
Parser::Arguments args;
|
||||
|
||||
utility::append(args.compilerFlags, m_projectSettings->getCompilerFlags());
|
||||
|
||||
// MAYBE DO THIS IN PARSER! AND ONLY ADD THE PATH OF THE CURRENT FILE!!
|
||||
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
//utility::append(args.systemHeaderSearchPaths, m_fileManager.getSourcePaths());
|
||||
|
||||
utility::append(args.systemHeaderSearchPaths, m_projectSettings->getAbsoluteHeaderSearchPaths());
|
||||
|
||||
utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
|
||||
|
||||
// Add all subdirectories of the header search paths
|
||||
if (m_projectSettings->getUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
std::vector<FilePath> headerSearchSubPaths;
|
||||
for (FilePath p : m_projectSettings->getSourcePaths())
|
||||
{
|
||||
utility::append(headerSearchSubPaths, FileSystem::getSubDirectories(p));
|
||||
}
|
||||
|
||||
utility::append(args.systemHeaderSearchPaths, utility::unique(headerSearchSubPaths));
|
||||
}
|
||||
|
||||
utility::append(args.frameworkSearchPaths, m_projectSettings->getAbsoluteFrameworkSearchPaths());
|
||||
utility::append(args.frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
|
||||
|
||||
args.language = m_projectSettings->getLanguage();
|
||||
args.languageStandard = m_projectSettings->getStandard();
|
||||
args.compilationDatabasePath = m_projectSettings->getCompilationDatabasePath();
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef CXX_PROJECT_H
|
||||
#define CXX_PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "Project.h"
|
||||
|
||||
class CxxProject: public Project
|
||||
{
|
||||
public:
|
||||
virtual ~CxxProject();
|
||||
|
||||
protected:
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings();
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const;
|
||||
|
||||
private:
|
||||
CxxProject(std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy);
|
||||
CxxProject(const CxxProject&);
|
||||
|
||||
virtual bool allowsRefresh();
|
||||
|
||||
virtual std::shared_ptr<Task> createIndexerTask(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister);
|
||||
|
||||
virtual void updateFileManager(FileManager& fileManager);
|
||||
|
||||
Parser::Arguments getParserArguments() const;
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> m_projectSettings;
|
||||
|
||||
|
||||
friend Project;
|
||||
};
|
||||
|
||||
#endif // CXX_PROJECT_H
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "JavaProject.h"
|
||||
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
|
||||
JavaProject::~JavaProject()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> JavaProject::getProjectSettings()
|
||||
{
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
const std::shared_ptr<ProjectSettings> JavaProject::getProjectSettings() const
|
||||
{
|
||||
return m_projectSettings;
|
||||
}
|
||||
|
||||
JavaProject::JavaProject(std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy)
|
||||
: Project(storageAccessProxy)
|
||||
, m_projectSettings(projectSettings)
|
||||
{
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
JavaEnvironmentFactory::createInstance(
|
||||
"data/java/asm-5.0.3.jar;"
|
||||
"data/java/cglib-3.1.jar;"
|
||||
"data/java/easymock-3.3.1.jar;"
|
||||
"data/java/guava-18.0.jar;"
|
||||
"data/java/hamcrest-core-1.3.jar;"
|
||||
"data/java/java-indexer.jar;"
|
||||
"data/java/javaparser-core-2.4.1-SNAPSHOT.jar;"
|
||||
"data/java/javaslang-2.0.0-beta.jar;"
|
||||
"data/java/javassist-3.19.0-GA.jar;"
|
||||
"data/java/java-symbol-solver-core-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/java-symbol-solver-model-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/objenesis-2.1.jar;"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> JavaProject::createIndexerTask(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister)
|
||||
{
|
||||
Parser::Arguments arguments;
|
||||
|
||||
for (FilePath classpath: m_projectSettings->getAbsoluteClasspaths())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(classpath.str());
|
||||
}
|
||||
|
||||
for (FilePath sourcePath: m_projectSettings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (sourcePath.extension().empty())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(sourcePath.str());
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_shared<TaskParseJava>(
|
||||
storage,
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
void JavaProject::updateFileManager(FileManager& fileManager)
|
||||
{
|
||||
std::vector<FilePath> sourcePaths = m_projectSettings->getAbsoluteSourcePaths();
|
||||
std::vector<FilePath> headerPaths = sourcePaths;
|
||||
std::vector<std::string> sourceExtensions = m_projectSettings->getSourceExtensions();
|
||||
std::vector<FilePath> excludePaths = m_projectSettings->getAbsoluteExcludePaths();
|
||||
|
||||
fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef JAVA_PROJECT_H
|
||||
#define JAVA_PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "Project.h"
|
||||
|
||||
class JavaProject: public Project
|
||||
{
|
||||
public:
|
||||
virtual ~JavaProject();
|
||||
|
||||
protected:
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings();
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const;
|
||||
|
||||
private:
|
||||
JavaProject(std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy);
|
||||
JavaProject(const JavaProject&);
|
||||
|
||||
virtual std::shared_ptr<Task> createIndexerTask(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister);
|
||||
|
||||
virtual void updateFileManager(FileManager& fileManager);
|
||||
|
||||
std::shared_ptr<JavaProjectSettings> m_projectSettings;
|
||||
|
||||
friend Project;
|
||||
};
|
||||
|
||||
#endif // JAVA_PROJECT_H
|
||||
+158
-229
@@ -2,12 +2,11 @@
|
||||
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
#include "data/parser/cxx/TaskParseWrapper.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "data/TaskCleanStorage.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
@@ -17,103 +16,201 @@
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/scheduling/TaskGroupSequential.h"
|
||||
#include "utility/scheduling/TaskGroupParallel.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(StorageAccessProxy* storageAccessProxy)
|
||||
#include "Application.h"
|
||||
#include "CxxProject.h"
|
||||
#include "JavaProject.h"
|
||||
#include "isTrial.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy)
|
||||
{
|
||||
std::shared_ptr<Project> ptr(new Project(storageAccessProxy));
|
||||
return ptr;
|
||||
std::shared_ptr<Project> project;
|
||||
|
||||
switch (ProjectSettings::getLanguageOfProject(projectSettingsFile))
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
case LANGUAGE_CPP:
|
||||
{
|
||||
project = std::shared_ptr<CxxProject>(new CxxProject(
|
||||
std::make_shared<CxxProjectSettings>(projectSettingsFile), storageAccessProxy
|
||||
));
|
||||
}
|
||||
break;
|
||||
case LANGUAGE_JAVA:
|
||||
{
|
||||
project = std::shared_ptr<JavaProject>(new JavaProject(
|
||||
std::make_shared<JavaProjectSettings>(projectSettingsFile), storageAccessProxy
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (project)
|
||||
{
|
||||
project->load();
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
}
|
||||
|
||||
const FilePath& Project::getProjectSettingsFilePath() const
|
||||
void Project::refresh()
|
||||
{
|
||||
return m_projectSettingsFilepath;
|
||||
if (allowsRefresh())
|
||||
{
|
||||
bool loadedSettings = getProjectSettings()->load();
|
||||
|
||||
updateFileManager(m_fileManager);
|
||||
|
||||
buildIndex();
|
||||
|
||||
m_state = PROJECT_STATE_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
Project::ProjectState Project::load(const FilePath& projectSettingsFile)
|
||||
void Project::forceRefresh()
|
||||
{
|
||||
m_state = PROJECT_NONE;
|
||||
|
||||
bool success = true;
|
||||
if (!projectSettingsFile.empty())
|
||||
if (allowsRefresh())
|
||||
{
|
||||
success = ProjectSettings::getInstance()->load(projectSettingsFile);
|
||||
clearStorage();
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
if (success)
|
||||
FilePath Project::getProjectSettingsFilePath() const
|
||||
{
|
||||
return getProjectSettings()->getFilePath();
|
||||
}
|
||||
|
||||
std::string Project::getDescription() const
|
||||
{
|
||||
return getProjectSettings()->getDescription();
|
||||
}
|
||||
|
||||
bool Project::settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const
|
||||
{
|
||||
return getProjectSettings()->equalsExceptNameAndLocation(otherSettings);
|
||||
}
|
||||
|
||||
void Project::logStats() const
|
||||
{
|
||||
m_storage->logStats();
|
||||
}
|
||||
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
, m_state(PROJECT_STATE_NOT_LOADED)
|
||||
{
|
||||
}
|
||||
|
||||
void Project::load()
|
||||
{
|
||||
const std::shared_ptr<ProjectSettings> projectSettings = getProjectSettings();
|
||||
bool loadedSettings = projectSettings->load();
|
||||
if (loadedSettings)
|
||||
{
|
||||
setProjectSettingsFilePath(projectSettingsFile);
|
||||
updateFileManager();
|
||||
const FilePath projectSettingsPath = projectSettings->getFilePath();
|
||||
const FilePath dbPath = FilePath(projectSettingsPath).replaceExtension("coatidb");
|
||||
m_storage = std::make_shared<PersistentStorage>(dbPath);
|
||||
m_storageAccessProxy->setSubject(m_storage.get());
|
||||
|
||||
if (m_storage->isEmpty())
|
||||
{
|
||||
m_state = PROJECT_STATE_EMPTY;
|
||||
m_storage->setup();
|
||||
}
|
||||
else if (m_storage->isIncompatible())
|
||||
{
|
||||
m_state = PROJECT_STATE_OUTVERSIONED;
|
||||
}
|
||||
else if (TextAccess::createFromFile(projectSettingsPath.str())->getText() != m_storage->getProjectSettingsText())
|
||||
{
|
||||
m_state = PROJECT_STATE_OUTDATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = PROJECT_STATE_LOADED;
|
||||
}
|
||||
|
||||
updateFileManager(m_fileManager);
|
||||
|
||||
bool reparse = false;
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case PROJECT_NONE:
|
||||
break;
|
||||
case PROJECT_STATE_EMPTY:
|
||||
buildIndex();
|
||||
m_state = PROJECT_STATE_LOADED;
|
||||
break;
|
||||
case PROJECT_STATE_OUTDATED:
|
||||
if (Application::getInstance()->hasGUI() && !isTrial())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = Application::getInstance()->handleDialog(
|
||||
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
|
||||
"reflect the current project state. Do you want to reindex the project?", options);
|
||||
|
||||
case PROJECT_EMPTY:
|
||||
parseCode();
|
||||
break;
|
||||
reparse = (result == 0);
|
||||
}
|
||||
// dont break here.
|
||||
case PROJECT_STATE_LOADED:
|
||||
m_storage->finishParsing();
|
||||
MessageFinishedParsing(0, 0, 0, true).dispatch();
|
||||
break;
|
||||
case PROJECT_STATE_OUTVERSIONED:
|
||||
MessageStatus("Can't load project").dispatch();
|
||||
|
||||
case PROJECT_LOADED:
|
||||
case PROJECT_OUTDATED:
|
||||
m_storage->finishParsing();
|
||||
MessageFinishedParsing(0, 0, 0, true).dispatch();
|
||||
break;
|
||||
reparse = true;
|
||||
|
||||
case PROJECT_OUTVERSIONED:
|
||||
m_storage.reset();
|
||||
break;
|
||||
if (Application::getInstance()->hasGUI() && !isTrial())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = Application::getInstance()->handleDialog(
|
||||
"This project was indexed with a different version of Coati. It needs to be fully reindexed to be used "
|
||||
"with this version of Coati. Do you want to reindex the project?", options);
|
||||
|
||||
reparse = (result == 0);
|
||||
}
|
||||
m_storage.reset();
|
||||
break;
|
||||
}
|
||||
|
||||
if (reparse)
|
||||
{
|
||||
forceRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
return m_state;
|
||||
}
|
||||
|
||||
Project::ProjectState Project::reload()
|
||||
{
|
||||
if (m_state == PROJECT_LOADED &&
|
||||
FileSystem::getFileInfoForPath(m_projectSettingsFilepath).lastWriteTime >
|
||||
FileSystem::getFileInfoForPath(m_storage->getDbFilePath()).lastWriteTime)
|
||||
{
|
||||
m_state = PROJECT_OUTDATED;
|
||||
}
|
||||
else if (!m_projectSettingsFilepath.empty() && (m_state == PROJECT_EMPTY || m_state == PROJECT_LOADED))
|
||||
{
|
||||
ProjectSettings::getInstance()->load(m_projectSettingsFilepath);
|
||||
updateFileManager();
|
||||
|
||||
parseCode();
|
||||
}
|
||||
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void Project::clearStorage()
|
||||
{
|
||||
if (m_state == PROJECT_OUTVERSIONED)
|
||||
if (!m_storage)
|
||||
{
|
||||
loadStorage(m_projectSettingsFilepath);
|
||||
const FilePath projectSettingsPath = getProjectSettings()->getFilePath();
|
||||
const FilePath dbPath = FilePath(projectSettingsPath).replaceExtension("coatidb");
|
||||
m_storage = std::make_shared<PersistentStorage>(dbPath);
|
||||
}
|
||||
|
||||
if (m_storage)
|
||||
{
|
||||
m_storage->clear();
|
||||
m_state = PROJECT_EMPTY;
|
||||
m_state = PROJECT_STATE_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
void Project::parseCode()
|
||||
void Project::buildIndex()
|
||||
{
|
||||
if (m_projectSettingsFilepath.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath().str())->getText());
|
||||
|
||||
m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
std::set<FilePath> addedFilePaths = m_fileManager.getAddedFilePaths();
|
||||
@@ -131,7 +228,6 @@ void Project::parseCode()
|
||||
filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end());
|
||||
filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end());
|
||||
|
||||
m_state = PROJECT_LOADED;
|
||||
|
||||
if (!filesToClean.size() && !filesToParse.size())
|
||||
{
|
||||
@@ -147,28 +243,6 @@ void Project::parseCode()
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(&m_fileManager, indexerThreadCount > 1);
|
||||
fileRegister->setFilePaths(filesToParse);
|
||||
|
||||
if (ProjectSettings::getInstance()->getLanguage() == "Java")
|
||||
{
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
JavaEnvironmentFactory::createInstance(
|
||||
"data/java/asm-5.0.3.jar;"
|
||||
"data/java/cglib-3.1.jar;"
|
||||
"data/java/easymock-3.3.1.jar;"
|
||||
"data/java/guava-18.0.jar;"
|
||||
"data/java/hamcrest-core-1.3.jar;"
|
||||
"data/java/java-indexer.jar;"
|
||||
"data/java/javaparser-core-2.4.1-SNAPSHOT.jar;"
|
||||
"data/java/javaslang-2.0.0-beta.jar;"
|
||||
"data/java/javassist-3.19.0-GA.jar;"
|
||||
"data/java/java-symbol-solver-core-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/java-symbol-solver-model-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/objenesis-2.1.jar;"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(
|
||||
m_storage.get(),
|
||||
fileRegister
|
||||
@@ -182,160 +256,15 @@ void Project::parseCode()
|
||||
|
||||
for (int i = 0; i < indexerThreadCount; i++)
|
||||
{
|
||||
if (ProjectSettings::getInstance()->getLanguage() == "Java")
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
Parser::Arguments arguments;
|
||||
|
||||
for (FilePath classpath: projSettings->getAbsoluteJavaClasspaths())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(classpath.str());
|
||||
}
|
||||
|
||||
for (FilePath sourcePath: projSettings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (sourcePath.extension().empty())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(sourcePath.str());
|
||||
}
|
||||
}
|
||||
|
||||
taskParallelIndexing->addTask(
|
||||
std::make_shared<TaskParseJava>(
|
||||
m_storage.get(),
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
arguments
|
||||
)
|
||||
);
|
||||
}
|
||||
else // c or cxx
|
||||
{
|
||||
taskParallelIndexing->addTask(std::make_shared<TaskParseCxx>(
|
||||
m_storage.get(),
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
getParserArguments()
|
||||
));
|
||||
}
|
||||
taskParallelIndexing->addTask(createIndexerTask(m_storage.get(), storageMutex, fileRegister));
|
||||
}
|
||||
|
||||
Task::dispatch(taskSequential);
|
||||
}
|
||||
|
||||
void Project::logStats() const
|
||||
bool Project::allowsRefresh()
|
||||
{
|
||||
m_storage->logStats();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::setProjectSettingsFilePath(const FilePath& path)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
m_storage.reset();
|
||||
m_state = PROJECT_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadStorage(path);
|
||||
|
||||
if (m_storage->isEmpty())
|
||||
{
|
||||
m_state = PROJECT_EMPTY;
|
||||
m_storage->setup();
|
||||
}
|
||||
else if (m_storage->isIncompatible())
|
||||
{
|
||||
m_state = PROJECT_OUTVERSIONED;
|
||||
m_storage.reset();
|
||||
}
|
||||
else if (FileSystem::getFileInfoForPath(path).lastWriteTime > FileSystem::getFileInfoForPath(m_storage->getDbFilePath()).lastWriteTime)
|
||||
{
|
||||
m_state = PROJECT_OUTDATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = PROJECT_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
m_storageAccessProxy->setSubject(m_storage.get());
|
||||
m_projectSettingsFilepath = path;
|
||||
}
|
||||
|
||||
void Project::loadStorage(const FilePath& path)
|
||||
{
|
||||
FilePath dbPath = FilePath(path).replaceExtension("coatidb");
|
||||
if (!m_storage || path != m_projectSettingsFilepath || !dbPath.exists())
|
||||
{
|
||||
m_storage = std::make_shared<PersistentStorage>(dbPath);
|
||||
}
|
||||
}
|
||||
|
||||
void Project::updateFileManager()
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
std::vector<FilePath> sourcePaths = projSettings->getAbsoluteSourcePaths();
|
||||
std::vector<FilePath> headerPaths = sourcePaths;
|
||||
|
||||
std::vector<std::string> sourceExtensions;
|
||||
|
||||
if (projSettings->getCompilationDatabasePath().exists())
|
||||
{
|
||||
sourcePaths = TaskParseCxx::getSourceFilesFromCDB(projSettings->getCompilationDatabasePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceExtensions = projSettings->getSourceExtensions();
|
||||
}
|
||||
|
||||
std::vector<FilePath> excludePaths = projSettings->getAbsoluteExcludePaths();
|
||||
|
||||
m_fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
|
||||
Parser::Arguments Project::getParserArguments() const
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
Parser::Arguments args;
|
||||
|
||||
utility::append(args.compilerFlags, projSettings->getCompilerFlags());
|
||||
|
||||
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
utility::append(args.systemHeaderSearchPaths, m_fileManager.getSourcePaths());
|
||||
|
||||
utility::append(args.systemHeaderSearchPaths, projSettings->getAbsoluteHeaderSearchPaths());
|
||||
|
||||
utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
|
||||
|
||||
// Add all subdirectories of the header search paths
|
||||
if (projSettings->getUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
std::vector<FilePath> headerSearchSubPaths;
|
||||
for (FilePath p : projSettings->getSourcePaths())
|
||||
{
|
||||
utility::append(headerSearchSubPaths, FileSystem::getSubDirectories(p));
|
||||
}
|
||||
|
||||
utility::append(args.systemHeaderSearchPaths, utility::unique(headerSearchSubPaths));
|
||||
}
|
||||
|
||||
utility::append(args.frameworkSearchPaths, projSettings->getAbsoluteFrameworkSearchPaths());
|
||||
utility::append(args.frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
|
||||
|
||||
args.language = projSettings->getLanguage();
|
||||
args.languageStandard = projSettings->getStandard();
|
||||
args.compilationDatabasePath = projSettings->getCompilationDatabasePath();
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
, m_state(PROJECT_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
+36
-28
@@ -2,57 +2,65 @@
|
||||
#define PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "settings/ProjectSettings.h" // todo: use forward declaration here
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class PersistentStorage;
|
||||
class StorageAccessProxy;
|
||||
class FileRegister;
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
enum ProjectState
|
||||
{
|
||||
PROJECT_NONE,
|
||||
PROJECT_EMPTY,
|
||||
PROJECT_LOADED,
|
||||
PROJECT_OUTDATED,
|
||||
PROJECT_OUTVERSIONED
|
||||
};
|
||||
static std::shared_ptr<Project> create(const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy);
|
||||
|
||||
static std::shared_ptr<Project> create(StorageAccessProxy* storageAccessProxy);
|
||||
virtual ~Project();
|
||||
|
||||
~Project();
|
||||
|
||||
const FilePath& getProjectSettingsFilePath() const;
|
||||
|
||||
ProjectState load(const FilePath& projectSettingsFile);
|
||||
ProjectState reload();
|
||||
|
||||
void clearStorage();
|
||||
void refresh();
|
||||
void forceRefresh();
|
||||
|
||||
FilePath getProjectSettingsFilePath() const;
|
||||
std::string getDescription() const;
|
||||
bool settingsEqualExceptNameAndLocation(const ProjectSettings& otherSettings) const;
|
||||
void logStats() const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
Project(StorageAccessProxy* storageAccessProxy);
|
||||
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings() = 0;
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const = 0;
|
||||
|
||||
private:
|
||||
enum ProjectStateType
|
||||
{
|
||||
PROJECT_STATE_NOT_LOADED,
|
||||
PROJECT_STATE_EMPTY,
|
||||
PROJECT_STATE_LOADED,
|
||||
PROJECT_STATE_OUTDATED,
|
||||
PROJECT_STATE_OUTVERSIONED
|
||||
};
|
||||
|
||||
Project(const Project&);
|
||||
Project operator=(const Project&);
|
||||
|
||||
void parseCode();
|
||||
void load();
|
||||
void clearStorage();
|
||||
void buildIndex();
|
||||
|
||||
void setProjectSettingsFilePath(const FilePath& path);
|
||||
void loadStorage(const FilePath& path);
|
||||
void updateFileManager();
|
||||
|
||||
Parser::Arguments getParserArguments() const;
|
||||
virtual bool allowsRefresh();
|
||||
virtual std::shared_ptr<Task> createIndexerTask(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister) = 0;
|
||||
virtual void updateFileManager(FileManager& fileManager) = 0;
|
||||
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
|
||||
ProjectState m_state;
|
||||
|
||||
FilePath m_projectSettingsFilepath;
|
||||
ProjectStateType m_state;
|
||||
FileManager m_fileManager;
|
||||
|
||||
std::shared_ptr<PersistentStorage> m_storage;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "data/location/TokenLocationLine.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "Application.h"
|
||||
|
||||
CodeController::CodeController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
@@ -47,7 +47,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
||||
statsSnippet.locationFile = std::make_shared<TokenLocationFile>(FilePath());
|
||||
statsSnippet.locationFile->isWholeCopy = true;
|
||||
|
||||
statsSnippet.title = ProjectSettings::getInstance()->getFilePath().withoutExtension().fileName();
|
||||
statsSnippet.title = Application::getInstance()->getCurrentProject()->getProjectSettingsFilePath().withoutExtension().fileName();
|
||||
|
||||
std::vector<std::string> description = getProjectDescription(statsSnippet.locationFile.get());
|
||||
|
||||
@@ -662,7 +662,7 @@ std::shared_ptr<TokenLocationFile> CodeController::getTokenLocationOfParentScope
|
||||
|
||||
std::vector<std::string> CodeController::getProjectDescription(TokenLocationFile* locationFile) const
|
||||
{
|
||||
std::string description = ProjectSettings::getInstance()->getDescription();
|
||||
std::string description = Application::getInstance()->getCurrentProject()->getDescription();
|
||||
|
||||
if (!description.size())
|
||||
{
|
||||
|
||||
@@ -248,6 +248,16 @@ bool PersistentStorage::isIncompatible() const
|
||||
return m_sqliteStorage.isIncompatible();
|
||||
}
|
||||
|
||||
std::string PersistentStorage::getProjectSettingsText() const
|
||||
{
|
||||
return m_sqliteStorage.getProjectSettingsText();
|
||||
}
|
||||
|
||||
void PersistentStorage::setProjectSettingsText(std::string text)
|
||||
{
|
||||
m_sqliteStorage.setProjectSettingsText(text);
|
||||
}
|
||||
|
||||
void PersistentStorage::setup()
|
||||
{
|
||||
m_sqliteStorage.setup();
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isIncompatible() const;
|
||||
std::string getProjectSettingsText() const;
|
||||
void setProjectSettingsText(std::string text);
|
||||
|
||||
void setup();
|
||||
void clear();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 2;
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 3;
|
||||
|
||||
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
|
||||
: m_dbFilePath(dbFilePath)
|
||||
@@ -90,6 +90,16 @@ bool SqliteStorage::isIncompatible() const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string SqliteStorage::getProjectSettingsText() const
|
||||
{
|
||||
return getMetaValue("project_settings");
|
||||
}
|
||||
|
||||
void SqliteStorage::setProjectSettingsText(std::string text)
|
||||
{
|
||||
insertOrUpdateMetaValue("project_settings", text);
|
||||
}
|
||||
|
||||
void SqliteStorage::setVersion()
|
||||
{
|
||||
setStorageVersion();
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isIncompatible() const;
|
||||
std::string getProjectSettingsText() const;
|
||||
void setProjectSettingsText(std::string text);
|
||||
|
||||
void setVersion();
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings()
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings(const FilePath& projectFilePath)
|
||||
: ProjectSettings(projectFilePath)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
: ProjectSettings(projectName, projectFileLocation)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::~CxxProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
{
|
||||
const CxxProjectSettings* typedOther = dynamic_cast<const CxxProjectSettings*>(&other);
|
||||
return(
|
||||
ProjectSettings::equalsExceptNameAndLocation(other)// &&
|
||||
// utility::isPermutation<FilePath>(getClasspaths(), typedOther->getClasspaths())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getAbsoluteHeaderSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getHeaderSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getAbsoluteFrameworkSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getFrameworkSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/compiler_flags/compiler_flag", defaultValues);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setCompilerFlags(const std::vector<std::string>& compilerFlags)
|
||||
{
|
||||
return setValues("source/compiler_flags/compiler_flag", compilerFlags);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return getValue<bool>("source/use_source_paths_for_header_search", false);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
return setValue<bool>("source/use_source_paths_for_header_search", useSourcePathsForHeaderSearch);
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getVisualStudioSolutionPath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/vs_solution_path", ""));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/vs_solution_path", visualStudioSolutionPath.str());
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getCompilationDatabasePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/compilation_db_path", ""));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/compilation_db_path", compilationDatabasePath.str());
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".c");
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
return defaultValues;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef CXX_PROJECT_SETTINGS_H
|
||||
#define CXX_PROJECT_SETTINGS_H
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class CxxProjectSettings: public ProjectSettings
|
||||
{
|
||||
public:
|
||||
CxxProjectSettings();
|
||||
CxxProjectSettings(const FilePath& projectFilePath);
|
||||
CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~CxxProjectSettings();
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteHeaderSearchPaths() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteFrameworkSearchPaths() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
bool setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
|
||||
FilePath getVisualStudioSolutionPath() const;
|
||||
bool setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath);
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
bool setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
};
|
||||
|
||||
#endif // CXX_PROJECT_SETTINGS_H
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings()
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings(const FilePath& projectFilePath)
|
||||
: ProjectSettings(projectFilePath)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
: ProjectSettings(projectName, projectFileLocation)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::~JavaProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
{
|
||||
const JavaProjectSettings* typedOther = dynamic_cast<const JavaProjectSettings*>(&other);
|
||||
return(
|
||||
ProjectSettings::equalsExceptNameAndLocation(other) &&
|
||||
utility::isPermutation<FilePath>(getClasspaths(), typedOther->getClasspaths())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FilePath> JavaProjectSettings::getClasspaths() const
|
||||
{
|
||||
return getPathValues("source/class_paths/class_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> JavaProjectSettings::getAbsoluteClasspaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getClasspaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setClasspaths(const std::vector<FilePath>& paths)
|
||||
{
|
||||
return setPathValues("source/class_paths/class_path", paths);
|
||||
}
|
||||
|
||||
std::vector<std::string> JavaProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".java");
|
||||
return defaultValues;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef JAVA_PROJECT_SETTINGS_H
|
||||
#define JAVA_PROJECT_SETTINGS_H
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class JavaProjectSettings: public ProjectSettings
|
||||
{
|
||||
public:
|
||||
JavaProjectSettings();
|
||||
JavaProjectSettings(const FilePath& projectFilePath);
|
||||
JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~JavaProjectSettings();
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
std::vector<FilePath> getClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteClasspaths() const;
|
||||
bool setClasspaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
};
|
||||
|
||||
#endif // JAVA_PROJECT_SETTINGS_H
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
std::string languageTypeToString(LanguageType t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
return "C";
|
||||
case LANGUAGE_CPP:
|
||||
return "C++";
|
||||
case LANGUAGE_JAVA:
|
||||
return "Java";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
LanguageType stringToLanguageType(std::string s)
|
||||
{
|
||||
if (s == "C")
|
||||
{
|
||||
return LANGUAGE_C;
|
||||
}
|
||||
else if (s == "C++")
|
||||
{
|
||||
return LANGUAGE_CPP;
|
||||
}
|
||||
else if (s == "Java")
|
||||
{
|
||||
return LANGUAGE_JAVA;
|
||||
}
|
||||
return LANGUAGE_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef LANGUAGE_TYPE_H
|
||||
#define LANGUAGE_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum LanguageType
|
||||
{
|
||||
LANGUAGE_C,
|
||||
LANGUAGE_CPP,
|
||||
LANGUAGE_JAVA,
|
||||
LANGUAGE_UNKNOWN
|
||||
};
|
||||
|
||||
std::string languageTypeToString(LanguageType t);
|
||||
LanguageType stringToLanguageType(std::string s);
|
||||
|
||||
#endif // LANGUAGE_TYPE_H
|
||||
@@ -1,75 +1,83 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions()
|
||||
LanguageType ProjectSettings::getLanguageOfProject(FilePath projectFilePath)
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".c");
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::s_instance;
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<ProjectSettings>(new ProjectSettings());
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
ProjectSettings tempSettings(projectFilePath);
|
||||
tempSettings.load();
|
||||
return tempSettings.getLanguage();
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings(const FilePath& projectFilePath)
|
||||
{
|
||||
setFilePath(projectFilePath);
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
{
|
||||
setFilePath(FilePath(projectFileLocation.str() + "/" + projectName + ".coatiproject"));
|
||||
}
|
||||
|
||||
ProjectSettings::~ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProjectSettings::operator==(const ProjectSettings& other) const
|
||||
bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
return
|
||||
getFilePath() == other.getFilePath() &&
|
||||
return (
|
||||
getLanguage() == other.getLanguage() &&
|
||||
getStandard() == other.getStandard() &&
|
||||
getVisualStudioSolutionPath() == other.getVisualStudioSolutionPath() &&
|
||||
getCompilationDatabasePath() == other.getCompilationDatabasePath() &&
|
||||
getUseSourcePathsForHeaderSearch() == other.getUseSourcePathsForHeaderSearch() &&
|
||||
utility::isPermutation<FilePath>(getSourcePaths(), other.getSourcePaths()) &&
|
||||
utility::isPermutation<FilePath>(getHeaderSearchPaths(), other.getHeaderSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getExcludePaths(), other.getExcludePaths()) &&
|
||||
utility::isPermutation<std::string>(getCompilerFlags(), other.getCompilerFlags()) &&
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions());
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions())
|
||||
);
|
||||
}
|
||||
|
||||
bool ProjectSettings::operator!=(const ProjectSettings& other) const
|
||||
bool ProjectSettings::load()
|
||||
{
|
||||
return !(*this == other);
|
||||
return Settings::load(getFilePath());
|
||||
}
|
||||
|
||||
void ProjectSettings::save(const FilePath& filePath)
|
||||
std::string ProjectSettings::getProjectName() const
|
||||
{
|
||||
m_projectName = "";
|
||||
m_projectFileLocation = "";
|
||||
|
||||
Settings::save(filePath);
|
||||
return getFilePath().withoutExtension().fileName();
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getLanguage() const
|
||||
void ProjectSettings::setProjectName(const std::string& name)
|
||||
{
|
||||
return getValue<std::string>("language_settings/language", "C++");
|
||||
setFilePath(FilePath(getProjectFileLocation().str() + "/" + name + ".coatiproject"));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setLanguage(const std::string& language)
|
||||
FilePath ProjectSettings::getProjectFileLocation() const
|
||||
{
|
||||
return setValue<std::string>("language_settings/language", language);
|
||||
return getFilePath().parentDirectory();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
||||
{
|
||||
setFilePath(FilePath(location.str() + "/" + getProjectName() + ".coatiproject"));
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getDescription() const
|
||||
{
|
||||
return getValue<std::string>("info/description", "");
|
||||
}
|
||||
|
||||
LanguageType ProjectSettings::getLanguage() const
|
||||
{
|
||||
return stringToLanguageType(getValue<std::string>("language_settings/language", languageTypeToString(LANGUAGE_UNKNOWN)));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setLanguage(LanguageType language)
|
||||
{
|
||||
return setValue<std::string>("language_settings/language", languageTypeToString(language));
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getStandard() const
|
||||
@@ -82,19 +90,6 @@ bool ProjectSettings::setStandard(const std::string& standard)
|
||||
return setValue<std::string>("language_settings/standard", standard);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getJavaClasspaths() const
|
||||
{
|
||||
return getPathValues("source/class_paths/class_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteJavaClasspaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getJavaClasspaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getSourcePaths() const
|
||||
{
|
||||
return getPathValues("source/source_paths/source_path");
|
||||
@@ -113,73 +108,6 @@ bool ProjectSettings::setSourcePaths(const std::vector<FilePath>& sourcePaths)
|
||||
return setPathValues("source/source_paths/source_path", sourcePaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteHeaderSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getHeaderSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ProjectSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteFrameworkSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getFrameworkSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ProjectSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/compiler_flags/compiler_flag", defaultValues);
|
||||
}
|
||||
|
||||
bool ProjectSettings::setCompilerFlags(const std::vector<std::string>& compilerFlags)
|
||||
{
|
||||
return setValues("source/compiler_flags/compiler_flag", compilerFlags);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
return getValues("source/extensions/source_extensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &sourceExtensions)
|
||||
{
|
||||
return setValues("source/extensions/source_extensions", sourceExtensions);
|
||||
}
|
||||
|
||||
bool ProjectSettings::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return getValue<bool>("source/use_source_paths_for_header_search", false);
|
||||
}
|
||||
|
||||
bool ProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
return setValue<bool>("source/use_source_paths_for_header_search", useSourcePathsForHeaderSearch);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getExcludePaths() const
|
||||
{
|
||||
return getPathValues("source/exclude_paths/exclude_path");
|
||||
@@ -198,59 +126,14 @@ bool ProjectSettings::setExcludePaths(const std::vector<FilePath>& excludePaths)
|
||||
return setPathValues("source/exclude_paths/exclude_path", excludePaths);
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getVisualStudioSolutionPath() const
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/vs_solution_path", ""));
|
||||
return getValues("source/extensions/source_extensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath)
|
||||
bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &sourceExtensions)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/vs_solution_path", visualStudioSolutionPath.str());
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getCompilationDatabasePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/compilation_db_path", ""));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/compilation_db_path", compilationDatabasePath.str());
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getDescription() const
|
||||
{
|
||||
return getValue<std::string>("info/description", "");
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getProjectName() const
|
||||
{
|
||||
if (m_projectName.size())
|
||||
{
|
||||
return m_projectName;
|
||||
}
|
||||
|
||||
return getFilePath().withoutExtension().fileName();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectName(const std::string& name)
|
||||
{
|
||||
m_projectName = name;
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getProjectFileLocation() const
|
||||
{
|
||||
if (!m_projectFileLocation.empty())
|
||||
{
|
||||
return m_projectFileLocation;
|
||||
}
|
||||
|
||||
return getFilePath().parentDirectory();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
||||
{
|
||||
m_projectFileLocation = location;
|
||||
return setValues("source/extensions/source_extensions", sourceExtensions);
|
||||
}
|
||||
|
||||
void ProjectSettings::makePathsAbsolute(std::vector<FilePath>& paths) const
|
||||
@@ -264,3 +147,8 @@ void ProjectSettings::makePathsAbsolute(std::vector<FilePath>& paths) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
@@ -5,82 +5,53 @@
|
||||
#include <vector>
|
||||
|
||||
#include "settings/Settings.h"
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
class ProjectSettings
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getDefaultSourceExtensions();
|
||||
static LanguageType getLanguageOfProject(FilePath projectFilePath);
|
||||
|
||||
static std::shared_ptr<ProjectSettings> getInstance();
|
||||
ProjectSettings();
|
||||
~ProjectSettings();
|
||||
ProjectSettings(const FilePath& projectFilePath);
|
||||
ProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~ProjectSettings();
|
||||
|
||||
bool operator==(const ProjectSettings& other) const;
|
||||
bool operator!=(const ProjectSettings& other) const;
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual void save(const FilePath& filePath);
|
||||
virtual bool load();
|
||||
|
||||
// language settings
|
||||
std::string getLanguage() const;
|
||||
bool setLanguage(const std::string& language);
|
||||
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
// java... todo: move this
|
||||
std::vector<FilePath> getJavaClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteJavaClasspaths() const;
|
||||
|
||||
// source
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteHeaderSearchPaths() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteFrameworkSearchPaths() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
bool setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
bool setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
FilePath getVisualStudioSolutionPath() const;
|
||||
bool setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath);
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
bool setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
// info
|
||||
std::string getDescription() const;
|
||||
|
||||
// used in project wizzard
|
||||
std::string getProjectName() const;
|
||||
void setProjectName(const std::string& name);
|
||||
|
||||
FilePath getProjectFileLocation() const;
|
||||
void setProjectFileLocation(const FilePath& location);
|
||||
|
||||
private:
|
||||
std::string getDescription() const;
|
||||
|
||||
LanguageType getLanguage() const;
|
||||
bool setLanguage(LanguageType language);
|
||||
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
bool setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
protected:
|
||||
void makePathsAbsolute(std::vector<FilePath>& paths) const;
|
||||
|
||||
std::string m_projectName;
|
||||
FilePath m_projectFileLocation;
|
||||
|
||||
static std::shared_ptr<ProjectSettings> s_instance;
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
};
|
||||
|
||||
#endif // PROJECT_SETTINGS_H
|
||||
|
||||
@@ -15,12 +15,13 @@ public:
|
||||
Settings& operator=(const Settings& other);
|
||||
virtual ~Settings();
|
||||
|
||||
bool load(const FilePath& filePath);
|
||||
void save();
|
||||
virtual bool load(const FilePath& filePath);
|
||||
virtual void save();
|
||||
virtual void save(const FilePath& filePath);
|
||||
|
||||
void clear();
|
||||
|
||||
const FilePath& getFilePath() const;
|
||||
virtual const FilePath& getFilePath() const;
|
||||
|
||||
protected:
|
||||
Settings();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "utility/ScopedFunctor.h"
|
||||
|
||||
ScopedFunctor::ScopedFunctor(std::function<void(void)> onDestroy)
|
||||
: m_onDestroy(onDestroy)
|
||||
{
|
||||
}
|
||||
|
||||
ScopedFunctor::~ScopedFunctor()
|
||||
{
|
||||
m_onDestroy();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef SCOPED_FUNCTOR_H
|
||||
#define SCOPED_FUNCTOR_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
class ScopedFunctor
|
||||
{
|
||||
public:
|
||||
ScopedFunctor(std::function<void(void)> onDestroy);
|
||||
~ScopedFunctor();
|
||||
|
||||
private:
|
||||
std::function<void(void)> m_onDestroy;
|
||||
};
|
||||
|
||||
#endif // SCOPED_FUNCTOR_H
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
virtual std::vector<std::string> getProjectItems() = 0;
|
||||
virtual std::vector<std::string> getCompileFlags() = 0;
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath) = 0;
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath) = 0;
|
||||
|
||||
virtual std::string getIdeName() const = 0;
|
||||
virtual std::string getButtonText() const = 0;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "SolutionParserUtility.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserCodeBlocks::SolutionParserCodeBlocks()
|
||||
@@ -174,14 +175,12 @@ std::vector<std::string> SolutionParserCodeBlocks::getCompileFlags()
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath)
|
||||
std::shared_ptr<ProjectSettings> SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
openSolutionFile(solutionFilePath);
|
||||
|
||||
ProjectSettings settings;
|
||||
settings.setProjectName(getSolutionName());
|
||||
settings.setProjectFileLocation(getSolutionPath());
|
||||
settings.setVisualStudioSolutionPath(solutionFilePath);
|
||||
std::shared_ptr<CxxProjectSettings> settings = std::make_shared<CxxProjectSettings>(getSolutionName(), getSolutionPath());
|
||||
settings->setVisualStudioSolutionPath(solutionFilePath); // why is it called vs solution if it is used for codeblocks as well?
|
||||
|
||||
std::vector<std::string> sourceFiles = getProjectItems();
|
||||
std::vector<FilePath> sourcePaths;
|
||||
@@ -197,8 +196,8 @@ ProjectSettings SolutionParserCodeBlocks::getProjectSettings(const std::string&
|
||||
headerPaths.push_back(FilePath(p));
|
||||
}
|
||||
|
||||
settings.setSourcePaths(sourcePaths);
|
||||
settings.setHeaderSearchPaths(headerPaths);
|
||||
settings->setSourcePaths(sourcePaths);
|
||||
settings->setHeaderSearchPaths(headerPaths);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath);
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
virtual std::string getIdeName() const;
|
||||
virtual std::string getButtonText() const;
|
||||
|
||||
@@ -39,7 +39,7 @@ bool SolutionParserManager::canParseSolution(const std::string& ideId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserManager::getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const
|
||||
std::shared_ptr<ProjectSettings> SolutionParserManager::getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const
|
||||
{
|
||||
std::string lIdeId = ideId;
|
||||
boost::algorithm::to_lower(lIdeId);
|
||||
@@ -57,7 +57,7 @@ ProjectSettings SolutionParserManager::getProjectSettings(const std::string& ide
|
||||
|
||||
LOG_ERROR_STREAM(<< "Solution type is unknown");
|
||||
|
||||
return ProjectSettings();
|
||||
return std::shared_ptr<ProjectSettings>();
|
||||
}
|
||||
|
||||
unsigned int SolutionParserManager::getParserCount() const
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
|
||||
bool canParseSolution(const std::string& ideId) const;
|
||||
|
||||
ProjectSettings getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const;
|
||||
std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& ideId, const std::string& solutionFilePath) const;
|
||||
|
||||
unsigned int getParserCount() const;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "SolutionParserUtility.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserVisualStudio::SolutionParserVisualStudio()
|
||||
@@ -202,7 +203,7 @@ std::vector<std::string> SolutionParserVisualStudio::getCompileFlags()
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string& solutionFilePath)
|
||||
std::shared_ptr<ProjectSettings> SolutionParserVisualStudio::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
LOG_INFO_STREAM(<< "Starting to parse VS solution");
|
||||
|
||||
@@ -218,10 +219,8 @@ ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string
|
||||
|
||||
LOG_INFO_STREAM(<< "Setting meta information");
|
||||
|
||||
ProjectSettings settings;
|
||||
settings.setProjectName(getSolutionName());
|
||||
settings.setProjectFileLocation(getSolutionPath());
|
||||
settings.setVisualStudioSolutionPath(solutionFilePath);
|
||||
std::shared_ptr<CxxProjectSettings> settings = std::make_shared<CxxProjectSettings>(getSolutionName(), getSolutionPath());
|
||||
settings->setVisualStudioSolutionPath(solutionFilePath);
|
||||
|
||||
LOG_INFO_STREAM(<< "Parsing project files");
|
||||
|
||||
@@ -247,10 +246,10 @@ ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string
|
||||
LOG_INFO_STREAM(<< "Setting compile flags");
|
||||
|
||||
std::vector<std::string> compilerFlags = getCompileFlags();
|
||||
settings.setCompilerFlags(compilerFlags);
|
||||
settings->setCompilerFlags(compilerFlags);
|
||||
|
||||
settings.setSourcePaths(sourcePaths);
|
||||
settings.setHeaderSearchPaths(headerPaths);
|
||||
settings->setSourcePaths(sourcePaths);
|
||||
settings->setHeaderSearchPaths(headerPaths);
|
||||
|
||||
LOG_INFO_STREAM(<< "Done parsing VS solution");
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath);
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
virtual std::string getIdeName() const;
|
||||
virtual std::string getButtonText() const;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "qt/window/QtAbout.h"
|
||||
#include "qt/window/QtLicense.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "Application.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
@@ -420,7 +420,7 @@ void QtMainWindow::openProject(const QString &path)
|
||||
void QtMainWindow::editProject()
|
||||
{
|
||||
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
|
||||
wizzard->editProject(*ProjectSettings::getInstance().get());
|
||||
wizzard->editProject(Application::getInstance()->getCurrentProject()->getProjectSettingsFilePath());
|
||||
}
|
||||
|
||||
void QtMainWindow::find()
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
@@ -29,6 +32,8 @@
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
QtProjectWizzard::QtProjectWizzard(QWidget* parent)
|
||||
: QtWindowStackElement(parent)
|
||||
, m_windowStack(this)
|
||||
@@ -70,13 +75,11 @@ void QtProjectWizzard::hideWindow()
|
||||
|
||||
void QtProjectWizzard::newProject()
|
||||
{
|
||||
m_settings = ProjectSettings();
|
||||
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSelect>();
|
||||
|
||||
connect(dynamic_cast<QtProjectWizzardContentSelect*>(window->content()),
|
||||
SIGNAL(selected(QtProjectWizzardContentSelect::ProjectType)),
|
||||
this, SLOT(selectedProjectType(QtProjectWizzardContentSelect::ProjectType)));
|
||||
SIGNAL(selected(LanguageType, QtProjectWizzardContentSelect::ProjectType)),
|
||||
this, SLOT(selectedProjectType(LanguageType, QtProjectWizzardContentSelect::ProjectType)));
|
||||
|
||||
window->setNextEnabled(false);
|
||||
window->setPreviousEnabled(false);
|
||||
@@ -86,8 +89,9 @@ void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const st
|
||||
{
|
||||
if (m_parserManager->canParseSolution(ideId))
|
||||
{
|
||||
ProjectSettings settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
|
||||
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
|
||||
|
||||
// this looks rather hacky.. calling the edit project and then setting the title.
|
||||
editProject(settings);
|
||||
|
||||
QWidget* widget = m_windowStack.getTopWindow();
|
||||
@@ -124,12 +128,16 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
|
||||
window->content()->save();
|
||||
}
|
||||
|
||||
ProjectSettings settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
|
||||
|
||||
m_settings.setSourcePaths(settings.getSourcePaths());
|
||||
m_settings.setHeaderSearchPaths(settings.getHeaderSearchPaths());
|
||||
m_settings.setVisualStudioSolutionPath(FilePath(visualStudioSolutionPath));
|
||||
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> otherCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(settings);
|
||||
std::shared_ptr<CxxProjectSettings> ownCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (otherCxxSettings && ownCxxSettings)
|
||||
{
|
||||
ownCxxSettings->setSourcePaths(otherCxxSettings->getSourcePaths());
|
||||
ownCxxSettings->setHeaderSearchPaths(otherCxxSettings->getHeaderSearchPaths());
|
||||
ownCxxSettings->setVisualStudioSolutionPath(FilePath(visualStudioSolutionPath));
|
||||
}
|
||||
if (window)
|
||||
{
|
||||
window->content()->load();
|
||||
@@ -142,7 +150,28 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzard::editProject(const ProjectSettings& settings)
|
||||
void QtProjectWizzard::editProject(const FilePath& settingsPath)
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> settings;
|
||||
switch (ProjectSettings::getLanguageOfProject(settingsPath))
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
case LANGUAGE_CPP:
|
||||
settings = std::make_shared<CxxProjectSettings>(settingsPath);
|
||||
break;
|
||||
case LANGUAGE_JAVA:
|
||||
settings = std::make_shared<JavaProjectSettings>(settingsPath);
|
||||
break;
|
||||
}
|
||||
|
||||
if (settings)
|
||||
{
|
||||
settings->load();
|
||||
editProject(settings);
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzard::editProject(std::shared_ptr<ProjectSettings> settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
m_editing = true;
|
||||
@@ -167,14 +196,12 @@ void QtProjectWizzard::showPreferences()
|
||||
{
|
||||
summary->setIsForm(true);
|
||||
|
||||
ProjectSettings* settings = &m_settings;
|
||||
summary->addContent(new QtProjectWizzardContentPreferences(m_settings, window), false, false);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPreferences(settings, window), false, false);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window), false, false);
|
||||
if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window), false, false);
|
||||
}
|
||||
|
||||
window->setup();
|
||||
@@ -196,7 +223,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent()
|
||||
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
|
||||
|
||||
window->setContent(new T(&m_settings, window));
|
||||
window->setContent(new T(m_settings, window));
|
||||
window->setup();
|
||||
|
||||
m_windowStack.pushWindow(window);
|
||||
@@ -212,9 +239,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithContent<QtProjectWizza
|
||||
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
|
||||
|
||||
QtProjectWizzardContentSelect* content = new QtProjectWizzardContentSelect(&m_settings, window, m_parserManager);
|
||||
|
||||
|
||||
QtProjectWizzardContentSelect* content = new QtProjectWizzardContentSelect(m_settings, window, m_parserManager);
|
||||
|
||||
window->setContent(content);
|
||||
window->setup();
|
||||
@@ -232,7 +257,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createWindowWithSummary(
|
||||
connect(window, SIGNAL(previous()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(canceled()), this, SLOT(cancelWizzard()));
|
||||
|
||||
QtProjectWizzardContentSummary* summary = new QtProjectWizzardContentSummary(&m_settings, window);
|
||||
QtProjectWizzardContentSummary* summary = new QtProjectWizzardContentSummary(m_settings, window);
|
||||
|
||||
window->setContent(summary);
|
||||
func(window, summary);
|
||||
@@ -248,7 +273,7 @@ QtProjectWizzardWindow* QtProjectWizzard::createPopupWithContent()
|
||||
QtProjectWizzardWindow* window = new QtProjectWizzardWindow(parentWidget());
|
||||
|
||||
window->setShowAsPopup(true);
|
||||
window->setContent(new T(&m_settings, window));
|
||||
window->setContent(new T(m_settings, window));
|
||||
window->setup();
|
||||
|
||||
window->move(window->pos() + QPoint(50, 50));
|
||||
@@ -266,13 +291,6 @@ QtProjectWizzardWindow* QtProjectWizzard::createPopupWithContent()
|
||||
return window;
|
||||
}
|
||||
|
||||
ProjectSettings QtProjectWizzard::getSettingsForCompilationDatabase(const std::string& compilationDatabasePath) const
|
||||
{
|
||||
ProjectSettings settings;
|
||||
settings.setCompilationDatabasePath(FilePath(compilationDatabasePath));
|
||||
return settings;
|
||||
}
|
||||
|
||||
void QtProjectWizzard::connectShowFiles(QtProjectWizzardContent* content)
|
||||
{
|
||||
connect(content, SIGNAL(filesButtonClicked(QtProjectWizzardContent*)),
|
||||
@@ -311,11 +329,13 @@ void QtProjectWizzard::popupClosed()
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzard::selectedProjectType(QtProjectWizzardContentSelect::ProjectType type)
|
||||
void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
|
||||
m_settings = std::make_shared<CxxProjectSettings>();
|
||||
m_settings->setLanguage(languageType);
|
||||
emptyProject();
|
||||
break;
|
||||
|
||||
@@ -346,6 +366,8 @@ void QtProjectWizzard::selectedProjectType(QtProjectWizzardContentSelect::Projec
|
||||
}
|
||||
|
||||
case QtProjectWizzardContentSelect::PROJECT_CDB:
|
||||
m_settings = std::make_shared<CxxProjectSettings>();
|
||||
m_settings->setLanguage(languageType);
|
||||
emptyProjectCDB();
|
||||
break;
|
||||
}
|
||||
@@ -362,13 +384,12 @@ void QtProjectWizzard::sourcePaths()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
ProjectSettings* settings = &m_settings;
|
||||
|
||||
QtProjectWizzardContent* source = new QtProjectWizzardContentPathsSource(settings, window);
|
||||
QtProjectWizzardContent* source = new QtProjectWizzardContentPathsSource(m_settings, window);
|
||||
summary->addContent(source, false, false);
|
||||
connectShowFiles(source);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window), false, false);
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -382,11 +403,9 @@ void QtProjectWizzard::headerSearchPaths()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
ProjectSettings* settings = &m_settings;
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentSimple(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentSimple(m_settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window), false, true);
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -412,10 +431,8 @@ void QtProjectWizzard::frameworkSearchPaths()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
ProjectSettings* settings = &m_settings;
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window), false, false);
|
||||
|
||||
window->setup();
|
||||
}
|
||||
@@ -438,13 +455,11 @@ void QtProjectWizzard::headerPathsCDB()
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
ProjectSettings* settings = &m_settings;
|
||||
|
||||
QtProjectWizzardContent* source = new QtProjectWizzardContentCDBSource(settings, window);
|
||||
QtProjectWizzardContent* source = new QtProjectWizzardContentCDBSource(m_settings, window);
|
||||
summary->addContent(source, false, false);
|
||||
connectShowFiles(source);
|
||||
|
||||
QtProjectWizzardContent* header = new QtProjectWizzardContentPathsCDBHeader(settings, window);
|
||||
QtProjectWizzardContent* header = new QtProjectWizzardContentPathsCDBHeader(m_settings, window);
|
||||
summary->addContent(header, false, false);
|
||||
|
||||
window->setup();
|
||||
@@ -492,13 +507,11 @@ void QtProjectWizzard::showSummary()
|
||||
{
|
||||
summary->setIsForm(true);
|
||||
|
||||
ProjectSettings* settings = &m_settings;
|
||||
|
||||
QtProjectWizzardContentBuildFile* buildFile = new QtProjectWizzardContentBuildFile(settings, window);
|
||||
QtProjectWizzardContentBuildFile* buildFile = new QtProjectWizzardContentBuildFile(m_settings, window);
|
||||
|
||||
if (buildFile->getType() != QtProjectWizzardContentSelect::PROJECT_CDB)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentData(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentData(m_settings, window), false, false);
|
||||
|
||||
if (buildFile->getType() == QtProjectWizzardContentSelect::PROJECT_MANAGED)
|
||||
{
|
||||
@@ -509,39 +522,39 @@ void QtProjectWizzard::showSummary()
|
||||
this, SLOT(refreshProjectFromSolution(const std::string&, const std::string&)));
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsSource* source = new QtProjectWizzardContentPathsSource(settings, window);
|
||||
QtProjectWizzardContentPathsSource* source = new QtProjectWizzardContentPathsSource(m_settings, window);
|
||||
summary->addContent(source, false, true);
|
||||
connectShowFiles(source);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), false, true);
|
||||
summary->addContent(new QtProjectWizzardContentSimple(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_settings, window), false, true);
|
||||
summary->addContent(new QtProjectWizzardContentSimple(m_settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window), false, false);
|
||||
|
||||
if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(settings, window), false, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_settings, window), false, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window), false, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentDataCDB(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentDataCDB(m_settings, window), false, false);
|
||||
|
||||
QtProjectWizzardContent* headers = new QtProjectWizzardContentPathsCDBHeader(settings, window);
|
||||
QtProjectWizzardContent* headers = new QtProjectWizzardContentPathsCDBHeader(m_settings, window);
|
||||
summary->addContent(headers, false, true);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(m_settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(m_settings, window), false, true);
|
||||
|
||||
if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(m_settings, window), true, false);
|
||||
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(m_settings, window), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentFlags(settings, window), true, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(settings, window), true, true);
|
||||
summary->addContent(new QtProjectWizzardContentFlags(m_settings, window), true, true);
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window), true, true);
|
||||
|
||||
window->setup();
|
||||
|
||||
@@ -555,23 +568,52 @@ void QtProjectWizzard::showSummary()
|
||||
|
||||
void QtProjectWizzard::createProject()
|
||||
{
|
||||
FilePath path(m_settings.getProjectFileLocation().str() + "/" + m_settings.getProjectName() + ".coatiproject");
|
||||
m_settings.save(path);
|
||||
FilePath path = m_settings->getFilePath();
|
||||
|
||||
bool edited = false;
|
||||
m_settings->save(path);
|
||||
|
||||
bool foreceRefreshProject = false;
|
||||
if (m_editing)
|
||||
{
|
||||
bool settingsChanged = !(m_settings == *ProjectSettings::getInstance().get());
|
||||
std::shared_ptr<Application> application = Application::getInstance();
|
||||
FilePath oldPath = application->getCurrentProject()->getProjectSettingsFilePath();
|
||||
|
||||
if (oldPath.exists() && oldPath != path)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = application->handleDialog(
|
||||
"You changed the project location. The project file (.coatiproject) and the database file (.coatidb) will "
|
||||
"be moved to the new location. Do you want to keep a copy of the files in the previous location?"
|
||||
, options
|
||||
);
|
||||
|
||||
FilePath dbPath = FilePath(path).replaceExtension("coatidb");
|
||||
FilePath oldDbPath = FilePath(oldPath).replaceExtension("coatidb");
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
FileSystem::copyFile(oldDbPath, dbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileSystem::remove(oldPath);
|
||||
FileSystem::rename(oldDbPath, dbPath);
|
||||
}
|
||||
}
|
||||
|
||||
bool settingsChanged = !(application->getCurrentProject()->settingsEqualExceptNameAndLocation(*(m_settings.get())));
|
||||
bool appSettingsChanged = !(m_appSettings == *ApplicationSettings::getInstance().get());
|
||||
|
||||
if (settingsChanged || appSettingsChanged)
|
||||
{
|
||||
edited = true;
|
||||
foreceRefreshProject = true;
|
||||
}
|
||||
}
|
||||
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(path, edited)
|
||||
std::make_shared<MessageLoadProject>(path, foreceRefreshProject)
|
||||
).dispatch();
|
||||
|
||||
finishWizzard();
|
||||
@@ -584,7 +626,9 @@ void QtProjectWizzard::savePreferences()
|
||||
if (appSettingsChanged)
|
||||
{
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>("", true)
|
||||
std::make_shared<MessageLoadProject>(
|
||||
Application::getInstance()->getCurrentProject()->getProjectSettingsFilePath(), true
|
||||
)
|
||||
).dispatch();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -36,7 +36,8 @@ public slots:
|
||||
void newProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
|
||||
void refreshProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
|
||||
|
||||
void editProject(const ProjectSettings& settings);
|
||||
void editProject(const FilePath& settingsPath);
|
||||
void editProject(std::shared_ptr<ProjectSettings> settings);
|
||||
void showPreferences();
|
||||
|
||||
private:
|
||||
@@ -48,14 +49,12 @@ private:
|
||||
template<typename T>
|
||||
QtProjectWizzardWindow* createPopupWithContent();
|
||||
|
||||
ProjectSettings getSettingsForCompilationDatabase(const std::string& compilationDatabasePath) const;
|
||||
|
||||
void connectShowFiles(QtProjectWizzardContent* content);
|
||||
|
||||
QtWindowStack m_windowStack;
|
||||
std::shared_ptr<QtProjectWizzardWindow> m_popup;
|
||||
|
||||
ProjectSettings m_settings;
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
ApplicationSettings m_appSettings;
|
||||
|
||||
bool m_editing;
|
||||
@@ -69,7 +68,7 @@ private slots:
|
||||
void windowStackChanged();
|
||||
void popupClosed();
|
||||
|
||||
void selectedProjectType(QtProjectWizzardContentSelect::ProjectType type);
|
||||
void selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type);
|
||||
|
||||
void emptyProject();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ void QtHelpButton::handleHelpPress()
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContent::QtProjectWizzardContent(ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
QtProjectWizzardContent::QtProjectWizzardContent(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QWidget(window)
|
||||
, m_settings(settings)
|
||||
, m_window(window)
|
||||
|
||||
@@ -33,7 +33,7 @@ class QtProjectWizzardContent
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContent(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContent(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
virtual void populateWindow(QWidget* widget);
|
||||
virtual void populateWindow(QGridLayout* layout);
|
||||
@@ -64,7 +64,7 @@ protected:
|
||||
QtHelpButton* addHelpButton(QString helpString, QGridLayout* layout, int row) const;
|
||||
QPushButton* addFilesButton(QString name, QGridLayout* layout, int row) const;
|
||||
|
||||
ProjectSettings* m_settings;
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
QtProjectWizzardWindow* m_window;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -4,20 +4,25 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qt/element/QtLocationPicker.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
QtProjectWizzardContentBuildFile::QtProjectWizzardContentBuildFile(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_type(QtProjectWizzardContentSelect::PROJECT_EMPTY)
|
||||
{
|
||||
if (!m_settings->getVisualStudioSolutionPath().empty())
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_type = QtProjectWizzardContentSelect::PROJECT_MANAGED;
|
||||
}
|
||||
else if (!m_settings->getCompilationDatabasePath().empty())
|
||||
{
|
||||
m_type = QtProjectWizzardContentSelect::PROJECT_CDB;
|
||||
if (!cxxSettings->getVisualStudioSolutionPath().empty())
|
||||
{
|
||||
m_type = QtProjectWizzardContentSelect::PROJECT_MANAGED;
|
||||
}
|
||||
else if (!cxxSettings->getCompilationDatabasePath().empty())
|
||||
{
|
||||
m_type = QtProjectWizzardContentSelect::PROJECT_CDB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,35 +78,43 @@ void QtProjectWizzardContentBuildFile::populateForm(QGridLayout* layout, int& ro
|
||||
|
||||
void QtProjectWizzardContentBuildFile::load()
|
||||
{
|
||||
switch (m_type)
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
|
||||
return;
|
||||
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
|
||||
m_picker->setText(QString::fromStdString(m_settings->getVisualStudioSolutionPath().str()));
|
||||
break;
|
||||
case QtProjectWizzardContentSelect::PROJECT_CDB:
|
||||
m_picker->setText(QString::fromStdString(m_settings->getCompilationDatabasePath().str()));
|
||||
break;
|
||||
switch (m_type)
|
||||
{
|
||||
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
|
||||
return;
|
||||
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
|
||||
m_picker->setText(QString::fromStdString(cxxSettings->getVisualStudioSolutionPath().str()));
|
||||
break;
|
||||
case QtProjectWizzardContentSelect::PROJECT_CDB:
|
||||
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentBuildFile::save()
|
||||
{
|
||||
switch (m_type)
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
|
||||
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
|
||||
break;
|
||||
case QtProjectWizzardContentSelect::PROJECT_CDB:
|
||||
switch (m_type)
|
||||
{
|
||||
FilePath path = m_picker->getText().toStdString();
|
||||
if (!path.exists() || path.extension() != ".json")
|
||||
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
|
||||
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
|
||||
break;
|
||||
case QtProjectWizzardContentSelect::PROJECT_CDB:
|
||||
{
|
||||
return;
|
||||
FilePath path = m_picker->getText().toStdString();
|
||||
if (!path.exists() || path.extension() != ".json")
|
||||
{
|
||||
return;
|
||||
}
|
||||
cxxSettings->setCompilationDatabasePath(m_picker->getText().toStdString());
|
||||
break;
|
||||
}
|
||||
m_settings->setCompilationDatabasePath(m_picker->getText().toStdString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ signals:
|
||||
void refreshVisualStudioSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentBuildFile(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentBuildFile(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
QtProjectWizzardContentSelect::ProjectType getType() const;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
|
||||
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
QtProjectWizzardContentCDBSource::QtProjectWizzardContentCDBSource(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_text(nullptr)
|
||||
@@ -38,32 +39,35 @@ void QtProjectWizzardContentCDBSource::load()
|
||||
FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
std::vector<FilePath> excludePaths = m_settings->getAbsoluteExcludePaths();
|
||||
|
||||
std::vector<FilePath> filePaths = TaskParseCxx::getSourceFilesFromCDB(m_settings->getCompilationDatabasePath());
|
||||
for (FilePath path : filePaths)
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
bool excluded = false;
|
||||
for (FilePath p : excludePaths)
|
||||
std::vector<FilePath> filePaths = TaskParseCxx::getSourceFilesFromCDB(cxxSettings->getCompilationDatabasePath());
|
||||
for (FilePath path : filePaths)
|
||||
{
|
||||
if (p == path || p.contains(path))
|
||||
bool excluded = false;
|
||||
for (FilePath p : excludePaths)
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
if (p == path || p.contains(path))
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excluded)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (excluded)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
}
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
}
|
||||
|
||||
m_fileNames << QString::fromStdString(path.str());
|
||||
m_fileNames << QString::fromStdString(path.str());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_text)
|
||||
{
|
||||
m_text->setText(QString::number(m_fileNames.size()) + " source files were found in the compilation database.");
|
||||
|
||||
@@ -9,7 +9,7 @@ class QtProjectWizzardContentCDBSource
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentCDBSource(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentCDBSource(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout, int& row) override;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <QFormLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
QtProjectWizzardContentData::QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
QtProjectWizzardContentData::QtProjectWizzardContentData(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_projectName(nullptr)
|
||||
, m_projectFileLocation(nullptr)
|
||||
@@ -45,9 +47,9 @@ void QtProjectWizzardContentData::load()
|
||||
|
||||
if (m_language)
|
||||
{
|
||||
if (m_settings->getLanguage().length() > 0)
|
||||
if (m_settings->getLanguage() != LANGUAGE_UNKNOWN)
|
||||
{
|
||||
m_language->setCurrentText(QString::fromStdString(m_settings->getLanguage()));
|
||||
m_language->setCurrentText(QString::fromStdString(languageTypeToString(m_settings->getLanguage())));
|
||||
}
|
||||
|
||||
if (m_settings->getStandard().length() > 0)
|
||||
@@ -76,7 +78,7 @@ void QtProjectWizzardContentData::save()
|
||||
|
||||
if (m_language)
|
||||
{
|
||||
m_settings->setLanguage(m_language->currentText().toStdString());
|
||||
m_settings->setLanguage(stringToLanguageType(m_language->currentText().toStdString()));
|
||||
|
||||
if (m_cppStandard->isVisible())
|
||||
{
|
||||
@@ -239,7 +241,7 @@ void QtProjectWizzardContentData::handleSelectionChanged(int index)
|
||||
|
||||
|
||||
QtProjectWizzardContentDataCDB::QtProjectWizzardContentDataCDB(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContentData(settings, window)
|
||||
{
|
||||
}
|
||||
@@ -259,8 +261,11 @@ void QtProjectWizzardContentDataCDB::populateForm(QGridLayout* layout, int& row)
|
||||
void QtProjectWizzardContentDataCDB::load()
|
||||
{
|
||||
QtProjectWizzardContentData::load();
|
||||
|
||||
m_buildFilePicker->setText(QString::fromStdString(m_settings->getCompilationDatabasePath().str()));
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_buildFilePicker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentDataCDB::save()
|
||||
@@ -272,7 +277,12 @@ void QtProjectWizzardContentDataCDB::save()
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_settings->setCompilationDatabasePath(path);
|
||||
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setCompilationDatabasePath(path);
|
||||
}
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentDataCDB::check()
|
||||
|
||||
@@ -13,7 +13,7 @@ class QtProjectWizzardContentData
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentData(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentData(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout) override;
|
||||
@@ -50,7 +50,7 @@ class QtProjectWizzardContentDataCDB
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentDataCDB(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentDataCDB(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
virtual void populateForm(QGridLayout* layout, int& row) override;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "qt/element/QtDirectoryListBox.h"
|
||||
|
||||
QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class QtProjectWizzardContentExtensions
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentExtensions(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentExtensions(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout, int& row) override;
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include <QFormLayout>
|
||||
|
||||
#include "qt/element/QtDirectoryListBox.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
{
|
||||
}
|
||||
@@ -24,10 +25,18 @@ void QtProjectWizzardContentFlags::populateForm(QGridLayout* layout, int& row)
|
||||
|
||||
void QtProjectWizzardContentFlags::load()
|
||||
{
|
||||
m_list->setStringList(m_settings->getCompilerFlags());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_list->setStringList(cxxSettings->getCompilerFlags());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentFlags::save()
|
||||
{
|
||||
m_settings->setCompilerFlags(m_list->getStringList());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setCompilerFlags(m_list->getStringList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class QtProjectWizzardContentFlags
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentFlags(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentFlags(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateForm(QGridLayout* layout, int& row) override;
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "qt/element/QtDirectoryListBox.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/headerSearch/StandardHeaderDetection.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
{
|
||||
}
|
||||
@@ -197,7 +198,7 @@ void QtProjectWizzardContentPaths::detectionClicked()
|
||||
|
||||
|
||||
QtProjectWizzardContentPathsSource::QtProjectWizzardContentPathsSource(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
{
|
||||
@@ -278,7 +279,7 @@ QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPathsSource(settings, window)
|
||||
{
|
||||
@@ -297,7 +298,7 @@ QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
|
||||
|
||||
|
||||
QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
{
|
||||
@@ -320,7 +321,7 @@ void QtProjectWizzardContentPathsExclude::save()
|
||||
|
||||
|
||||
QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
{
|
||||
@@ -335,12 +336,20 @@ QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSear
|
||||
|
||||
void QtProjectWizzardContentPathsHeaderSearch::load()
|
||||
{
|
||||
m_list->setList(m_settings->getHeaderSearchPaths());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_list->setList(cxxSettings->getHeaderSearchPaths());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsHeaderSearch::save()
|
||||
{
|
||||
m_settings->setHeaderSearchPaths(m_list->getList());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setHeaderSearchPaths(m_list->getList());
|
||||
}
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentPathsHeaderSearch::isScrollAble() const
|
||||
@@ -349,7 +358,7 @@ bool QtProjectWizzardContentPathsHeaderSearch::isScrollAble() const
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsHeaderSearchGlobal::QtProjectWizzardContentPathsHeaderSearchGlobal(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
{
|
||||
@@ -380,7 +389,7 @@ void QtProjectWizzardContentPathsHeaderSearchGlobal::save()
|
||||
|
||||
|
||||
QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFrameworkSearch(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
{
|
||||
@@ -394,12 +403,20 @@ QtProjectWizzardContentPathsFrameworkSearch::QtProjectWizzardContentPathsFramewo
|
||||
|
||||
void QtProjectWizzardContentPathsFrameworkSearch::load()
|
||||
{
|
||||
m_list->setList(m_settings->getFrameworkSearchPaths());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_list->setList(cxxSettings->getFrameworkSearchPaths());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsFrameworkSearch::save()
|
||||
{
|
||||
m_settings->setFrameworkSearchPaths(m_list->getList());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setFrameworkSearchPaths(m_list->getList());
|
||||
}
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentPathsFrameworkSearch::isScrollAble() const
|
||||
@@ -408,7 +425,7 @@ bool QtProjectWizzardContentPathsFrameworkSearch::isScrollAble() const
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsFrameworkSearchGlobal::QtProjectWizzardContentPathsFrameworkSearchGlobal(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ signals:
|
||||
void showSourceFiles();
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentPaths(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPaths(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtSettingsWindow implementation
|
||||
virtual void populateWindow(QGridLayout* layout) override;
|
||||
@@ -57,7 +57,7 @@ class QtProjectWizzardContentPathsSource
|
||||
: public QtProjectWizzardContentPaths
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsSource(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsSource(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual QSize preferredWindowSize() const override;
|
||||
@@ -74,7 +74,7 @@ class QtProjectWizzardContentPathsCDBHeader
|
||||
: public QtProjectWizzardContentPathsSource
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsCDBHeader(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsCDBHeader(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
};
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class QtProjectWizzardContentPathsExclude
|
||||
: public QtProjectWizzardContentPaths
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsExclude(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsExclude(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
@@ -93,7 +93,7 @@ class QtProjectWizzardContentPathsHeaderSearch
|
||||
: public QtProjectWizzardContentPaths
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsHeaderSearch(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsHeaderSearch(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void load() override;
|
||||
@@ -106,7 +106,7 @@ class QtProjectWizzardContentPathsHeaderSearchGlobal
|
||||
: public QtProjectWizzardContentPaths
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsHeaderSearchGlobal(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsHeaderSearchGlobal(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void load() override;
|
||||
@@ -118,7 +118,7 @@ class QtProjectWizzardContentPathsFrameworkSearch
|
||||
: public QtProjectWizzardContentPaths
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsFrameworkSearch(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsFrameworkSearch(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void load() override;
|
||||
@@ -131,7 +131,7 @@ class QtProjectWizzardContentPathsFrameworkSearchGlobal
|
||||
: public QtProjectWizzardContentPaths
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsFrameworkSearchGlobal(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPathsFrameworkSearchGlobal(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void load() override;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_oldColorSchemeIndex(-1)
|
||||
|
||||
@@ -13,7 +13,7 @@ class QtProjectWizzardContentPreferences
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentPreferences(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPreferences(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
~QtProjectWizzardContentPreferences();
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "utility/solution/SolutionParserManager.h"
|
||||
|
||||
QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(ProjectSettings* settings, QtProjectWizzardWindow* window, std::weak_ptr<SolutionParserManager> solutionParserManager)
|
||||
QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window, std::weak_ptr<SolutionParserManager> solutionParserManager)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_solutionParserManager(solutionParserManager)
|
||||
{
|
||||
@@ -145,8 +145,6 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout)
|
||||
|
||||
void QtProjectWizzardContentSelect::save()
|
||||
{
|
||||
m_settings->setLanguage(m_languages->checkedButton()->text().toStdString());
|
||||
|
||||
ProjectType type;
|
||||
|
||||
switch (m_buttons->checkedId())
|
||||
@@ -157,7 +155,7 @@ void QtProjectWizzardContentSelect::save()
|
||||
default: type = PROJECT_MANAGED; break;
|
||||
}
|
||||
|
||||
emit selected(type);
|
||||
emit selected(stringToLanguageType(m_languages->checkedButton()->text().toStdString()), type);
|
||||
}
|
||||
|
||||
bool QtProjectWizzardContentSelect::check()
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
PROJECT_MANAGED = 2 // use this type for all standard parser (parsers that are handled by the parser manager)
|
||||
};
|
||||
|
||||
QtProjectWizzardContentSelect(ProjectSettings* settings, QtProjectWizzardWindow* window, std::weak_ptr<SolutionParserManager> solutionParserManager);
|
||||
QtProjectWizzardContentSelect(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window, std::weak_ptr<SolutionParserManager> solutionParserManager);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout) override;
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
virtual QSize preferredWindowSize() const override;
|
||||
|
||||
signals:
|
||||
void selected(QtProjectWizzardContentSelect::ProjectType);
|
||||
void selected(LanguageType, QtProjectWizzardContentSelect::ProjectType);
|
||||
|
||||
// void selected(unsigned int type);
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
|
||||
QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(ProjectSettings* settings, QtProjectWizzardWindow* window)
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_checkBox(nullptr)
|
||||
{
|
||||
@@ -52,10 +54,18 @@ void QtProjectWizzardContentSimple::populateForm(QGridLayout* layout, int& row)
|
||||
|
||||
void QtProjectWizzardContentSimple::load()
|
||||
{
|
||||
m_checkBox->setChecked(m_settings->getUseSourcePathsForHeaderSearch());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_checkBox->setChecked(cxxSettings->getUseSourcePathsForHeaderSearch());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentSimple::save()
|
||||
{
|
||||
m_settings->setUseSourcePathsForHeaderSearch(m_checkBox->isChecked());
|
||||
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setUseSourcePathsForHeaderSearch(m_checkBox->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class QtProjectWizzardContentSimple
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentSimple(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentSimple(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout) override;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QStringListModel>
|
||||
|
||||
QtProjectWizzardContentSourceList::QtProjectWizzardContentSourceList(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ class QtProjectWizzardContentSourceList
|
||||
: public QtProjectWizzardContent
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentSourceList(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentSourceList(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtSettingsWindow implementation
|
||||
virtual void populateWindow(QWidget* widget) override;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QCheckBox>
|
||||
|
||||
QtProjectWizzardContentSummary::QtProjectWizzardContentSummary(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_layout(nullptr)
|
||||
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentSummary(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentSummary(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
void addContent(QtProjectWizzardContent* content, bool advanced, bool gapBefore);
|
||||
void setIsForm(bool isForm);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class SettingsTestSuite : public CxxTest::TestSuite
|
||||
@@ -108,13 +109,15 @@ public:
|
||||
|
||||
void test_load_project_settings_from_file()
|
||||
{
|
||||
TS_ASSERT(ProjectSettings::getInstance()->load("data/SettingsTestSuite/settings.xml"));
|
||||
ProjectSettings settings(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
TS_ASSERT(settings.load());
|
||||
}
|
||||
|
||||
void test_load_source_path_from_file()
|
||||
{
|
||||
ProjectSettings::getInstance()->load("data/SettingsTestSuite/settings.xml");
|
||||
std::vector<FilePath> paths = ProjectSettings::getInstance()->getSourcePaths();
|
||||
ProjectSettings settings(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
settings.load();
|
||||
std::vector<FilePath> paths = settings.getSourcePaths();
|
||||
|
||||
TS_ASSERT_EQUALS(paths.size(), 1);
|
||||
TS_ASSERT_EQUALS(paths[0].str(), "data");
|
||||
@@ -122,8 +125,9 @@ public:
|
||||
|
||||
void test_load_header_search_paths_from_file()
|
||||
{
|
||||
ProjectSettings::getInstance()->load("data/SettingsTestSuite/settings.xml");
|
||||
std::vector<FilePath> paths = ProjectSettings::getInstance()->getHeaderSearchPaths();
|
||||
CxxProjectSettings settings(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
settings.load();
|
||||
std::vector<FilePath> paths = settings.getHeaderSearchPaths();
|
||||
|
||||
TS_ASSERT_EQUALS(paths.size(), 2);
|
||||
TS_ASSERT_EQUALS(paths[0].str(), "data/");
|
||||
|
||||
+5
-1
@@ -3,6 +3,7 @@
|
||||
#include "utility/logging/FileLogger.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
@@ -53,7 +54,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
|
||||
std::shared_ptr<Application> app = Application::create(version, &viewFactory, &networkFactory);
|
||||
Application::createInstance(version, &viewFactory, &networkFactory);
|
||||
ScopedFunctor f([](){
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
return qtApp.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user