logic: source groups for project settings
* project can not have multiple source groups with different types * language of a project is now inferred from source groups * setting global NameHierarchy delimiter of first sourceGroup in project * added project settings migrations for source groups * Add Settings Migration classes (MoveKey, DeleteKey, Lambda) * Update sample projects with migrations * added method to config to retrieve sublevel key names * implemented recursive removing of keys in settings * moved project files out of top level * removed solution parsing code as it is not used anymore fortune cookie message = The secret of getting ahead is getting started.
This commit is contained in:
@@ -16,11 +16,11 @@ add_files(
|
||||
data/parser/java/JavaEnvironmentFactory.cpp
|
||||
data/parser/java/JavaEnvironmentFactory.h
|
||||
|
||||
project/SourceGroupJava.cpp
|
||||
project/SourceGroupJava.h
|
||||
project/SourceGroupFactoryModuleJava.cpp
|
||||
project/SourceGroupFactoryModuleJava.h
|
||||
|
||||
utility/utilityMaven.cpp
|
||||
utility/utilityMaven.h
|
||||
|
||||
JavaProject.cpp
|
||||
JavaProject.h
|
||||
ProjectFactoryModuleJava.cpp
|
||||
ProjectFactoryModuleJava.h
|
||||
)
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef JAVA_PROJECT_H
|
||||
#define JAVA_PROJECT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "Project.h"
|
||||
|
||||
class JavaProject: public Project
|
||||
{
|
||||
public:
|
||||
JavaProject(
|
||||
std::shared_ptr<JavaProjectSettings> projectSettings,
|
||||
StorageAccessProxy* storageAccessProxy,
|
||||
std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
virtual ~JavaProject();
|
||||
|
||||
protected:
|
||||
virtual std::shared_ptr<ProjectSettings> getProjectSettings();
|
||||
virtual const std::shared_ptr<ProjectSettings> getProjectSettings() const;
|
||||
|
||||
private:
|
||||
JavaProject(const JavaProject&);
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands();
|
||||
|
||||
virtual void updateFileManager(FileManager& fileManager);
|
||||
|
||||
void fetchRootDirectories();
|
||||
|
||||
std::shared_ptr<JavaProjectSettings> m_projectSettings;
|
||||
std::shared_ptr<std::set<FilePath>> m_rootDirectories;
|
||||
|
||||
friend Project;
|
||||
};
|
||||
|
||||
#endif // JAVA_PROJECT_H
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "ProjectFactoryModuleJava.h"
|
||||
|
||||
#include "settings/LanguageType.h"
|
||||
#include "JavaProject.h"
|
||||
|
||||
ProjectFactoryModuleJava::~ProjectFactoryModuleJava()
|
||||
{
|
||||
}
|
||||
|
||||
LanguageType ProjectFactoryModuleJava::getLanguage() const
|
||||
{
|
||||
return LANGUAGE_JAVA;
|
||||
}
|
||||
|
||||
std::shared_ptr<Project> ProjectFactoryModuleJava::createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
{
|
||||
return std::shared_ptr<JavaProject>(new JavaProject(
|
||||
std::make_shared<JavaProjectSettings>(projectSettingsFile), storageAccessProxy, dialogView));
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef PROJECT_FACTORY_MODULE_JAVA_H
|
||||
#define PROJECT_FACTORY_MODULE_JAVA_H
|
||||
|
||||
#include "ProjectFactoryModule.h"
|
||||
|
||||
class ProjectFactoryModuleJava: public ProjectFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~ProjectFactoryModuleJava();
|
||||
virtual LanguageType getLanguage() const;
|
||||
|
||||
virtual std::shared_ptr<Project> createProject(
|
||||
const FilePath& projectSettingsFile, StorageAccessProxy* storageAccessProxy, std::shared_ptr<DialogView> dialogView
|
||||
);
|
||||
};
|
||||
|
||||
#endif // PROJECT_FACTORY_MODULE_JAVA_H
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "project/SourceGroupFactoryModuleJava.h"
|
||||
|
||||
#include "project/SourceGroupJava.h"
|
||||
|
||||
SourceGroupFactoryModuleJava::~SourceGroupFactoryModuleJava()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleJava::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJava(javaSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_JAVA_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_JAVA_H
|
||||
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
class SourceGroupFactoryModuleJava: public SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModuleJava();
|
||||
virtual bool supports(SourceGroupType type) const;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_JAVA_H
|
||||
@@ -1,48 +1,116 @@
|
||||
#include "JavaProject.h"
|
||||
#include "project/SourceGroupJava.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/indexer/IndexerCommandJava.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityMaven.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/utility.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, std::shared_ptr<DialogView> dialogView
|
||||
)
|
||||
: Project(storageAccessProxy, dialogView)
|
||||
, m_projectSettings(projectSettings)
|
||||
SourceGroupJava::SourceGroupJava(std::shared_ptr<SourceGroupSettingsJava> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
JavaProject::~JavaProject()
|
||||
SourceGroupJava::~SourceGroupJava()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> JavaProject::getProjectSettings()
|
||||
SourceGroupType SourceGroupJava::getType() const
|
||||
{
|
||||
return m_projectSettings;
|
||||
return m_settings->getType();
|
||||
}
|
||||
|
||||
const std::shared_ptr<ProjectSettings> JavaProject::getProjectSettings() const
|
||||
bool SourceGroupJava::prepareIndexing()
|
||||
{
|
||||
return m_projectSettings;
|
||||
if (!prepareJavaEnvironment())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!prepareMavenData())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JavaProject::prepareIndexing()
|
||||
void SourceGroupJava::fetchAllSourceFilePaths()
|
||||
{
|
||||
m_rootDirectories.reset();
|
||||
std::vector<FilePath> sourcePaths;
|
||||
if (m_settings->getAbsoluteMavenProjectFilePath().exists())
|
||||
{
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
}
|
||||
|
||||
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
|
||||
const FilePath projectRootPath = m_settings->getAbsoluteMavenProjectFilePath().parentDirectory();
|
||||
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests());
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
Application::getInstance()->getDialogView()->hideStatusDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePaths = m_settings->getAbsoluteSourcePaths();
|
||||
}
|
||||
|
||||
m_sourceFilePathsToIndex.clear();
|
||||
FileManager fileManager;
|
||||
fileManager.update(sourcePaths, m_settings->getAbsoluteExcludePaths(), m_settings->getSourceExtensions());
|
||||
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands(const bool fullRefresh)
|
||||
{
|
||||
std::vector<FilePath> classPath = getClassPath();
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (FilePath p: m_settings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
indexedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (FilePath p: m_settings->getAbsoluteExcludePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
excludedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
const std::set<FilePath>& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex());
|
||||
for (const FilePath& sourcePath: sourceFilePathsToIndex)
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandJava>(sourcePath, indexedPaths, excludedPaths, classPath));
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
bool SourceGroupJava::prepareJavaEnvironment()
|
||||
{
|
||||
std::string errorString;
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
@@ -86,19 +154,23 @@ bool JavaProject::prepareIndexing()
|
||||
Application::getInstance()->handleDialog(dialogMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists())
|
||||
bool SourceGroupJava::prepareMavenData()
|
||||
{
|
||||
if (m_settings->getAbsoluteMavenProjectFilePath().exists())
|
||||
{
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
|
||||
const FilePath projectRootPath = m_settings->getAbsoluteMavenProjectFilePath().parentDirectory();
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
ScopedFunctor dialogHider([this](){
|
||||
getDialogView()->hideStatusDialog();
|
||||
ScopedFunctor dialogHider([](){
|
||||
Application::getInstance()->getDialogView()->hideStatusDialog();
|
||||
});
|
||||
|
||||
getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
bool success = utility::mavenGenerateSources(
|
||||
mavenPath, projectRootPath
|
||||
);
|
||||
@@ -115,21 +187,22 @@ bool JavaProject::prepareIndexing()
|
||||
return false;
|
||||
}
|
||||
|
||||
getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies");
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies");
|
||||
}
|
||||
utility::mavenCopyDependencies(
|
||||
mavenPath, projectRootPath, m_projectSettings->getAbsoluteMavenDependenciesDirectory()
|
||||
mavenPath, projectRootPath, m_settings->getAbsoluteMavenDependenciesDirectory()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
|
||||
|
||||
std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
{
|
||||
std::vector<FilePath> classPath;
|
||||
|
||||
for (const FilePath& p: m_projectSettings->getAbsoluteClasspaths())
|
||||
for (const FilePath& p: m_settings->getAbsoluteClasspaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
@@ -137,11 +210,11 @@ std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_projectSettings->getAbsoluteMavenDependenciesDirectory().exists())
|
||||
if (m_settings->getAbsoluteMavenDependenciesDirectory().exists())
|
||||
{
|
||||
const std::vector<std::string> dependencies = FileSystem::getFileNamesFromDirectory(
|
||||
m_projectSettings->getAbsoluteMavenDependenciesDirectory().str(),
|
||||
std::vector<std::string>(1, ".jar")
|
||||
m_settings->getAbsoluteMavenDependenciesDirectory().str(),
|
||||
utility::createVectorFromElements<std::string>(".jar")
|
||||
);
|
||||
for (const std::string& dependency: dependencies)
|
||||
{
|
||||
@@ -149,20 +222,7 @@ std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_rootDirectories)
|
||||
{
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories");
|
||||
}
|
||||
fetchRootDirectories();
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
getDialogView()->hideStatusDialog();
|
||||
}
|
||||
}
|
||||
|
||||
for (FilePath rootDirectory: *(m_rootDirectories.get()))
|
||||
for (FilePath rootDirectory: fetchRootDirectories())
|
||||
{
|
||||
if (rootDirectory.exists())
|
||||
{
|
||||
@@ -170,76 +230,20 @@ std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (FilePath p: m_projectSettings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
indexedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (FilePath p: m_projectSettings->getAbsoluteExcludePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
excludedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
for (const FilePath& sourcePath: getSourceFilePaths())
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandJava>(sourcePath, indexedPaths, excludedPaths, classPath));
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
return classPath;
|
||||
}
|
||||
|
||||
void JavaProject::updateFileManager(FileManager& fileManager)
|
||||
std::set<FilePath> SourceGroupJava::fetchRootDirectories()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists())
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
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());
|
||||
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
getDialogView()->hideStatusDialog();
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories");
|
||||
}
|
||||
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();
|
||||
|
||||
fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
std::set<FilePath> rootDirectories;
|
||||
|
||||
void JavaProject::fetchRootDirectories()
|
||||
{
|
||||
m_rootDirectories = std::make_shared<std::set<FilePath>>();
|
||||
|
||||
FileManager fileManager;
|
||||
updateFileManager(fileManager);
|
||||
|
||||
FileManager::FileSets fileSets = fileManager.fetchFilePaths(std::vector<FileInfo>());
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
|
||||
for (FilePath filePath: fileSets.addedFiles)
|
||||
for (FilePath filePath: m_allSourceFilePaths)
|
||||
{
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath.str());
|
||||
|
||||
@@ -267,7 +271,14 @@ void JavaProject::fetchRootDirectories()
|
||||
|
||||
if (success)
|
||||
{
|
||||
m_rootDirectories->insert(rootPath);
|
||||
rootDirectories.insert(rootPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
Application::getInstance()->getDialogView()->hideStatusDialog();
|
||||
}
|
||||
|
||||
return rootDirectories;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef SOURCE_GROUP_JAVA_H
|
||||
#define SOURCE_GROUP_JAVA_H
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "project/SourceGroup.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
class SourceGroupJava: public SourceGroup
|
||||
{
|
||||
public:
|
||||
SourceGroupJava(std::shared_ptr<SourceGroupSettingsJava> settings);
|
||||
virtual ~SourceGroupJava();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
virtual void fetchAllSourceFilePaths();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const bool fullRefresh);
|
||||
|
||||
private:
|
||||
bool prepareJavaEnvironment();
|
||||
bool prepareMavenData();
|
||||
|
||||
std::vector<FilePath> getClassPath();
|
||||
std::set<FilePath> fetchRootDirectories();
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJava> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_JAVA_H
|
||||
Reference in New Issue
Block a user