src: removed sonargraph based project setup methods
This commit is contained in:
@@ -24,8 +24,6 @@ add_files(
|
||||
project/SourceGroupJavaGradle.h
|
||||
project/SourceGroupJavaMaven.cpp
|
||||
project/SourceGroupJavaMaven.h
|
||||
project/SourceGroupJavaSonargraph.cpp
|
||||
project/SourceGroupJavaSonargraph.h
|
||||
|
||||
utility/utilityJava.cpp
|
||||
utility/utilityJava.h
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
#include "SourceGroupJavaEmpty.h"
|
||||
#include "SourceGroupJavaGradle.h"
|
||||
#include "SourceGroupJavaMaven.h"
|
||||
#include "SourceGroupJavaSonargraph.h"
|
||||
#include "SourceGroupSettingsJavaEmpty.h"
|
||||
#include "SourceGroupSettingsJavaGradle.h"
|
||||
#include "SourceGroupSettingsJavaMaven.h"
|
||||
#include "SourceGroupSettingsJavaSonargraph.h"
|
||||
|
||||
bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const
|
||||
{
|
||||
@@ -16,7 +14,6 @@ bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
case SOURCE_GROUP_JAVA_SONARGRAPH:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
@@ -39,9 +36,5 @@ std::shared_ptr<SourceGroup> SourceGroupFactoryModuleJava::createSourceGroup(std
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJavaMaven(javaSettings));
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsJavaSonargraph> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJavaSonargraph>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJavaSonargraph(javaSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
#include "SourceGroupJavaSonargraph.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "ApplicationSettings.h"
|
||||
#include "IndexerCommandJava.h"
|
||||
#include "MessageStatus.h"
|
||||
#include "RefreshInfo.h"
|
||||
#include "SonargraphProject.h"
|
||||
#include "SourceGroupSettingsJavaSonargraph.h"
|
||||
#include "utilityJava.h"
|
||||
|
||||
SourceGroupJavaSonargraph::SourceGroupJavaSonargraph(std::shared_ptr<SourceGroupSettingsJavaSonargraph> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupJavaSonargraph::prepareIndexing()
|
||||
{
|
||||
if (!utility::prepareJavaEnvironmentAndDisplayOccurringErrors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath sonargraphProjectPath = m_settings->getSonargraphProjectPathExpandedAndAbsolute();
|
||||
if (!sonargraphProjectPath.empty() && !sonargraphProjectPath.exists())
|
||||
{
|
||||
std::wstring error = L"Can't refresh project. The referenced Sonargraph project does not exist anymore: "
|
||||
+ sonargraphProjectPath.wstr();
|
||||
MessageStatus(error, true).dispatch();
|
||||
Application::getInstance()->handleDialog(error, { L"Ok" });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::set<FilePath> SourceGroupJavaSonargraph::filterToContainedFilePaths(const std::set<FilePath>& filePaths) const
|
||||
{
|
||||
std::set<FilePath> containedFilePaths;
|
||||
|
||||
const std::set<FilePath> indexedPaths = getAllSourceFilePaths();
|
||||
|
||||
for (const FilePath& filePath : filePaths)
|
||||
{
|
||||
for (const FilePath& indexedPath : indexedPaths)
|
||||
{
|
||||
if (indexedPath == filePath || indexedPath.contains(filePath))
|
||||
{
|
||||
containedFilePaths.insert(filePath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return containedFilePaths;
|
||||
}
|
||||
|
||||
std::set<FilePath> SourceGroupJavaSonargraph::getAllSourceFilePaths() const
|
||||
{
|
||||
if (std::shared_ptr<Sonargraph::Project> project = Sonargraph::Project::load(
|
||||
m_settings->getSonargraphProjectPathExpandedAndAbsolute(), getLanguage()
|
||||
))
|
||||
{
|
||||
// DONT CALL getIndexerCommands here because this would create an endless recursion due to hack...
|
||||
return project->getAllSourceFilePathsCanonical();
|
||||
}
|
||||
return std::set<FilePath>();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJavaSonargraph::getIndexerCommands(const RefreshInfo& info) const
|
||||
{
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
if (std::shared_ptr<Sonargraph::Project> project = Sonargraph::Project::load(
|
||||
m_settings->getSonargraphProjectPathExpandedAndAbsolute(), getLanguage()
|
||||
))
|
||||
{
|
||||
for (std::shared_ptr<IndexerCommand> indexerCommand : project->getIndexerCommands(m_settings, ApplicationSettings::getInstance()))
|
||||
{
|
||||
if (info.filesToIndex.find(indexerCommand->getSourceFilePath()) != info.filesToIndex.end())
|
||||
{
|
||||
indexerCommands.push_back(indexerCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!indexerCommands.empty())
|
||||
{
|
||||
// TODO: remove this hack once sourcegroup and sourcegroupsettings are merged
|
||||
const std::vector<FilePath> classPath = utility::getClassPath(
|
||||
m_settings->getClasspathExpandedAndAbsolute(), m_settings->getUseJreSystemLibrary(), getAllSourceFilePaths()
|
||||
);
|
||||
for (std::shared_ptr<IndexerCommand> indexerCommand : indexerCommands)
|
||||
{
|
||||
if (std::shared_ptr<IndexerCommandJava> javaIndexerCommand = std::dynamic_pointer_cast<IndexerCommandJava>(indexerCommand))
|
||||
{
|
||||
javaIndexerCommand->setClassPath(classPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettings> SourceGroupJavaSonargraph::getSourceGroupSettings()
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
std::shared_ptr<const SourceGroupSettings> SourceGroupJavaSonargraph::getSourceGroupSettings() const
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef SOURCE_GROUP_JAVA_SONARGRAPH_H
|
||||
#define SOURCE_GROUP_JAVA_SONARGRAPH_H
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "SourceGroup.h"
|
||||
|
||||
class SourceGroupSettingsJavaSonargraph;
|
||||
|
||||
class SourceGroupJavaSonargraph
|
||||
: public SourceGroup
|
||||
{
|
||||
public:
|
||||
SourceGroupJavaSonargraph(std::shared_ptr<SourceGroupSettingsJavaSonargraph> settings);
|
||||
|
||||
bool prepareIndexing() override;
|
||||
std::set<FilePath> filterToContainedFilePaths(const std::set<FilePath>& filePaths) const override;
|
||||
std::set<FilePath> getAllSourceFilePaths() const override;
|
||||
std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(const RefreshInfo& info) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
|
||||
std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const override;
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJavaSonargraph> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_JAVA_SONARGRAPH_H
|
||||
Reference in New Issue
Block a user