logic: use caching to speed up preparing gradle and maven projects for indexing

This commit is contained in:
mlangkabel
2019-10-18 13:05:27 +02:00
committed by Eberhard Graether
parent b631f3ddf7
commit e621a835fd
4 changed files with 53 additions and 35 deletions
+22 -16
View File
@@ -12,6 +12,7 @@
SourceGroupJavaGradle::SourceGroupJavaGradle(std::shared_ptr<SourceGroupSettingsJavaGradle> settings)
: m_settings(settings)
, m_allSourcePathsCache(std::bind(&SourceGroupJavaGradle::doGetAllSourcePaths, this))
{
}
@@ -32,22 +33,7 @@ bool SourceGroupJavaGradle::prepareIndexing()
std::vector<FilePath> SourceGroupJavaGradle::getAllSourcePaths() const
{
std::vector<FilePath> sourcePaths;
if (m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists())
{
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP);
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gradle\nFetching Source Directories");
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory();
sourcePaths = utility::gradleGetAllSourceDirectories(projectRootPath, m_settings->getShouldIndexGradleTests());
dialogView->hideUnknownProgressDialog();
}
else
{
LOG_INFO("Could not find any source paths because Gradle project path does not exist.");
}
return sourcePaths;
return m_allSourcePathsCache.getValue();
}
std::vector<FilePath> SourceGroupJavaGradle::doGetClassPath() const
@@ -107,3 +93,23 @@ bool SourceGroupJavaGradle::prepareGradleData()
return true;
}
std::vector<FilePath> SourceGroupJavaGradle::doGetAllSourcePaths() const
{
std::vector<FilePath> sourcePaths;
if (m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists())
{
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP);
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gradle\nFetching Source Directories");
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory();
sourcePaths = utility::gradleGetAllSourceDirectories(projectRootPath, m_settings->getShouldIndexGradleTests());
dialogView->hideUnknownProgressDialog();
}
else
{
LOG_INFO("Could not find any source paths because Gradle project path does not exist.");
}
return sourcePaths;
}
@@ -4,6 +4,7 @@
#include <memory>
#include <vector>
#include "SingleValueCache.h"
#include "SourceGroupJava.h"
class SourceGroupSettingsJavaGradle;
@@ -21,8 +22,10 @@ private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const override;
bool prepareGradleData();
std::vector<FilePath> doGetAllSourcePaths() const;
std::shared_ptr<SourceGroupSettingsJavaGradle> m_settings;
mutable SingleValueCache<std::vector<FilePath>> m_allSourcePathsCache;
};
#endif // SOURCE_GROUP_JAVA_GRADLE_H
+25 -19
View File
@@ -14,6 +14,7 @@
SourceGroupJavaMaven::SourceGroupJavaMaven(std::shared_ptr<SourceGroupSettingsJavaMaven> settings)
: m_settings(settings)
, m_allSourcePathsCache(std::bind(&SourceGroupJavaMaven::doGetAllSourcePaths, this))
{
}
@@ -34,25 +35,7 @@ bool SourceGroupJavaMaven::prepareIndexing()
std::vector<FilePath> SourceGroupJavaMaven::getAllSourcePaths() const
{
std::vector<FilePath> sourcePaths;
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
{
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP);
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nFetching Source Directories");
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(
mavenPath,
projectRootPath,
m_settings->getMavenDependenciesDirectoryPath(),
m_settings->getShouldIndexMavenTests()
);
dialogView->hideUnknownProgressDialog();
}
return sourcePaths;
return m_allSourcePathsCache.getValue();
}
std::vector<FilePath> SourceGroupJavaMaven::doGetClassPath() const
@@ -120,3 +103,26 @@ bool SourceGroupJavaMaven::prepareMavenData()
return true;
}
std::vector<FilePath> SourceGroupJavaMaven::doGetAllSourcePaths() const
{
std::vector<FilePath> sourcePaths;
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
{
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView(DialogView::UseCase::PROJECT_SETUP);
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nFetching Source Directories");
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(
mavenPath,
projectRootPath,
m_settings->getMavenDependenciesDirectoryPath(),
m_settings->getShouldIndexMavenTests()
);
dialogView->hideUnknownProgressDialog();
}
return sourcePaths;
}
@@ -4,6 +4,7 @@
#include <memory>
#include <vector>
#include "SingleValueCache.h"
#include "SourceGroupJava.h"
class SourceGroupSettingsJavaMaven;
@@ -20,8 +21,10 @@ private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<const SourceGroupSettings> getSourceGroupSettings() const override;
bool prepareMavenData();
std::vector<FilePath> doGetAllSourcePaths() const;
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
mutable SingleValueCache<std::vector<FilePath>> m_allSourcePathsCache;
};
#endif // SOURCE_GROUP_JAVA_MAVEN_H