logic: maven project setup
* added option to create a Coati project from a Maven POM file * show list of indexed file paths in maven project setup * use FileManager to detect indexed files in project setup (except cdb) * added Maven path to preferences window and added path detectors. * fixed: QtDialogView::hideStatusDialog now also hides loader in status bar. * refactored ProjectType fortune cookie message = If you continually give, you will continually have.
This commit is contained in:
+10
-11
@@ -130,6 +130,16 @@ int Application::handleDialog(const std::string& message, const std::vector<std:
|
||||
return getDialogView()->confirm(message, options);
|
||||
}
|
||||
|
||||
std::shared_ptr<DialogView> Application::getDialogView()
|
||||
{
|
||||
if (m_componentManager)
|
||||
{
|
||||
return m_componentManager->getDialogView();
|
||||
}
|
||||
|
||||
return std::shared_ptr<DialogView>();
|
||||
}
|
||||
|
||||
bool Application::isInTrial() const
|
||||
{
|
||||
return m_isInTrial;
|
||||
@@ -303,17 +313,6 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
DialogView* Application::getDialogView() const
|
||||
{
|
||||
if (m_componentManager)
|
||||
{
|
||||
return m_componentManager->getDialogView();
|
||||
}
|
||||
|
||||
static DialogView dialogView(nullptr);
|
||||
return &dialogView;
|
||||
}
|
||||
|
||||
void Application::logStorageStats() const
|
||||
{
|
||||
if (!ApplicationSettings::getInstance()->getLoggingEnabled())
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
int handleDialog(const std::string& message);
|
||||
int handleDialog(const std::string& message, const std::vector<std::string>& options);
|
||||
std::shared_ptr<DialogView> getDialogView();
|
||||
|
||||
bool isInTrial() const;
|
||||
|
||||
@@ -70,7 +71,6 @@ private:
|
||||
|
||||
void updateRecentProjects(const FilePath& projectSettingsFilePath);
|
||||
|
||||
DialogView* getDialogView() const;
|
||||
void logStorageStats() const;
|
||||
|
||||
void updateTitle();
|
||||
|
||||
@@ -236,6 +236,8 @@ add_files(
|
||||
settings/LanguageType.h
|
||||
settings/ProjectSettings.cpp
|
||||
settings/ProjectSettings.h
|
||||
settings/ProjectType.cpp
|
||||
settings/ProjectType.h
|
||||
settings/Settings.cpp
|
||||
settings/Settings.h
|
||||
settings/SettingsMigrator.cpp
|
||||
@@ -442,6 +444,8 @@ add_files(
|
||||
utility/utilityLibrary.h
|
||||
utility/utilityString.cpp
|
||||
utility/utilityString.h
|
||||
utility/utilityXml.cpp
|
||||
utility/utilityXml.h
|
||||
utility/UUIDUtility.cpp
|
||||
utility/UUIDUtility.h
|
||||
utility/Version.cpp
|
||||
|
||||
+2
-6
@@ -34,8 +34,6 @@
|
||||
#include "utility/Version.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "CxxProject.h"
|
||||
#include "JavaProject.h"
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
@@ -156,8 +154,6 @@ std::string Project::getDescription() const
|
||||
return getProjectSettings()->getDescription();
|
||||
}
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
|
||||
std::set<FilePath> Project::getSourceFilePaths() const
|
||||
{
|
||||
return m_fileManager.getSourceFilePaths();
|
||||
@@ -176,14 +172,14 @@ void Project::setStateSettingsUpdated()
|
||||
}
|
||||
}
|
||||
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy, DialogView* dialogView)
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
, m_dialogView(dialogView)
|
||||
, m_state(PROJECT_STATE_NOT_LOADED)
|
||||
{
|
||||
}
|
||||
|
||||
DialogView* Project::getDialogView() const
|
||||
std::shared_ptr<DialogView> Project::getDialogView() const
|
||||
{
|
||||
return m_dialogView;
|
||||
}
|
||||
|
||||
+3
-3
@@ -35,8 +35,8 @@ public:
|
||||
void setStateSettingsUpdated();
|
||||
|
||||
protected:
|
||||
Project(StorageAccessProxy* storageAccessProxy, DialogView* dialogView);
|
||||
DialogView* getDialogView() const;
|
||||
Project(StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView);
|
||||
std::shared_ptr<DialogView> getDialogView() const;
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings() = 0;
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
virtual void updateFileManager(FileManager& fileManager) = 0;
|
||||
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
DialogView* m_dialogView;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
ProjectStateType m_state;
|
||||
FileManager m_fileManager;
|
||||
|
||||
@@ -14,7 +14,7 @@ void ProjectFactory::addModule(std::shared_ptr<ProjectFactoryModule> module)
|
||||
}
|
||||
|
||||
std::shared_ptr<Project> ProjectFactory::createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView)
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView)
|
||||
{
|
||||
std::shared_ptr<Project> project;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void addModule(std::shared_ptr<ProjectFactoryModule> module);
|
||||
|
||||
std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView);
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView);
|
||||
|
||||
private:
|
||||
std::map<LanguageType, std::shared_ptr<ProjectFactoryModule>> m_modules;
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
virtual LanguageType getLanguage() const = 0;
|
||||
|
||||
virtual std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -110,9 +110,9 @@ void ComponentManager::refreshViews()
|
||||
}
|
||||
}
|
||||
|
||||
DialogView* ComponentManager::getDialogView() const
|
||||
std::shared_ptr<DialogView> ComponentManager::getDialogView() const
|
||||
{
|
||||
return m_dialogView.get();
|
||||
return m_dialogView;
|
||||
}
|
||||
|
||||
ComponentManager::ComponentManager()
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
void clearComponents();
|
||||
void refreshViews();
|
||||
|
||||
DialogView* getDialogView() const;
|
||||
std::shared_ptr<DialogView> getDialogView() const;
|
||||
|
||||
private:
|
||||
ComponentManager();
|
||||
|
||||
@@ -73,7 +73,8 @@ void StatusBarController::setStatus(const std::string& status, bool isError, boo
|
||||
if (!status.empty())
|
||||
{
|
||||
LOG_INFO_STREAM(<< "STATUS " << status);
|
||||
|
||||
getView()->showMessage(status, isError, showLoader);
|
||||
}
|
||||
|
||||
getView()->showMessage(status, isError, showLoader);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "utility/utility.h"
|
||||
|
||||
TaskCleanStorage::TaskCleanStorage(
|
||||
PersistentStorage* storage, const std::vector<FilePath>& filePaths, DialogView* dialogView
|
||||
PersistentStorage* storage, const std::vector<FilePath>& filePaths, std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_filePaths(filePaths)
|
||||
@@ -28,7 +28,7 @@ void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
DialogView* dialogView = m_dialogView;
|
||||
std::shared_ptr<DialogView> dialogView = m_dialogView;
|
||||
m_storage->clearFileElements(m_filePaths, [=](int progress)
|
||||
{
|
||||
if (dialogView != nullptr)
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
TaskCleanStorage(
|
||||
PersistentStorage* storage,
|
||||
const std::vector<FilePath>& filePaths,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
|
||||
private:
|
||||
@@ -28,7 +28,7 @@ private:
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
std::vector<FilePath> m_filePaths;
|
||||
DialogView* m_dialogView;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
TimePoint m_start;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
TaskFinishParsing::TaskFinishParsing(
|
||||
PersistentStorage* storage,
|
||||
StorageAccess* storageAccess,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_storageAccess(storageAccess)
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
TaskFinishParsing(
|
||||
PersistentStorage* storage,
|
||||
StorageAccess* storageAccess,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
|
||||
virtual ~TaskFinishParsing();
|
||||
@@ -31,7 +31,7 @@ private:
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
StorageAccess* m_storageAccess;
|
||||
DialogView* m_dialogView;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_FINISH_PARSING_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
TaskShowStatusDialog::TaskShowStatusDialog(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: m_title(title)
|
||||
, m_message(message)
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
TaskShowStatusDialog(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
|
||||
virtual ~TaskShowStatusDialog();
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
|
||||
const std::string m_title;
|
||||
const std::string m_message;
|
||||
DialogView* m_dialogView;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_SHOW_STATUS_DIALOG_H
|
||||
|
||||
@@ -14,7 +14,7 @@ TaskBuildIndex::TaskBuildIndex(
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList,
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: m_indexerCommandList(indexerCommandList)
|
||||
, m_storageProvider(storageProvider)
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
std::shared_ptr<IndexerCommandList> indexerCommandList,
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
|
||||
protected:
|
||||
@@ -36,7 +36,7 @@ protected:
|
||||
std::shared_ptr<IndexerCommandList> m_indexerCommandList;
|
||||
std::shared_ptr<StorageProvider> m_storageProvider;
|
||||
std::shared_ptr<FileRegisterStateData> m_fileRegisterStateData;
|
||||
DialogView* m_dialogView;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
std::shared_ptr<IndexerBase> m_indexer;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
TaskParseWrapper::TaskParseWrapper(
|
||||
PersistentStorage* storage,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_dialogView(dialogView)
|
||||
|
||||
@@ -20,7 +20,7 @@ class TaskParseWrapper
|
||||
public:
|
||||
TaskParseWrapper(
|
||||
PersistentStorage* storage,
|
||||
DialogView* dialogView
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
virtual ~TaskParseWrapper();
|
||||
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
DialogView* m_dialogView;
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
TimePoint m_start;
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
|
||||
@@ -247,6 +247,16 @@ void ApplicationSettings::setJavaMaximumMemory(int size)
|
||||
setValue<int>("indexing/java/java_maximum_memory", size);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getMavenPath() const
|
||||
{
|
||||
return getValue<std::string>("indexing/java/maven_path", "");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setMavenPath(const std::string path)
|
||||
{
|
||||
setValue<std::string>("indexing/java/maven_path", path);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("indexing/cxx/header_search_paths/header_search_path");
|
||||
|
||||
@@ -76,6 +76,9 @@ public:
|
||||
int getJavaMaximumMemory() const;
|
||||
void setJavaMaximumMemory(int size);
|
||||
|
||||
std::string getMavenPath() const;
|
||||
void setMavenPath(const std::string path);
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getHeaderSearchPathsExpanded() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
@@ -23,6 +23,31 @@ CxxProjectSettings::~CxxProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectType CxxProjectSettings::getProjectType() const
|
||||
{
|
||||
if (!getVisualStudioSolutionPath().empty()) // I think this is crap. VS solution path is not used anymore.. so vs projects are handled like cdb projects
|
||||
{
|
||||
return PROJECT_CXX_VS;
|
||||
}
|
||||
else if (!getCompilationDatabasePath().empty())
|
||||
{
|
||||
return PROJECT_CXX_CDB;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (getLanguage())
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
return PROJECT_C_EMPTY;
|
||||
case LANGUAGE_CPP:
|
||||
return PROJECT_CPP_EMPTY;
|
||||
default:
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
|
||||
@@ -11,6 +11,8 @@ public:
|
||||
CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~CxxProjectSettings();
|
||||
|
||||
virtual ProjectType getProjectType() const;
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual std::vector<std::string> getLanguageStandards() const;
|
||||
|
||||
@@ -23,6 +23,11 @@ JavaProjectSettings::~JavaProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectType JavaProjectSettings::getProjectType() const
|
||||
{
|
||||
return PROJECT_JAVA_EMPTY;
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
@@ -51,9 +56,48 @@ std::vector<FilePath> JavaProjectSettings::getAbsoluteClasspaths() const
|
||||
return makePathsAbsolute(expandPaths(getClasspaths()));
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setClasspaths(const std::vector<FilePath>& paths)
|
||||
bool JavaProjectSettings::setClasspaths(const std::vector<FilePath>& classpaths)
|
||||
{
|
||||
return setPathValues("source/class_paths/class_path", paths);
|
||||
return setPathValues("source/class_paths/class_path", classpaths);
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getMavenProjectFilePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/maven/project_root", ""));
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getAbsoluteMavenProjectFilePath() const
|
||||
{
|
||||
return makePathAbsolute(expandPath(getMavenProjectFilePath()));
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setMavenProjectFilePath(const FilePath& path)
|
||||
{
|
||||
return setValue("source/maven/project_root", path.str());
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getMavenDependenciesDirectory() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/maven/dependencies_directory", ""));
|
||||
}
|
||||
|
||||
FilePath JavaProjectSettings::getAbsoluteMavenDependenciesDirectory() const
|
||||
{
|
||||
return makePathAbsolute(expandPath(getMavenDependenciesDirectory()));
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setMavenDependenciesDirectory(const FilePath& path)
|
||||
{
|
||||
return setValue("source/maven/dependencies_directory", path.str());
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::getShouldIndexMavenTests() const
|
||||
{
|
||||
return getValue<bool>("source/maven/should_index_tests", false);
|
||||
}
|
||||
void JavaProjectSettings::setShouldIndexMavenTests(bool value)
|
||||
{
|
||||
setValue<bool>("source/maven/should_index_tests", value);
|
||||
}
|
||||
|
||||
std::vector<std::string> JavaProjectSettings::getDefaultSourceExtensions() const
|
||||
|
||||
@@ -12,13 +12,26 @@ public:
|
||||
JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~JavaProjectSettings();
|
||||
|
||||
virtual ProjectType getProjectType() const;
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual std::vector<std::string> getLanguageStandards() const;
|
||||
|
||||
std::vector<FilePath> getClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteClasspaths() const;
|
||||
bool setClasspaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
bool setClasspaths(const std::vector<FilePath>& classpaths);
|
||||
|
||||
FilePath getMavenProjectFilePath() const;
|
||||
FilePath getAbsoluteMavenProjectFilePath() const;
|
||||
bool setMavenProjectFilePath(const FilePath& path);
|
||||
|
||||
FilePath getMavenDependenciesDirectory() const;
|
||||
FilePath getAbsoluteMavenDependenciesDirectory() const;
|
||||
bool setMavenDependenciesDirectory(const FilePath& path);
|
||||
|
||||
bool getShouldIndexMavenTests() const;
|
||||
void setShouldIndexMavenTests(bool value);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
|
||||
@@ -47,3 +47,25 @@ std::string getSymbolNameDelimiterForLanguage(LanguageType t)
|
||||
}
|
||||
return "@";
|
||||
}
|
||||
|
||||
LanguageType getLanguageTypeForProjectType(ProjectType t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
return LANGUAGE_C;
|
||||
case PROJECT_CPP_EMPTY:
|
||||
return LANGUAGE_CPP;
|
||||
case PROJECT_CXX_CDB:
|
||||
return LANGUAGE_CPP;
|
||||
case PROJECT_CXX_VS:
|
||||
return LANGUAGE_CPP;
|
||||
case PROJECT_JAVA_EMPTY:
|
||||
return LANGUAGE_JAVA;
|
||||
case PROJECT_JAVA_MAVEN:
|
||||
return LANGUAGE_JAVA;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "settings/ProjectType.h"
|
||||
|
||||
enum LanguageType
|
||||
{
|
||||
LANGUAGE_C,
|
||||
@@ -15,5 +17,6 @@ std::string languageTypeToString(LanguageType t);
|
||||
LanguageType stringToLanguageType(std::string s);
|
||||
|
||||
std::string getSymbolNameDelimiterForLanguage(LanguageType t);
|
||||
LanguageType getLanguageTypeForProjectType(ProjectType t);
|
||||
|
||||
#endif // LANGUAGE_TYPE_H
|
||||
|
||||
@@ -32,6 +32,11 @@ ProjectSettings::~ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectType ProjectSettings::getProjectType() const
|
||||
{
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
|
||||
bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
return (
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
ProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~ProjectSettings();
|
||||
|
||||
virtual ProjectType getProjectType() const;
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual std::vector<std::string> getLanguageStandards() const;
|
||||
@@ -36,7 +38,7 @@ public:
|
||||
void setProjectFileLocation(const FilePath& location);
|
||||
|
||||
std::string getDescription() const;
|
||||
|
||||
|
||||
LanguageType getLanguage() const;
|
||||
bool setLanguage(LanguageType language);
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "settings/ProjectType.h"
|
||||
|
||||
std::string projectTypeToString(ProjectType v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case PROJECT_C_EMPTY:
|
||||
return "Empty C Project";
|
||||
case PROJECT_CPP_EMPTY:
|
||||
return "Empty C++ Project";
|
||||
case PROJECT_CXX_CDB:
|
||||
return "C/C++ from Compilation Database";
|
||||
case PROJECT_CXX_VS:
|
||||
return "C/C++ from Visual Studio";
|
||||
case PROJECT_JAVA_EMPTY:
|
||||
return "Empty Java Project";
|
||||
case PROJECT_JAVA_MAVEN:
|
||||
return "Java Project from Maven";
|
||||
case PROJECT_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
ProjectType stringToProjectType(std::string v)
|
||||
{
|
||||
if (v == projectTypeToString(PROJECT_C_EMPTY))
|
||||
{
|
||||
return PROJECT_C_EMPTY;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_CPP_EMPTY))
|
||||
{
|
||||
return PROJECT_CPP_EMPTY;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_CXX_CDB))
|
||||
{
|
||||
return PROJECT_CXX_CDB;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_CXX_VS))
|
||||
{
|
||||
return PROJECT_CXX_VS;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_JAVA_EMPTY))
|
||||
{
|
||||
return PROJECT_JAVA_EMPTY;
|
||||
}
|
||||
else if (v == projectTypeToString(PROJECT_JAVA_MAVEN))
|
||||
{
|
||||
return PROJECT_JAVA_MAVEN;
|
||||
}
|
||||
|
||||
return PROJECT_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef PROJECT_TYPE_H
|
||||
#define PROJECT_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum ProjectType
|
||||
{
|
||||
PROJECT_C_EMPTY,
|
||||
PROJECT_CPP_EMPTY,
|
||||
PROJECT_CXX_CDB,
|
||||
PROJECT_CXX_VS,
|
||||
PROJECT_JAVA_EMPTY,
|
||||
PROJECT_JAVA_MAVEN,
|
||||
PROJECT_UNKNOWN
|
||||
};
|
||||
|
||||
std::string projectTypeToString(ProjectType v);
|
||||
ProjectType stringToProjectType(std::string v);
|
||||
|
||||
#endif // PROJECT_TYPE_H
|
||||
@@ -106,7 +106,21 @@ std::set<FilePath> FileManager::getSourceFilePaths() const
|
||||
std::set<FilePath> sourceFilePaths;
|
||||
for (const FileInfo& fileInfo: FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions))
|
||||
{
|
||||
sourceFilePaths.emplace(fileInfo.path);
|
||||
const FilePath& path = fileInfo.path;
|
||||
bool excluded = false;
|
||||
for (FilePath p: m_excludePaths)
|
||||
{
|
||||
if (p == path || p.contains(path))
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!excluded)
|
||||
{
|
||||
sourceFilePaths.emplace(path);
|
||||
}
|
||||
}
|
||||
return sourceFilePaths;
|
||||
}
|
||||
@@ -115,6 +129,14 @@ bool FileManager::hasSourceFilePath(const FilePath& filePath) const
|
||||
{
|
||||
if (m_sourceFilePaths.find(filePath) != m_sourceFilePaths.end())
|
||||
{
|
||||
for (FilePath p: m_excludePaths)
|
||||
{
|
||||
if (p == filePath || p.contains(filePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
std::set<FilePath> getSourceFilePaths() const;
|
||||
|
||||
// checks if file is in non-excluded source directory
|
||||
virtual bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
bool hasSourceFilePath(const FilePath& filePath) const;
|
||||
|
||||
private:
|
||||
std::vector<FilePath> makeCanonical(const std::vector<FilePath>& filePaths);
|
||||
|
||||
@@ -68,59 +68,6 @@ TiXmlElement* SolutionParserUtility::getFirstTagByName(TiXmlElement* root, const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<TiXmlElement*> SolutionParserUtility::getAllTagsByName(TiXmlElement* root, const std::string& tag)
|
||||
{
|
||||
std::vector<TiXmlElement*> nodes;
|
||||
|
||||
TiXmlElement* element = root;
|
||||
|
||||
while (element)
|
||||
{
|
||||
std::string value = element->Value();
|
||||
|
||||
if (value == tag)
|
||||
{
|
||||
nodes.push_back(element);
|
||||
}
|
||||
|
||||
if (element->FirstChildElement() != NULL)
|
||||
{
|
||||
element = element->FirstChildElement();
|
||||
}
|
||||
else if (element->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (element == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
|
||||
{
|
||||
TiXmlElement* newElement = element->Parent()->ToElement();
|
||||
|
||||
if (newElement == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
element = newElement;
|
||||
}
|
||||
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->Parent()->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
TiXmlElement* SolutionParserUtility::getFirstTagByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute)
|
||||
{
|
||||
TiXmlElement* element = root;
|
||||
@@ -284,7 +231,7 @@ std::string SolutionParserUtility::findAndResolveEnvironmentVariable(const std::
|
||||
if (macro != "")
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Encountered IDE macro \"" << macro << "\"");
|
||||
|
||||
|
||||
if (m_ideMacroValues.find(macro) == m_ideMacroValues.end())
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Could not resolve IDE macro \"" << macro << "\"");
|
||||
@@ -358,7 +305,7 @@ std::string SolutionParserUtility::makePathCanonical(const std::string& path)
|
||||
{
|
||||
std::string what = e.what();
|
||||
LOG_WARNING_STREAM(<< e.what());
|
||||
|
||||
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Could not make path \"" << path << "\" canonical. Check if it really exists.";
|
||||
MessageStatus(errorMessage.str(), true).dispatch();
|
||||
|
||||
@@ -11,7 +11,6 @@ class SolutionParserUtility
|
||||
{
|
||||
public:
|
||||
static TiXmlElement* getFirstTagByName(TiXmlElement* root, const std::string& tag);
|
||||
static std::vector<TiXmlElement*> getAllTagsByName(TiXmlElement* root, const std::string& tag);
|
||||
|
||||
static TiXmlElement* getFirstTagByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute);
|
||||
static std::vector<TiXmlElement*> getAllTagsByNameWithAttribute(TiXmlElement* root, const std::string& tag, const std::string& attribute);
|
||||
@@ -24,7 +23,7 @@ public:
|
||||
static std::string makePathCanonical(const std::string& path);
|
||||
|
||||
static std::string checkIsIdeMacro(const std::string& text); // returns matching macro or empty string if no match was found
|
||||
|
||||
|
||||
static std::vector<std::string> m_ideMacros;
|
||||
static std::map<std::string, std::string> m_ideMacroValues; // to replace macros with known values
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define UTILITY_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <time.h>
|
||||
@@ -47,6 +48,15 @@ namespace utility
|
||||
template<typename T>
|
||||
std::vector<T> toVector(const std::set<T>& d);
|
||||
|
||||
template<typename T>
|
||||
void fillVectorWithElements(std::vector<T>& v, const T& arg);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void fillVectorWithElements(std::vector<T>& v, const T& arg, const Args&... args);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::vector<T> createVectorFromElements(const Args&... args);
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::string> toStrings(const std::vector<T>& d);
|
||||
template<>
|
||||
@@ -156,6 +166,27 @@ std::vector<T> utility::toVector(const std::set<T>& d)
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void utility::fillVectorWithElements(std::vector<T>& v, const T& arg)
|
||||
{
|
||||
v.push_back(arg);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void utility::fillVectorWithElements(std::vector<T>& v, const T& arg, const Args&... args)
|
||||
{
|
||||
fillVectorWithElements<T>(v, arg);
|
||||
fillVectorWithElements<T>(v, args...);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::vector<T> utility::createVectorFromElements(const Args&... args)
|
||||
{
|
||||
std::vector<T> v;
|
||||
fillVectorWithElements<T>(v, args...);
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::string> utility::toStrings(const std::vector<T>& d)
|
||||
{
|
||||
|
||||
@@ -211,6 +211,47 @@ namespace utility
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string insertLineBreaksAtBlankSpaces(const std::string& s, int maxLineLength)
|
||||
{
|
||||
const std::vector<std::string> atoms = splitToVector(s, " ");
|
||||
|
||||
std::string ret = "";
|
||||
std::string currentLine = "";
|
||||
for (const std::string& atom: atoms)
|
||||
{
|
||||
if (currentLine.size() + 1 + atom.size() <= maxLineLength)
|
||||
{
|
||||
currentLine += " " + atom;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ret.empty())
|
||||
{
|
||||
ret += "\n";
|
||||
}
|
||||
|
||||
if (currentLine.empty())
|
||||
{
|
||||
ret += atom;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += currentLine;
|
||||
currentLine = atom;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!currentLine.empty())
|
||||
{
|
||||
if (!ret.empty())
|
||||
{
|
||||
ret += "\n";
|
||||
}
|
||||
ret += currentLine;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string trim(const std::string &str)
|
||||
{
|
||||
auto wsfront = std::find_if_not(str.begin(), str.end(), [](int c){ return std::isspace(c); });
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace utility
|
||||
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||
|
||||
std::string insertLineBreaksAtBlankSpaces(const std::string& s, int maxLineLength);
|
||||
|
||||
std::string trim(const std::string &str);
|
||||
|
||||
template <typename ContainerType>
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
#include "utility/utilityXml.h";
|
||||
|
||||
#include "tinyxml/tinyxml.h";
|
||||
|
||||
namespace utility
|
||||
{
|
||||
|
||||
std::vector<std::string> getValuesOfAllXmlElementsOnPath(std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& tags)
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
|
||||
std::string text = textAccess->getText();
|
||||
|
||||
TiXmlDocument doc;
|
||||
const char* pTest = doc.Parse(text.c_str(), 0, TIXML_ENCODING_LEGACY);
|
||||
if (pTest != NULL)
|
||||
{
|
||||
TiXmlHandle docHandle(&doc);
|
||||
std::vector<std::pair<TiXmlElement*, size_t>> traversalStates;
|
||||
traversalStates.push_back(std::make_pair(docHandle.ToNode()->FirstChildElement(), 0));
|
||||
|
||||
while (!traversalStates.empty())
|
||||
{
|
||||
TiXmlElement* currentElement = traversalStates.back().first;
|
||||
const size_t currentIndex = traversalStates.back().second;
|
||||
traversalStates.pop_back();
|
||||
|
||||
if(currentElement != nullptr &&
|
||||
currentElement->Value() == tags[currentIndex]
|
||||
)
|
||||
{
|
||||
if (currentIndex < tags.size() - 1)
|
||||
{
|
||||
TiXmlElement* nextElement = currentElement->FirstChildElement();
|
||||
|
||||
while (nextElement)
|
||||
{
|
||||
traversalStates.push_back(std::make_pair(nextElement, size_t(currentIndex + 1)));
|
||||
nextElement = nextElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentElement->FirstChild() &&
|
||||
currentElement->FirstChild() == currentElement->LastChild() &&
|
||||
currentElement->FirstChild()->ToText()
|
||||
)
|
||||
{
|
||||
values.push_back(currentElement->FirstChild()->ToText()->Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// LOG_ERROR("Unable to load file.");
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<std::string> getValuesOfAllXmlTagsByName(std::shared_ptr<TextAccess> textAccess, const std::string& tag)
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
|
||||
std::string text = textAccess->getText();
|
||||
|
||||
TiXmlDocument doc;
|
||||
const char* pTest = doc.Parse(text.c_str(), 0, TIXML_ENCODING_UTF8);
|
||||
if (pTest != NULL)
|
||||
{
|
||||
TiXmlHandle docHandle(&doc);
|
||||
TiXmlElement *rootElement = docHandle.ToNode()->FirstChildElement();
|
||||
if(rootElement != nullptr)
|
||||
{
|
||||
for (TiXmlElement* element: getAllXmlTagsByName(rootElement, tag))
|
||||
{
|
||||
if (element->FirstChild() &&
|
||||
element->FirstChild() == element->LastChild() &&
|
||||
element->FirstChild()->ToText()
|
||||
)
|
||||
{
|
||||
values.push_back(element->FirstChild()->ToText()->Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// LOG_ERROR("Unable to load file.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// LOG_ERROR("Unable to load file.");
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
std::vector<TiXmlElement*> getAllXmlTagsByName(TiXmlElement* root, const std::string& tag)
|
||||
{
|
||||
std::vector<TiXmlElement*> nodes;
|
||||
|
||||
TiXmlElement* element = root;
|
||||
|
||||
while (element)
|
||||
{
|
||||
std::string value = element->Value();
|
||||
|
||||
if (value == tag)
|
||||
{
|
||||
nodes.push_back(element);
|
||||
}
|
||||
|
||||
if (element->FirstChildElement() != NULL)
|
||||
{
|
||||
element = element->FirstChildElement();
|
||||
}
|
||||
else if (element->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (element == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
while (element->Parent()->ToElement() != NULL && element->Parent()->NextSiblingElement() == NULL)
|
||||
{
|
||||
TiXmlElement* newElement = element->Parent()->ToElement();
|
||||
|
||||
if (newElement == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
element = newElement;
|
||||
}
|
||||
if (element->Parent() != NULL && element->Parent()->NextSiblingElement() != NULL)
|
||||
{
|
||||
element = element->Parent()->NextSiblingElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef UTILITY_XML_H
|
||||
#define UTILITY_XML_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
class TiXmlElement;
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::vector<std::string> getValuesOfAllXmlElementsOnPath(std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& tags);
|
||||
std::vector<std::string> getValuesOfAllXmlTagsByName(std::shared_ptr<TextAccess> textAccess, const std::string& tag);
|
||||
std::vector<TiXmlElement*> getAllXmlTagsByName(TiXmlElement* root, const std::string& tag);
|
||||
}
|
||||
|
||||
#endif // UTILITY_XML_H
|
||||
Reference in New Issue
Block a user