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:
malte_langkabel
2017-03-08 14:55:42 +01:00
parent d6f3099981
commit 3cbe83f9e6
83 changed files with 1502 additions and 545 deletions
+4 -2
View File
@@ -217,8 +217,6 @@ set_property(
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/external"
"${CMAKE_SOURCE_DIR}/src/lib_license"
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_BINARY_DIR}/src/lib_license"
)
@@ -275,6 +273,7 @@ set_property(
PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/lib_gui"
)
target_include_directories(${LIB_JAVA_PROJECT_NAME} SYSTEM
@@ -284,6 +283,8 @@ target_include_directories(${LIB_JAVA_PROJECT_NAME} SYSTEM
link_directories(${Boost_LIBRARY_DIRS})
target_link_libraries(${LIB_JAVA_PROJECT_NAME} ${LIB_PROJECT_NAME})
add_custom_command(
TARGET ${LIB_JAVA_PROJECT_NAME}
PRE_BUILD
@@ -361,6 +362,7 @@ set_property(
"${CMAKE_SOURCE_DIR}/src/lib_gui"
"${CMAKE_SOURCE_DIR}/src/lib"
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
"${CMAKE_SOURCE_DIR}/src/lib_java"
"${CMAKE_SOURCE_DIR}/src/lib_license"
"${CMAKE_BINARY_DIR}/src/lib_gui"
"${CMAKE_BINARY_DIR}/src/lib_license"
+1 -1
View File
@@ -154,7 +154,7 @@ QLabel, QCheckBox {
color: black;
font-size: 12px;
width: 7em;
height: 7em;
height: 8em;
margin-top: 10px;
}
-74
View File
@@ -1,74 +0,0 @@
Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies.
INFO: send MessageStatus Enabled console and file logging.
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage2
INFO: send TestMessage
INFO: send TestMessage2
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage2
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage
INFO: send TestMessage
NetworkProtocolHelper.cpp ERROR: Failed to parse message, invalid type token: foo. Expected setActiveToken
NetworkProtocolHelper.cpp ERROR: Failed to parse setActiveToken message, invalid token count
Settings.cpp WARNING: File for Settings not found: data/SettingsTestSuite/wrong_settings.xml
Settings.cpp WARNING: File for Settings not found: data/SettingsTestSuite/wrong_settings.xml
TextAccess.cpp ERROR: Could not open file path/to/test.h
TextAccess.cpp WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 3 > 2
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
TextAccess.cpp WARNING: Line numbers start with one, is 0
TextAccess.cpp WARNING: Line numbers start with one, is 0
TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 2:3 2:1
TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 4:1 1:10
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
+23 -3
View File
@@ -9,8 +9,6 @@
#include "data/indexer/IndexerFactoryModuleCxxCdb.h"
#include "data/indexer/IndexerFactoryModuleCxxManual.h"
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
#include "LicenseChecker.h"
#include "qt/network/QtNetworkFactory.h"
@@ -66,7 +64,27 @@ void prefillJavaRuntimePath()
else
{
MessageStatus("Run Java runtime path detection, no path found.");
std::cout << "no javapath" << std::endl;
}
}
}
void prefillMavenExecutablePath()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (settings->getMavenPath().empty())
{
std::shared_ptr<CombinedPathDetector> mavenPathDetector = utility::getMavenExecutablePathDetector();
std::vector<FilePath> paths = mavenPathDetector->getPaths();
if (!paths.empty())
{
MessageStatus("Run Maven executable path detection, found: " + paths.front().str());
settings->setMavenPath(paths.front().str());
settings->save();
}
else
{
MessageStatus("Run Maven executable path detection, no path found.");
}
}
}
@@ -142,6 +160,7 @@ int main(int argc, char *argv[])
});
prefillJavaRuntimePath();
prefillMavenExecutablePath();
prefillCxxHeaderPaths();
prefillCxxFrameworkPaths();
@@ -203,6 +222,7 @@ int main(int argc, char *argv[])
});
prefillJavaRuntimePath();
prefillMavenExecutablePath();
prefillCxxHeaderPaths();
prefillCxxFrameworkPaths();
+10 -11
View File
@@ -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())
+1 -1
View File
@@ -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();
+4
View File
@@ -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
View File
@@ -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
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
};
+2 -2
View File
@@ -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()
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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;
};
+1 -1
View File
@@ -10,7 +10,7 @@
TaskFinishParsing::TaskFinishParsing(
PersistentStorage* storage,
StorageAccess* storageAccess,
DialogView* dialogView
std::shared_ptr<DialogView> dialogView
)
: m_storage(storage)
, m_storageAccess(storageAccess)
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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;
};
+1 -1
View File
@@ -7,7 +7,7 @@
TaskParseWrapper::TaskParseWrapper(
PersistentStorage* storage,
DialogView* dialogView
std::shared_ptr<DialogView> dialogView
)
: m_storage(storage)
, m_dialogView(dialogView)
+2 -2
View File
@@ -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;
+10
View File
@@ -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");
+3
View File
@@ -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);
+25
View File
@@ -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())
+2
View File
@@ -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;
+46 -2
View File
@@ -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
+14 -1
View File
@@ -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;
+22
View File
@@ -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
View File
@@ -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
+5
View File
@@ -32,6 +32,11 @@ ProjectSettings::~ProjectSettings()
{
}
ProjectType ProjectSettings::getProjectType() const
{
return PROJECT_UNKNOWN;
}
bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
{
return (
+3 -1
View File
@@ -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);
+53
View File
@@ -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;
}
+20
View File
@@ -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
+23 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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
};
+31
View File
@@ -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)
{
+41
View File
@@ -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); });
+2
View File
@@ -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>
+153
View File
@@ -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;
}
}
+19
View File
@@ -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
+1 -1
View File
@@ -16,7 +16,7 @@
#include "Application.h"
CxxProject::CxxProject(
std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
std::shared_ptr<CxxProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
)
: Project(storageAccessProxy, dialogView)
, m_projectSettings(projectSettings)
+1 -1
View File
@@ -12,7 +12,7 @@ public:
CxxProject(
std::shared_ptr<CxxProjectSettings> projectSettings,
StorageAccessProxy* storageAccessProxy,
DialogView* dialogView
std::shared_ptr<DialogView> dialogView
);
virtual ~CxxProject();
+1 -1
View File
@@ -13,7 +13,7 @@ LanguageType ProjectFactoryModuleC::getLanguage() const
}
std::shared_ptr<Project> ProjectFactoryModuleC::createProject(
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
)
{
return std::shared_ptr<CxxProject>(new CxxProject(
+1 -1
View File
@@ -10,7 +10,7 @@ public:
virtual LanguageType getLanguage() const;
virtual std::shared_ptr<Project> createProject(
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
);
};
+1 -1
View File
@@ -13,7 +13,7 @@ LanguageType ProjectFactoryModuleCpp::getLanguage() const
}
std::shared_ptr<Project> ProjectFactoryModuleCpp::createProject(
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
)
{
return std::shared_ptr<CxxProject>(new CxxProject(
+1 -1
View File
@@ -10,7 +10,7 @@ public:
virtual LanguageType getLanguage() const;
virtual std::shared_ptr<Project> createProject(
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
);
};
+7
View File
@@ -158,6 +158,8 @@ add_files(
qt/window/project_wizzard/QtProjectWizzardContentExtensions.h
qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp
qt/window/project_wizzard/QtProjectWizzardContentFlags.h
qt/window/project_wizzard/QtProjectWizzardContentPath.cpp
qt/window/project_wizzard/QtProjectWizzardContentPath.h
qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
qt/window/project_wizzard/QtProjectWizzardContentPaths.h
qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp
@@ -223,6 +225,11 @@ add_files(
utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp
utility/path_detector/java_runtime/JavaPathDetectorWindows.h
utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp
utility/path_detector/maven_executable/MavenPathDetectorUnix.h
utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp
utility/path_detector/maven_executable/MavenPathDetectorWindows.h
utility/path_detector/CombinedPathDetector.cpp
utility/path_detector/CombinedPathDetector.h
utility/path_detector/PathDetector.cpp
@@ -10,6 +10,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentExtensions.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPath.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
@@ -48,8 +49,6 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
m_parserManager = std::make_shared<SolutionParserManager>();
// wip
// m_parserManager->pushSolutionParser(std::make_shared<SolutionParserCodeBlocks>());
}
void QtProjectWizzard::showWindow()
@@ -77,19 +76,19 @@ void QtProjectWizzard::newProject()
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSelect>();
connect(dynamic_cast<QtProjectWizzardContentSelect*>(window->content()),
SIGNAL(selected(LanguageType, QtProjectWizzardContentSelect::ProjectType)),
this, SLOT(selectedProjectType(LanguageType, QtProjectWizzardContentSelect::ProjectType)));
SIGNAL(selected(ProjectType)),
this, SLOT(selectedProjectType(ProjectType)));
window->setNextEnabled(false);
window->setPreviousEnabled(false);
window->updateSubTitle("Type Selection");
}
void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath)
void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
if (m_parserManager->canParseSolution(ideId))
{
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, solutionPath);
// this looks rather hacky.. calling the edit project and then setting the title.
editProject(settings);
@@ -136,7 +135,7 @@ void QtProjectWizzard::newProjectFromCDB(const std::string& filePath, const std:
emptyProjectCDBVS();
}
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath)
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
if (m_parserManager->canParseSolution(ideId))
{
@@ -146,7 +145,7 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
window->content()->save();
}
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, solutionPath);
std::shared_ptr<CxxProjectSettings> otherCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(settings);
std::shared_ptr<CxxProjectSettings> ownCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
@@ -154,7 +153,7 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
{
ownCxxSettings->setSourcePaths(otherCxxSettings->getSourcePaths());
ownCxxSettings->setHeaderSearchPaths(otherCxxSettings->getHeaderSearchPaths());
ownCxxSettings->setVisualStudioSolutionPath(FilePath(visualStudioSolutionPath));
ownCxxSettings->setVisualStudioSolutionPath(FilePath(solutionPath));
}
if (window)
{
@@ -342,67 +341,44 @@ void QtProjectWizzard::windowStackChanged()
}
}
void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type)
void QtProjectWizzard::selectedProjectType(ProjectType projectType)
{
switch (type)
LanguageType languageType = getLanguageTypeForProjectType(projectType);
switch (projectType)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
if (languageType == LANGUAGE_JAVA)
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
m_settings = std::make_shared<CxxProjectSettings>();
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
{
m_settings = std::make_shared<JavaProjectSettings>();
}
else
{
m_settings = std::make_shared<CxxProjectSettings>();
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
{
std::vector<std::string> flags;
flags.push_back("-fms-extensions");
flags.push_back("-fms-compatibility");
flags.push_back("-fms-compatibility-version=19");
std::dynamic_pointer_cast<CxxProjectSettings>(m_settings)->setCompilerFlags(flags);
}
std::vector<std::string> flags;
flags.push_back("-fms-extensions");
flags.push_back("-fms-compatibility");
flags.push_back("-fms-compatibility-version=19");
std::dynamic_pointer_cast<CxxProjectSettings>(m_settings)->setCompilerFlags(flags);
}
m_settings->setLanguage(languageType);
emptyProject();
break;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
/*{
std::string fileEndings = "(";
for (unsigned int i = 0; i < m_parserManager->getParserCount(); i++)
{
fileEndings += " *" + m_parserManager->getParserFileEnding(i);
}
fileEndings += ")";
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open Solution"), "", fileEndings.c_str()
);
if (!fileName.isNull())
{
for (unsigned int i = 0; i < m_parserManager->getParserCount(); i++)
{
if (fileName.contains(m_parserManager->getParserFileEnding(i).c_str()))
{
newProjectFromSolution(m_parserManager->getParserIdeId(i), fileName.toStdString());
}
}
}
break;
}*/
case PROJECT_CXX_CDB:
m_settings = std::make_shared<CxxProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectCDB();
break;
case PROJECT_CXX_VS:
m_settings = std::make_shared<CxxProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectCDBVS();
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
m_settings = std::make_shared<CxxProjectSettings>();
case PROJECT_JAVA_EMPTY:
m_settings = std::make_shared<JavaProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectCDB();
emptyProject();
break;
case PROJECT_JAVA_MAVEN:
m_settings = std::make_shared<JavaProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectJavaMaven();
break;
}
}
@@ -501,6 +477,14 @@ void QtProjectWizzard::emptyProjectCDB()
window->updateSubTitle("Project Data");
}
void QtProjectWizzard::emptyProjectJavaMaven()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentData>();
connect(window, SIGNAL(next()), this, SLOT(sourcePathsJavaMaven()));
window->updateSubTitle("Project Data");
}
void QtProjectWizzard::headerPathsCDB()
{
QtProjectWizzardWindow* window = createWindowWithSummary(
@@ -535,6 +519,27 @@ void QtProjectWizzard::sourcePathsJava()
window->updateSubTitle("Indexed Paths");
}
void QtProjectWizzard::sourcePathsJavaMaven()
{
std::dynamic_pointer_cast<JavaProjectSettings>(m_settings)->setMavenDependenciesDirectory(
"./coati_dependencies/" + utility::replace(m_settings->getProjectName(), " ", "_") + "/maven"
);
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_settings, window));
window->setup();
}
);
connect(window, SIGNAL(next()), this, SLOT(advancedSettingsJava()));
window->updateSubTitle("Indexed Paths");
}
void QtProjectWizzard::advancedSettingsCxx()
{
QtProjectWizzardWindow* window = createWindowWithSummary(
@@ -577,23 +582,13 @@ void QtProjectWizzard::showSummary()
summary->setIsForm(true);
QtProjectWizzardContentBuildFile* buildFile = new QtProjectWizzardContentBuildFile(m_settings, window);
bool isCDB = buildFile->getType() == QtProjectWizzardContentSelect::PROJECT_CDB;
const bool isCDB = buildFile->getType() == PROJECT_CXX_CDB || buildFile->getType() == PROJECT_CXX_VS;
if (!isCDB)
{
summary->addContent(new QtProjectWizzardContentData(m_settings, window, m_editing));
summary->addSpace();
if (buildFile->getType() == QtProjectWizzardContentSelect::PROJECT_MANAGED)
{
summary->addContent(buildFile);
summary->addSpace();
connect(dynamic_cast<QtProjectWizzardContentBuildFile*>(buildFile),
SIGNAL(refreshVisualStudioSolution(const std::string&, const std::string&)),
this, SLOT(refreshProjectFromSolution(const std::string&, const std::string&)));
}
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
summary->addSpace();
@@ -656,15 +651,31 @@ void QtProjectWizzard::showSummaryJava()
{
summary->setIsForm(true);
bool isMaven = false;
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
isMaven = javaSettings->getAbsoluteMavenProjectFilePath().exists();
}
summary->addContent(new QtProjectWizzardContentData(m_settings, window, m_editing));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
summary->addSpace();
if (isMaven)
{
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_settings, window));
}
else
{
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window));
}
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window));
@@ -33,9 +33,9 @@ public:
public slots:
void newProject();
void newProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
void refreshProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
void refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void editProject(const FilePath& settingsPath);
void editProject(std::shared_ptr<ProjectSettings> settings);
@@ -65,7 +65,7 @@ private slots:
void windowStackChanged();
void selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type);
void selectedProjectType(ProjectType type);
void emptyProject();
@@ -77,9 +77,12 @@ private slots:
void emptyProjectCDBVS();
void emptyProjectCDB();
void emptyProjectJavaMaven();
void headerPathsCDB();
void sourcePathsJava();
void sourcePathsJavaMaven();
void advancedSettingsCxx();
void advancedSettingsJava();
@@ -134,7 +134,10 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
{
QPushButton* button = new QPushButton(name);
button->setObjectName("windowButton");
layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop);
if (layout)
{
layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop);
}
connect(button, SIGNAL(clicked()), this, SLOT(filesButtonClicked()));
return button;
@@ -142,7 +145,7 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
void QtProjectWizzardContent::filesButtonClicked()
{
save();
m_window->saveContent();
if (!m_filesDialog)
{
@@ -13,23 +13,12 @@ QtProjectWizzardContentBuildFile::QtProjectWizzardContentBuildFile(
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(settings, window)
, m_type(QtProjectWizzardContentSelect::PROJECT_EMPTY)
, m_type(PROJECT_UNKNOWN)
{
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
if (cxxSettings)
{
if (!cxxSettings->getVisualStudioSolutionPath().empty())
{
m_type = QtProjectWizzardContentSelect::PROJECT_MANAGED;
}
else if (!cxxSettings->getCompilationDatabasePath().empty())
{
m_type = QtProjectWizzardContentSelect::PROJECT_CDB;
}
}
m_type = m_settings->getProjectType();
}
QtProjectWizzardContentSelect::ProjectType QtProjectWizzardContentBuildFile::getType() const
ProjectType QtProjectWizzardContentBuildFile::getType() const
{
return m_type;
}
@@ -41,18 +30,16 @@ void QtProjectWizzardContentBuildFile::populate(QGridLayout* layout, int& row)
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
name = "Build Text";
filter = "Text (*.txt)";
return;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
name = "Visual Studio Solution";
filter = "Visual Studio Solution (*.sln)";
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
name = "Compilation Database";
filter = "JSON Compilation Database (*.json)";
break;
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
name = "Build Text";
filter = "Text (*.txt)";
return;
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
name = "Compilation Database";
filter = "JSON Compilation Database (*.json)";
break;
}
QLabel* label = createFormLabel(name);
@@ -62,19 +49,6 @@ void QtProjectWizzardContentBuildFile::populate(QGridLayout* layout, int& row)
m_picker->setFileFilter(filter);
m_picker->setRelativeRootDirectory(m_settings->getProjectFileLocation());
QPushButton* button = new QtIconButton(
(ResourcePaths::getGuiPath() + "window/refresh.png").c_str(),
(ResourcePaths::getGuiPath() + "window/refresh_hover.png").c_str());
button->setToolTip("refresh paths");
connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked()));
if (m_type == QtProjectWizzardContentSelect::PROJECT_CDB)
{
button->hide();
}
m_picker->layout()->addWidget(button);
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
row++;
@@ -87,14 +61,13 @@ void QtProjectWizzardContentBuildFile::load()
{
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;
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
return;
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
break;
}
}
}
@@ -106,10 +79,11 @@ void QtProjectWizzardContentBuildFile::save()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
{
FilePath path = m_picker->getText().toStdString();
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
@@ -128,10 +102,11 @@ bool QtProjectWizzardContentBuildFile::check()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
break;
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
{
FilePath path = m_picker->getText().toStdString();
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
@@ -147,40 +122,3 @@ bool QtProjectWizzardContentBuildFile::check()
return true;
}
void QtProjectWizzardContentBuildFile::refreshClicked()
{
FilePath path = m_picker->getText().toStdString();
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
if (!absPath.exists())
{
QMessageBox msgBox;
msgBox.setText("Please enter a valid file path.");
msgBox.exec();
return;
}
QMessageBox::StandardButton reply =
QMessageBox::question(
this,
"Refresh Paths",
"Do you really want to refresh from the given file? All changes you have made to the project paths "
"and include paths will be lost.",
QMessageBox::Yes | QMessageBox::No
);
if (reply == QMessageBox::No)
{
return;
}
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_CDB:
break;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
emit refreshVisualStudioSolution("vs", path.str());
break;
}
}
@@ -18,7 +18,7 @@ signals:
public:
QtProjectWizzardContentBuildFile(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentSelect::ProjectType getType() const;
ProjectType getType() const;
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
@@ -27,13 +27,10 @@ public:
virtual void save() override;
virtual bool check() override;
private slots:
void refreshClicked();
private:
QtLocationPicker* m_picker;
QtProjectWizzardContentSelect::ProjectType m_type;
ProjectType m_type;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_BUILD_FILE_H
@@ -0,0 +1,203 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentPath.h"
#include <QCheckBox>
#include <QComboBox>
#include <QLabel>
#include <QMessageBox>
#include <QVBoxLayout>
#include "component/view/DialogView.h"
#include "qt/element/QtLocationPicker.h"
#include "settings/ApplicationSettings.h"
#include "settings/JavaProjectSettings.h"
#include "utility/file/FileManager.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/utilityMaven.h"
#include "utility/ScopedFunctor.h"
#include "Application.h"
QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_makePathRelativeToProjectFileLocation(true)
{
}
void QtProjectWizzardContentPath::populate(QGridLayout* layout, int& row)
{
QLabel* label = createFormLabel(m_titleString);
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
if (m_helpString.size() > 0)
{
addHelpButton(m_helpString, layout, row);
}
m_picker = new QtLocationPicker(this);
m_picker->setPickDirectory(true);
if (m_makePathRelativeToProjectFileLocation)
{
m_picker->setRelativeRootDirectory(m_settings->getProjectFileLocation());
}
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
row++;
}
bool QtProjectWizzardContentPath::check()
{
if (m_picker->getText().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please define the location for the \"" + m_titleString + "\".");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentPath::setTitleString(const QString& title)
{
m_titleString = title;
}
void QtProjectWizzardContentPath::setHelpString(const QString& help)
{
m_helpString = help;
}
QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven(
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
{
setTitleString("Maven Project Root");
setHelpString(
"Enter the root folder of your Maven project (where the main .pom file resides).<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& row)
{
QtProjectWizzardContentPath::populate(layout, row);
m_picker->setPickDirectory(false);
m_picker->setFileFilter("POM File (pom.xml)");
QPushButton* filesButton = addFilesButton("show source files", nullptr, row);
m_shouldIndexTests = new QCheckBox("Should Index Tests");
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addWidget(m_shouldIndexTests);
hlayout->addStretch();
hlayout->addWidget(filesButton);
layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL);
row++;
}
void QtProjectWizzardContentPathSourceMaven::load()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
m_picker->setText(QString::fromStdString(javaSettings->getMavenProjectFilePath().str()));
m_shouldIndexTests->setChecked(javaSettings->getShouldIndexMavenTests());
}
}
void QtProjectWizzardContentPathSourceMaven::save()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
javaSettings->setMavenProjectFilePath(m_picker->getText().toStdString());
javaSettings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
}
}
std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames() const
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath mavenProjectRoot = javaSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
std::vector<std::string> list;
const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot);
if (!success)
{
const std::string dialogMessage =
"Coati was unable to locate Maven on this machine.\n"
"Please make sure to provide the correct Maven Path in the preferences.";
MessageStatus(dialogMessage, true, false).dispatch();
Application::getInstance()->handleDialog(dialogMessage);
}
else
{
const std::vector<FilePath> sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom(
mavenPath,
mavenProjectRoot,
javaSettings->getShouldIndexMavenTests()
);
FileManager fileManager;
fileManager.setPaths(
sourceDirectories,
std::vector<FilePath>(), // we don't need to specify header paths here
m_settings->getAbsoluteExcludePaths(),
m_settings->getSourceExtensions()
);
const FilePath projectPath = m_settings->getProjectFileLocation();
for (FilePath path: fileManager.getSourceFilePaths())
{
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
}
list.push_back(path.str());
}
}
return list;
}
QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven(
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Maven project while it is indexed.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizzardContentPathDependenciesMaven::load()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
m_picker->setText(QString::fromStdString(javaSettings->getMavenDependenciesDirectory().str()));
}
}
void QtProjectWizzardContentPathDependenciesMaven::save()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
javaSettings->setMavenDependenciesDirectory(m_picker->getText().toStdString());
}
}
@@ -0,0 +1,69 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PATH_H
#define QT_PROJECT_WIZZARD_CONTENT_PATH_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "utility/path_detector/CombinedPathDetector.h"
class QCheckBox;
class QComboBox;
class QPushButton;
class QtLocationPicker;
class QtProjectWizzardContentPath
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentPath(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
virtual void populate(QGridLayout* layout, int& row) override;
virtual bool check() override;
protected:
void setTitleString(const QString& title);
void setHelpString(const QString& help);
QtLocationPicker* m_picker;
bool m_makePathRelativeToProjectFileLocation;
private:
QString m_titleString;
QString m_helpString;
};
class QtProjectWizzardContentPathSourceMaven
: public QtProjectWizzardContentPath
{
public:
QtProjectWizzardContentPathSourceMaven(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
virtual void populate(QGridLayout* layout, int& row) override;
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
virtual std::vector<std::string> getFileNames() const override;
private:
QCheckBox* m_shouldIndexTests;
};
class QtProjectWizzardContentPathDependenciesMaven
: public QtProjectWizzardContentPath
{
public:
QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H
@@ -172,33 +172,19 @@ void QtProjectWizzardContentPathsSource::save()
std::vector<std::string> QtProjectWizzardContentPathsSource::getFileNames() const
{
std::vector<FilePath> sourcePaths = m_settings->getAbsoluteSourcePaths();
std::vector<FilePath> excludePaths = m_settings->getAbsoluteExcludePaths();
std::vector<std::string> extensions = m_settings->getSourceExtensions();
FileManager fileManager;
fileManager.setPaths(
m_settings->getAbsoluteSourcePaths(),
std::vector<FilePath>(), // we don't need to specify header paths here
m_settings->getAbsoluteExcludePaths(),
m_settings->getSourceExtensions()
);
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions);
FilePath projectPath = m_settings->getProjectFileLocation();
const FilePath projectPath = m_settings->getProjectFileLocation();
std::vector<std::string> list;
for (const FileInfo& info : fileInfos)
for (FilePath path: fileManager.getSourceFilePaths())
{
FilePath path = info.path;
bool excluded = false;
for (FilePath p : excludePaths)
{
if (p == path || p.contains(path))
{
excluded = true;
break;
}
}
if (excluded)
{
continue;
}
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
@@ -143,7 +143,6 @@ public:
virtual void save() override;
};
class QtProjectWizzardContentPathsClassJava
: public QtProjectWizzardContentPaths
{
@@ -113,25 +113,20 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
// jvm library path
m_javaPath = new QtLocationPicker(this);
#ifdef _WIN32
QString filter = "JVM Library (jvm.dll)";
#elif __APPLE__
QString filter = "JLI or JVM Library (libjli.dylib libjvm.dylib)";
#else
QString filter = "JVM Library (libjvm.so)";
#endif
m_javaPath->setFileFilter(filter);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
m_javaPath->setFileFilter("JVM Library (jvm.dll)");
m_javaPath->setPlaceholderText("<jre_path>/bin/client/jvm.dll");
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_javaPath->setFileFilter("JLI or JVM Library (libjli.dylib libjvm.dylib)");
m_javaPath->setPlaceholderText("<jre_path>/Contents/Home/jre/lib/jli/libjli.dylib");
}
else
{
m_javaPath->setFileFilter("JVM Library (libjvm.so)");
m_javaPath->setPlaceholderText("<jre_path>/bin/<arch>/server/libjvm.so");
}
@@ -152,6 +147,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
javaVersionString += "Java 8";
addHelpButton((
"Only required for indexing Java projects.\n"
"Provide the location of the jvm library inside the installation of your " + javaVersionString +
" runtime environment (for information on how to set these take a look at "
"<a href=\"https://coati.io/documentation/#FindingJavaRuntimeLibraryLocation\">"
@@ -168,6 +164,37 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
"allocated by the indexer's JVM. A value of -1 ignores this setting.", layout, row);
layout->setRowMinimumHeight(row - 1, 30);
// maven path
m_mavenPath = new QtLocationPicker(this);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
m_mavenPath->setFileFilter("Maven command (mvn.cmd)");
m_mavenPath->setPlaceholderText("<maven_path>/bin/mvn.cmd");
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
// todo: add filter here
// todo: add placeholder here
}
else
{
// todo: add filter here
// todo: add placeholder here
}
addLabelAndWidget("Maven Path", m_mavenPath, layout, row);
addHelpButton(
"Only required for indexing projects using Maven.\n"
"Provide the location of the Maven executable. You can also use the auto detection below."
, layout, row
);
row++;
m_mavenPathDetector = utility::getMavenExecutablePathDetector();
addMavenPathDetection(layout, row);
addGap(layout, row);
// C/C++
@@ -214,6 +241,11 @@ void QtProjectWizzardContentPreferences::load()
}
m_jvmMaximumMemory->setText(QString::number(appSettings->getJavaMaximumMemory()));
if (m_mavenPath)
{
m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath()));
}
}
void QtProjectWizzardContentPreferences::save()
@@ -253,6 +285,11 @@ void QtProjectWizzardContentPreferences::save()
int jvmMaximumMemory = m_jvmMaximumMemory->text().toInt();
if (jvmMaximumMemory) appSettings->setJavaMaximumMemory(jvmMaximumMemory);
if (m_mavenPath)
{
appSettings->setMavenPath(m_mavenPath->getText().toStdString());
}
}
bool QtProjectWizzardContentPreferences::check()
@@ -265,7 +302,6 @@ void QtProjectWizzardContentPreferences::colorSchemeChanged(int index)
MessageSwitchColorScheme(m_colorSchemePaths[index]).dispatch();
}
void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
{
std::vector<FilePath> paths = m_javaPathDetector->getPaths(m_javaPathDetectorBox->currentText().toStdString());
@@ -275,6 +311,15 @@ void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
}
}
void QtProjectWizzardContentPreferences::mavenPathDetectionClicked()
{
std::vector<FilePath> paths = m_mavenPathDetector->getPaths(m_mavenPathDetectorBox->currentText().toStdString());
if (!paths.empty())
{
m_mavenPath->setText(paths.front().str().c_str());
}
}
void QtProjectWizzardContentPreferences::loggingEnabledChanged()
{
m_verboseIndexerLoggingEnabled->setEnabled(m_loggingEnabled->isChecked());
@@ -314,6 +359,40 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou
row++;
}
void QtProjectWizzardContentPreferences::addMavenPathDetection(QGridLayout* layout, int& row)
{
std::vector<std::string> detectorNames = m_mavenPathDetector->getWorkingDetectorNames();
if (detectorNames.empty())
{
return;
}
QLabel* label = new QLabel("Auto detection from:");
m_mavenPathDetectorBox = new QComboBox();
for (const std::string& detectorName: detectorNames)
{
m_mavenPathDetectorBox->addItem(detectorName.c_str());
}
QPushButton* button = new QPushButton("detect");
button->setObjectName("windowButton");
connect(button, SIGNAL(clicked()), this, SLOT(mavenPathDetectionClicked()));
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addWidget(label);
hlayout->addWidget(m_mavenPathDetectorBox);
hlayout->addWidget(button);
QWidget* detectionWidget = new QWidget();
detectionWidget->setLayout(hlayout);
layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
row++;
}
void QtProjectWizzardContentPreferences::addTitle(QString title, QGridLayout* layout, int& row)
{
layout->addWidget(createFormTitle(title), row++, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
@@ -29,10 +29,12 @@ public:
private slots:
void colorSchemeChanged(int index);
void javaPathDetectionClicked();
void mavenPathDetectionClicked();
void loggingEnabledChanged();
private:
void addJavaPathDetection(QGridLayout* layout, int& row);
void addMavenPathDetection(QGridLayout* layout, int& row);
void addTitle(QString title, QGridLayout* layout, int& row);
void addLabelAndWidget(
@@ -63,8 +65,12 @@ private:
QComboBox* m_threads;
std::shared_ptr<CombinedPathDetector> m_javaPathDetector;
std::shared_ptr<CombinedPathDetector> m_mavenPathDetector;
QComboBox* m_javaPathDetectorBox;
QComboBox* m_mavenPathDetectorBox;
QtLocationPicker* m_javaPath;
QtLocationPicker* m_mavenPath;
QLineEdit* m_jvmMaximumMemory;
};
@@ -7,6 +7,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
#include "utility/solution/SolutionParserManager.h"
@@ -22,45 +23,82 @@ QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(
void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
{
QPushButton* d = new QPushButton(languageTypeToString(LANGUAGE_CPP).c_str(), this);
QPushButton* e = new QPushButton(languageTypeToString(LANGUAGE_C).c_str(), this);
QPushButton* f = new QPushButton(languageTypeToString(LANGUAGE_JAVA).c_str(), this);
struct ProjectInfo
{
ProjectInfo(ProjectType type) :type(type) {}
const ProjectType type;
};
d->setObjectName("menuButton");
e->setObjectName("menuButton");
f->setObjectName("menuButton");
// define which kind of projects are available for each language
std::map<LanguageType, std::vector<ProjectInfo>> projectInfos;
projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_C_EMPTY));
projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_CXX_CDB));
projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_CXX_VS));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CPP_EMPTY));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CXX_CDB));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CXX_VS));
projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(PROJECT_JAVA_EMPTY));
projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(PROJECT_JAVA_MAVEN));
d->setCheckable(true);
e->setCheckable(true);
f->setCheckable(true);
// define which icons should be used for which kind of project
m_projectTypeIconName[PROJECT_C_EMPTY] = "empty_icon";
m_projectTypeIconName[PROJECT_CPP_EMPTY] = "empty_icon";
m_projectTypeIconName[PROJECT_CXX_CDB] = "cdb_icon";
m_projectTypeIconName[PROJECT_CXX_VS] = "vs_icon";
m_projectTypeIconName[PROJECT_JAVA_EMPTY] = "empty_icon";
m_projectTypeIconName[PROJECT_JAVA_MAVEN] = "empty_icon";
d->setChecked(true);
// define descriptions for each kind of project
m_projectTypeDescriptions[PROJECT_C_EMPTY] = "Create a new Coati project by defining which C files will be indexed.";
m_projectTypeDescriptions[PROJECT_CPP_EMPTY] = "Create a new Coati project by defining which C++ files will be indexed.";
m_projectTypeDescriptions[PROJECT_CXX_CDB] = "Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and "
"CMake projects. Have a look at the <a href=\"https://coati.io/documentation/#CreateAProjectFromCompilationDatabase\">"
"documentation</a> to find out more.";
m_projectTypeDescriptions[PROJECT_CXX_VS] = "Create a new project from an existing Visual Studio Solution file. "
"<b>Note: Requires a running Visual Studio instance with the "
"<a href=\"https://coati.io/documentation/index.html#VisualStudio\">Visual Studio plugin</a> installed.";
m_projectTypeDescriptions[PROJECT_JAVA_EMPTY] = "Create a new Coati project by defining which Java files will be indexed.";
m_projectTypeDescriptions[PROJECT_JAVA_MAVEN] = "Create a new project from an existing Maven project.";
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 30, 0, 0);
vlayout->setSpacing(10);
m_languages = new QButtonGroup();
m_languages->addButton(d);
m_languages->addButton(e);
m_languages->addButton(f);
for (auto it: projectInfos)
{
QPushButton* b = new QPushButton(languageTypeToString(it.first).c_str(), this);
b->setObjectName("menuButton");
b->setCheckable(true);
b->setProperty("language_type", it.first);
m_languages->addButton(b);
vlayout->addWidget(b);
}
m_languages->setId(d, 0);
m_languages->setId(e, 1);
m_languages->setId(f, 2);
vlayout->addStretch();
layout->addLayout(vlayout, 0, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
connect(m_languages, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
connect(m_languages, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
[this](QAbstractButton* button)
{
bool isJava = stringToLanguageType(m_languages->checkedButton()->text().toStdString()) == LANGUAGE_JAVA;
m_buttons->setExclusive(false);
for (int i = 0; i < m_buttons->buttons().size(); i++)
LanguageType selectedLanguage = LANGUAGE_UNKNOWN;
bool ok = false;
int languageTypeInt = button->property("language_type").toInt(&ok);
if (ok)
{
m_buttons->button(i)->setChecked(false);
selectedLanguage = LanguageType(languageTypeInt);
}
if (i != 0)
for (auto it: m_buttons)
{
it.second->setExclusive(false);
for (QAbstractButton* button: it.second->buttons())
{
m_buttons->button(i)->setVisible(!isJava);
button->setChecked(false);
button->setVisible(it.first == selectedLanguage);
}
it.second->setExclusive(true);
}
m_buttons->setExclusive(true);
m_window->setNextEnabled(false);
m_title->setText("Project Types - " + m_languages->checkedButton()->text());
@@ -68,94 +106,46 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
}
);
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 30, 0, 0);
vlayout->setSpacing(10);
vlayout->addWidget(d);
vlayout->addWidget(e);
vlayout->addWidget(f);
vlayout->addStretch();
layout->addLayout(vlayout, 0, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
QToolButton* a = createProjectButton(
"Empty Project", (ResourcePaths::getGuiPath() + "icon/empty_icon.png").c_str());
QToolButton* c = createProjectButton(
"from Compilation\nDatabase", (ResourcePaths::getGuiPath() + "icon/cdb_icon.png").c_str());
m_solutionDescription.push_back("Create a new Coati project by defining what files will be indexed.");
m_solutionDescription.push_back(
"Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and "
"CMake projects. Have a look at the <a href=\"https://coati.io/documentation/#CreateAProjectFromCompilationDatabase\">"
"documentation</a> to find out more.");
m_buttons = new QButtonGroup(this);
m_buttons->addButton(a);
m_buttons->addButton(c);
m_buttons->setId(a, PROJECT_EMPTY);
m_buttons->setId(c, PROJECT_CDB);
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->addWidget(a);
hlayout->addWidget(c);
unsigned int runningId = 2;
std::shared_ptr<SolutionParserManager> manager = m_solutionParserManager.lock();
if (manager != NULL)
for (auto languageIt: projectInfos)
{
for (unsigned int i = 0; i < manager->getParserCount(); i++)
QButtonGroup* projectButtons = new QButtonGroup(this);
for (auto projectIt: languageIt.second)
{
std::string name = manager->getParserButtonText(i);
QToolButton* button = createProjectButton(name.c_str(),
(ResourcePaths::getGuiPath() + manager->getIconPath(i)).c_str());
m_buttons->addButton(button);
m_solutionDescription.push_back(manager->getParserDescription(i));
hlayout->addWidget(button);
m_buttons->setId(button, runningId);
runningId++;
QToolButton* b = createProjectButton(
utility::insertLineBreaksAtBlankSpaces(projectTypeToString(projectIt.type), 15).c_str(),
(ResourcePaths::getGuiPath() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str()
);
b->setProperty("project_type", int(projectIt.type));
projectButtons->addButton(b);
hlayout->addWidget(b);
}
m_buttons[languageIt.first] = projectButtons;
}
// Add vs solution button
for (auto it: m_buttons)
{
std::string name = "Visual Studio";
connect(it.second, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
[this](QAbstractButton* button)
{
ProjectType selectedProject = PROJECT_UNKNOWN;
bool ok = false;
int projectTypeInt = button->property("project_type").toInt(&ok);
if (ok)
{
selectedProject = ProjectType(projectTypeInt);
}
QToolButton* button = createProjectButton(name.c_str(),
(ResourcePaths::getGuiPath() + "icon/vs_icon.png").c_str());
m_description->setText(m_projectTypeDescriptions[selectedProject].c_str());
m_buttons->addButton(button);
m_solutionDescription.push_back("Create a new project from an existing Visual Studio Solution file. "
"<b>Note: Requires a running Visual Studio instance with the "
"<a href=\"https://coati.io/documentation/index.html#VisualStudio\">Visual Studio plugin</a> installed.");
hlayout->addWidget(button);
m_buttons->setId(button, runningId);
runningId++;
m_window->setNextEnabled(true);
}
);
}
connect(m_buttons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
{
m_description->setText(m_solutionDescription[id].c_str());
m_window->setNextEnabled(true);
}
);
QFrame* container = new QFrame();
container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
container->setObjectName("projectContainer");
@@ -169,7 +159,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
m_description->setObjectName("projectDescription");
layout->addWidget(m_description, 1, QtProjectWizzardWindow::BACK_COL);
m_title = new QLabel("Project Types - " + m_languages->checkedButton()->text());
m_title = new QLabel("Project Types");
m_title->setObjectName("projectTitle");
layout->addWidget(m_title, 0, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
@@ -179,26 +169,44 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 0);
layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 1);
layout->setHorizontalSpacing(0);
m_languages->buttons().first()->click();
}
void QtProjectWizzardContentSelect::save()
{
ProjectType type;
switch (m_buttons->checkedId())
for (auto it: m_buttons)
{
case 0: type = PROJECT_EMPTY; break;
case 1: type = PROJECT_CDB; break;
case 2: type = PROJECT_MANAGED; break;
default: type = PROJECT_MANAGED; break;
if (QAbstractButton* b = it.second->checkedButton())
{
bool ok = false;
int projectType = b->property("project_type").toInt(&ok);
if (ok)
{
type = ProjectType(projectType);
break;
}
}
}
emit selected(stringToLanguageType(m_languages->checkedButton()->text().toStdString()), type);
emit selected(type);
}
bool QtProjectWizzardContentSelect::check()
{
if (m_buttons->checkedId() == -1)
bool projectChosen = false;
for (auto it: m_buttons)
{
if (it.second->checkedId() != -1)
{
projectChosen = true;
break;
}
}
if (!projectChosen)
{
QMessageBox msgBox;
msgBox.setText("Please choose a method of creating a new project.");
@@ -12,13 +12,6 @@ class QtProjectWizzardContentSelect
Q_OBJECT
public:
enum ProjectType : int
{
PROJECT_EMPTY = 0,
PROJECT_CDB = 1,
PROJECT_MANAGED = 2 // use this type for all standard parser (parsers that are handled by the parser manager)
};
QtProjectWizzardContentSelect(
std::shared_ptr<ProjectSettings> settings,
QtProjectWizzardWindow* window,
@@ -31,18 +24,17 @@ public:
virtual bool check() override;
signals:
void selected(LanguageType, QtProjectWizzardContentSelect::ProjectType);
void selected(ProjectType);
private:
QButtonGroup* m_languages;
QButtonGroup* m_buttons;
std::map<LanguageType, QButtonGroup*> m_buttons;
QLabel* m_title;
QLabel* m_description;
std::vector<std::string> m_projectTypeNames;
std::vector<std::string> m_projectTypeDescriptions;
std::vector<std::string> m_projectTypeIconPaths;
std::map<ProjectType, std::string> m_projectTypeIconName;
std::map<ProjectType, std::string> m_projectTypeDescriptions;
std::weak_ptr<SolutionParserManager> m_solutionParserManager;
std::vector<std::string> m_solutionDescription;
@@ -40,6 +40,11 @@ void QtProjectWizzardWindow::setPreferredSize(QSize size)
m_preferredSize = size;
}
void QtProjectWizzardWindow::saveContent()
{
m_content->save();
}
void QtProjectWizzardWindow::populateWindow(QWidget* widget)
{
QGridLayout* layout = new QGridLayout();
@@ -80,7 +85,7 @@ void QtProjectWizzardWindow::windowReady()
void QtProjectWizzardWindow::handleNext()
{
m_content->save();
saveContent();
if (m_content->check())
{
@@ -20,6 +20,8 @@ public:
void setPreferredSize(QSize size);
void saveContent();
static const int FRONT_COL = 0;
static const int HELP_COL = 1;
static const int LINE_COL = 2;
@@ -0,0 +1,25 @@
#include "utility/path_detector/maven_executable/MavenPathDetectorUnix.h"
#include "utility/utilityApp.h"
MavenPathDetectorUnix::MavenPathDetectorUnix()
: PathDetector("Maven for Unix")
{
}
MavenPathDetectorUnix::~MavenPathDetectorUnix()
{
}
std::vector<FilePath> MavenPathDetectorUnix::getPaths() const
{
std::string command = "which mvn";
FilePath mavenPath(utility::executeProcess(command.c_str()));
std::vector<FilePath> paths;
if (mavenPath.exists())
{
paths.push_back(mavenPath);
}
return paths;
}
@@ -0,0 +1,15 @@
#ifndef MAVEN_PATH_DETECTOR_UNIX_H
#define MAVEN_PATH_DETECTOR_UNIX_H
#include "utility/path_detector/PathDetector.h"
class MavenPathDetectorUnix: public PathDetector
{
public:
MavenPathDetectorUnix();
virtual ~MavenPathDetectorUnix();
virtual std::vector<FilePath> getPaths() const;
};
#endif // MAVEN_PATH_DETECTOR_UNIX_H
@@ -0,0 +1,25 @@
#include "utility/path_detector/maven_executable/MavenPathDetectorWindows.h"
#include "utility/utilityApp.h"
MavenPathDetectorWindows::MavenPathDetectorWindows()
: PathDetector("Maven for Windows")
{
}
MavenPathDetectorWindows::~MavenPathDetectorWindows()
{
}
std::vector<FilePath> MavenPathDetectorWindows::getPaths() const
{
std::string command = "cmd /k where mvn.cmd && exit";
FilePath mavenPath(utility::executeProcess(command.c_str()));
std::vector<FilePath> paths;
if (mavenPath.exists())
{
paths.push_back(mavenPath);
}
return paths;
}
@@ -0,0 +1,15 @@
#ifndef MAVEN_PATH_DETECTOR_WINDOWS_H
#define MAVEN_PATH_DETECTOR_WINDOWS_H
#include "utility/path_detector/PathDetector.h"
class MavenPathDetectorWindows: public PathDetector
{
public:
MavenPathDetectorWindows();
virtual ~MavenPathDetectorWindows();
virtual std::vector<FilePath> getPaths() const;
};
#endif // MAVEN_PATH_DETECTOR_WINDOWS_H
+8 -2
View File
@@ -5,11 +5,17 @@
#include "utility/utilityString.h"
std::string utility::executeProcess(const char *cmd)
std::string utility::executeProcess(const std::string& command, const std::string& workingDirectory)
{
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.start(cmd);
if (!workingDirectory.empty())
{
process.setWorkingDirectory(workingDirectory.c_str());
}
process.start(command.c_str());
process.waitForFinished();
std::string processoutput = process.readAll().toStdString();
process.close();
+2 -3
View File
@@ -1,17 +1,16 @@
#ifndef UTILITY_APP_H
#define UTILITY_APP_H
#include <QProcess>
#include <string>
#include "utility/ApplicationArchitectureType.h"
namespace utility
{
std::string executeProcess(const char* cmd);
std::string executeProcess(const std::string& command, const std::string& workingDirectory = "");
ApplicationArchitectureType getApplicationArchitectureType();
}
#endif // UTILITY_APP_H
@@ -6,6 +6,9 @@
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
#include "utility/path_detector/maven_executable/MavenPathDetectorUnix.h"
#include "utility/path_detector/maven_executable/MavenPathDetectorWindows.h"
#include "utility/path_detector/cxx_header/CxxFrameworkPathDetector.h"
#include "utility/path_detector/cxx_header/CxxHeaderPathDetector.h"
#include "utility/path_detector/cxx_header/CxxVsHeaderPathDetector.h"
@@ -29,6 +32,21 @@ std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getMavenExecutablePathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
combinedDetector->addDetector(std::make_shared<MavenPathDetectorWindows>());
}
else
{
combinedDetector->addDetector(std::make_shared<MavenPathDetectorUnix>());
}
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getCxxVsHeaderPathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
@@ -6,6 +6,7 @@
namespace utility
{
std::shared_ptr<CombinedPathDetector> getJavaRuntimePathDetector();
std::shared_ptr<CombinedPathDetector> getMavenExecutablePathDetector();
std::shared_ptr<CombinedPathDetector> getCxxVsHeaderPathDetector();
std::shared_ptr<CombinedPathDetector> getCxxHeaderPathDetector();
+3
View File
@@ -16,6 +16,9 @@ add_files(
data/parser/java/JavaEnvironmentFactory.cpp
data/parser/java/JavaEnvironmentFactory.h
utility/utilityMaven.cpp
utility/utilityMaven.h
JavaProject.cpp
JavaProject.h
ProjectFactoryModuleJava.cpp
+73 -12
View File
@@ -5,14 +5,20 @@
#include "data/parser/java/JavaEnvironmentFactory.h"
#include "data/parser/java/JavaEnvironment.h"
#include "utility/file/FileRegister.h"
#include "utility/text/TextAccess.h"
#include "utility/file/FileSystem.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/text/TextAccess.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityMaven.h"
#include "utility/utilityString.h"
#include "Application.h"
#include "settings/ApplicationSettings.h"
#include "utility/tracing.h"
#include "utility/ScopedFunctor.h"
JavaProject::JavaProject(
std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
)
: Project(storageAccessProxy, dialogView)
, m_projectSettings(projectSettings)
@@ -67,17 +73,52 @@ bool JavaProject::prepareIndexing()
if (!JavaEnvironmentFactory::getInstance())
{
std::string dialogMessage =
"Coati was unable to locate Java on this machine.\nPlease make sure to provide the correct Java Path in the preferences.";
"Coati was unable to locate Java on this machine.\n"
"Please make sure to provide the correct Java Path in the preferences.";
if (errorString.size() > 0)
{
dialogMessage += "\n\nError: " + errorString;
}
MessageStatus(dialogMessage, true, false).dispatch();
Application::getInstance()->handleDialog(dialogMessage);
return false;
}
if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists())
{
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
ScopedFunctor dialogHider([this](){
getDialogView()->hideStatusDialog();
});
getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files");
bool success = utility::mavenGenerateSources(
mavenPath, projectRootPath
);
if (!success)
{
const std::string dialogMessage =
"Coati was unable to locate Maven on this machine.\n"
"Please make sure to provide the correct Maven Path in the preferences.";
MessageStatus(dialogMessage, true, false).dispatch();
Application::getInstance()->handleDialog(dialogMessage);
return false;
}
getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies");
utility::mavenCopyDependencies(
mavenPath, projectRootPath, m_projectSettings->getAbsoluteMavenDependenciesDirectory()
);
}
return true;
}
@@ -85,7 +126,7 @@ std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
{
std::vector<FilePath> classPath;
for (FilePath p: m_projectSettings->getAbsoluteClasspaths())
for (const FilePath& p: m_projectSettings->getAbsoluteClasspaths())
{
if (p.exists())
{
@@ -93,6 +134,18 @@ std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
}
}
if (m_projectSettings->getAbsoluteMavenDependenciesDirectory().exists())
{
const std::vector<std::string> dependencies = FileSystem::getFileNamesFromDirectory(
m_projectSettings->getAbsoluteMavenDependenciesDirectory().str(),
std::vector<std::string>(1, ".jar")
);
for (const std::string& dependency: dependencies)
{
classPath.push_back(dependency);
}
}
if (!m_rootDirectories)
{
getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories");
@@ -135,10 +188,23 @@ std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
return indexerCommands;
}
void JavaProject::updateFileManager(FileManager& fileManager)
{
std::vector<FilePath> sourcePaths = m_projectSettings->getAbsoluteSourcePaths();
std::vector<FilePath> sourcePaths;
if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists())
{
getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories");
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_projectSettings->getShouldIndexMavenTests());
getDialogView()->hideStatusDialog();
}
else
{
sourcePaths = m_projectSettings->getAbsoluteSourcePaths();
}
std::vector<FilePath> headerPaths = sourcePaths;
std::vector<std::string> sourceExtensions = m_projectSettings->getSourceExtensions();
std::vector<FilePath> excludePaths = m_projectSettings->getAbsoluteExcludePaths();
@@ -151,12 +217,7 @@ void JavaProject::fetchRootDirectories()
m_rootDirectories = std::make_shared<std::set<FilePath>>();
FileManager fileManager;
fileManager.setPaths(
m_projectSettings->getAbsoluteSourcePaths(),
std::vector<FilePath>(),
m_projectSettings->getAbsoluteExcludePaths(),
m_projectSettings->getSourceExtensions()
);
updateFileManager(fileManager);
FileManager::FileSets fileSets = fileManager.fetchFilePaths(std::vector<FileInfo>());
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
+1 -1
View File
@@ -12,7 +12,7 @@ public:
JavaProject(
std::shared_ptr<JavaProjectSettings> projectSettings,
StorageAccessProxy* storageAccessProxy,
DialogView* dialogView
std::shared_ptr<DialogView> dialogView
);
virtual ~JavaProject();
+1 -1
View File
@@ -13,7 +13,7 @@ LanguageType ProjectFactoryModuleJava::getLanguage() const
}
std::shared_ptr<Project> ProjectFactoryModuleJava::createProject(
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
)
{
return std::shared_ptr<JavaProject>(new JavaProject(
+1 -1
View File
@@ -10,7 +10,7 @@ public:
virtual LanguageType getLanguage() const;
virtual std::shared_ptr<Project> createProject(
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
);
};
+104
View File
@@ -0,0 +1,104 @@
#include "utility/utilityMaven.h"
#include "utility/text/TextAccess.h"
#include "utility/utilityApp.h"
#include "utility/utilityString.h"
#include "utility/utilityXml.h"
#include "utility/utility.h"
namespace utility
{
bool mavenGenerateSources(const FilePath& mavenPath, const FilePath& projectDirectoryPath)
{
const std::string output = utility::executeProcess(
mavenPath.str() + " generate-sources",
projectDirectoryPath.str()
);
return !output.empty();
}
bool mavenCopyDependencies(const FilePath& mavenPath, const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath)
{
const std::string output = utility::executeProcess(
mavenPath.str() + " dependency:copy-dependencies -DoutputDirectory=" + outputDirectoryPath.str(),
projectDirectoryPath.str()
);
return !output.empty();
}
std::vector<FilePath> mavenGetAllDirectoriesFromEffectivePom(const FilePath& mavenPath, const FilePath& projectDirectoryPath, bool addTestDirectories)
{
std::shared_ptr<TextAccess> outputAccess = TextAccess::createFromString(utility::executeProcess(
mavenPath.str() + " help:effective-pom",
projectDirectoryPath.str()
));
std::string xmlContent = "";
for (std::string line: outputAccess->getAllLines())
{
const std::string trimmedLine = utility::trim(line);
if (!trimmedLine.empty() && trimmedLine.front() == '<')
{
xmlContent.append(line);
}
}
std::shared_ptr<TextAccess> xmlAccess = TextAccess::createFromString(xmlContent);
std::vector<FilePath> directories;
std::vector<FilePath> uncheckedDirectories;
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("project", "build", "sourceDirectory")))
{
uncheckedDirectories.push_back(FilePath(value));
}
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("projects", "project", "build", "sourceDirectory")))
{
uncheckedDirectories.push_back(FilePath(value));
}
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("project", "build", "directory")))
{
uncheckedDirectories.push_back(FilePath(value).concat("generated-sources"));
}
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("projects", "project", "build", "directory")))
{
uncheckedDirectories.push_back(FilePath(value).concat("generated-sources"));
}
if (addTestDirectories)
{
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("project", "build", "testSourceDirectory")))
{
uncheckedDirectories.push_back(FilePath(value));
}
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("projects", "project", "build", "testSourceDirectory")))
{
uncheckedDirectories.push_back(FilePath(value));
}
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("project", "build", "directory")))
{
uncheckedDirectories.push_back(FilePath(value).concat("generated-test-sources"));
}
for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements<std::string>("projects", "project", "build", "directory")))
{
uncheckedDirectories.push_back(FilePath(value).concat("generated-test-sources"));
}
}
for (const FilePath& uncheckedDirectory: uncheckedDirectories)
{
if (uncheckedDirectory.exists())
{
directories.push_back(uncheckedDirectory);
}
}
return directories;
}
}
+13
View File
@@ -0,0 +1,13 @@
#ifndef UTILITY_MAVEN_H
#define UTILITY_MAVEN_H
#include "utility/file/FilePath.h"
namespace utility
{
bool mavenGenerateSources(const FilePath& mavenPath, const FilePath& projectDirectoryPath);
bool mavenCopyDependencies(const FilePath& mavenPath, const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath);
std::vector<FilePath> mavenGetAllDirectoriesFromEffectivePom(const FilePath& mavenPath, const FilePath& projectDirectoryPath, bool addTestDirectories);
}
#endif // UTILITY_MAVEN_H