logic: only prefill application settings once
This commit is contained in:
+18
-5
@@ -60,8 +60,9 @@ void setupLogging()
|
|||||||
void prefillJavaRuntimePath()
|
void prefillJavaRuntimePath()
|
||||||
{
|
{
|
||||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
if (settings->getJavaPath().empty())
|
if (!settings->getHasPrefilledJavaPath() && settings->getJavaPath().empty())
|
||||||
{
|
{
|
||||||
|
LOG_INFO("Prefilling Java path");
|
||||||
std::shared_ptr<CombinedPathDetector> javaPathDetector = utility::getJavaRuntimePathDetector();
|
std::shared_ptr<CombinedPathDetector> javaPathDetector = utility::getJavaRuntimePathDetector();
|
||||||
std::vector<FilePath> paths = javaPathDetector->getPaths();
|
std::vector<FilePath> paths = javaPathDetector->getPaths();
|
||||||
if (!paths.empty())
|
if (!paths.empty())
|
||||||
@@ -76,13 +77,15 @@ void prefillJavaRuntimePath()
|
|||||||
MessageStatus(L"Ran Java runtime path detection, no path found.").dispatch();
|
MessageStatus(L"Ran Java runtime path detection, no path found.").dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settings->setHasPrefilledJavaPath(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prefillJreSystemLibraryPaths()
|
void prefillJreSystemLibraryPaths()
|
||||||
{
|
{
|
||||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
if (settings->getJreSystemLibraryPaths().empty())
|
if (!settings->getHasPrefilledJreSystemLibraryPaths() && settings->getJreSystemLibraryPaths().empty())
|
||||||
{
|
{
|
||||||
|
LOG_INFO("Prefilling JRE system library path");
|
||||||
std::shared_ptr<CombinedPathDetector> jreSystemLibraryPathsDetector = utility::getJreSystemLibraryPathsDetector();
|
std::shared_ptr<CombinedPathDetector> jreSystemLibraryPathsDetector = utility::getJreSystemLibraryPathsDetector();
|
||||||
std::vector<FilePath> paths = jreSystemLibraryPathsDetector->getPaths();
|
std::vector<FilePath> paths = jreSystemLibraryPathsDetector->getPaths();
|
||||||
if (!paths.empty())
|
if (!paths.empty())
|
||||||
@@ -97,13 +100,15 @@ void prefillJreSystemLibraryPaths()
|
|||||||
MessageStatus(L"Ran JRE system library path detection, no path found.").dispatch();
|
MessageStatus(L"Ran JRE system library path detection, no path found.").dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settings->setHasPrefilledJreSystemLibraryPaths(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prefillMavenExecutablePath()
|
void prefillMavenExecutablePath()
|
||||||
{
|
{
|
||||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
if (settings->getMavenPath().empty())
|
if (!settings->getHasPrefilledMavenPath() && settings->getMavenPath().empty())
|
||||||
{
|
{
|
||||||
|
LOG_INFO("Prefilling Maven path");
|
||||||
std::shared_ptr<CombinedPathDetector> mavenPathDetector = utility::getMavenExecutablePathDetector();
|
std::shared_ptr<CombinedPathDetector> mavenPathDetector = utility::getMavenExecutablePathDetector();
|
||||||
std::vector<FilePath> paths = mavenPathDetector->getPaths();
|
std::vector<FilePath> paths = mavenPathDetector->getPaths();
|
||||||
if (!paths.empty())
|
if (!paths.empty())
|
||||||
@@ -118,13 +123,15 @@ void prefillMavenExecutablePath()
|
|||||||
MessageStatus(L"Ran Maven executable path detection, no path found.").dispatch();
|
MessageStatus(L"Ran Maven executable path detection, no path found.").dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settings->setHasPrefilledMavenPath(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prefillCxxHeaderPaths()
|
void prefillCxxHeaderPaths()
|
||||||
{
|
{
|
||||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
if (settings->getHeaderSearchPaths().empty())
|
if (!settings->getHasPrefilledHeaderSearchPaths() && settings->getHeaderSearchPaths().empty())
|
||||||
{
|
{
|
||||||
|
LOG_INFO("Prefilling header search paths");
|
||||||
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
|
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
|
||||||
std::vector<FilePath> paths = cxxHeaderDetector->getPaths();
|
std::vector<FilePath> paths = cxxHeaderDetector->getPaths();
|
||||||
|
|
||||||
@@ -137,13 +144,15 @@ void prefillCxxHeaderPaths()
|
|||||||
settings->save();
|
settings->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settings->setHasPrefilledHeaderSearchPaths(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prefillCxxFrameworkPaths()
|
void prefillCxxFrameworkPaths()
|
||||||
{
|
{
|
||||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
if (settings->getFrameworkSearchPaths().empty())
|
if (!settings->getHasPrefilledFrameworkSearchPaths() && settings->getFrameworkSearchPaths().empty())
|
||||||
{
|
{
|
||||||
|
LOG_INFO("Prefilling framework search paths");
|
||||||
std::shared_ptr<CombinedPathDetector> cxxFrameworkDetector = utility::getCxxFrameworkPathDetector();
|
std::shared_ptr<CombinedPathDetector> cxxFrameworkDetector = utility::getCxxFrameworkPathDetector();
|
||||||
std::vector<FilePath> paths = cxxFrameworkDetector->getPaths();
|
std::vector<FilePath> paths = cxxFrameworkDetector->getPaths();
|
||||||
if (!paths.empty())
|
if (!paths.empty())
|
||||||
@@ -155,6 +164,7 @@ void prefillCxxFrameworkPaths()
|
|||||||
settings->save();
|
settings->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settings->setHasPrefilledFrameworkSearchPaths(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prefillPaths()
|
void prefillPaths()
|
||||||
@@ -164,6 +174,9 @@ void prefillPaths()
|
|||||||
prefillJreSystemLibraryPaths();
|
prefillJreSystemLibraryPaths();
|
||||||
prefillCxxHeaderPaths();
|
prefillCxxHeaderPaths();
|
||||||
prefillCxxFrameworkPaths();
|
prefillCxxFrameworkPaths();
|
||||||
|
|
||||||
|
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||||
|
settings->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLanguagePackages()
|
void addLanguagePackages()
|
||||||
|
|||||||
@@ -27,14 +27,6 @@ std::shared_ptr<ApplicationSettings> ApplicationSettings::getInstance()
|
|||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationSettings::ApplicationSettings()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationSettings::~ApplicationSettings()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ApplicationSettings::load(const FilePath& filePath, bool readOnly)
|
bool ApplicationSettings::load(const FilePath& filePath, bool readOnly)
|
||||||
{
|
{
|
||||||
bool loaded = Settings::load(filePath, readOnly);
|
bool loaded = Settings::load(filePath, readOnly);
|
||||||
@@ -352,6 +344,16 @@ void ApplicationSettings::setJavaPath(const FilePath& path)
|
|||||||
setValue<std::wstring>("indexing/java/java_path", path.wstr());
|
setValue<std::wstring>("indexing/java/java_path", path.wstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationSettings::getHasPrefilledJavaPath() const
|
||||||
|
{
|
||||||
|
return getValue<bool>("indexing/java/has_prefilled_java_path", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationSettings::setHasPrefilledJavaPath(bool v)
|
||||||
|
{
|
||||||
|
setValue<bool>("indexing/java/has_prefilled_java_path", v);
|
||||||
|
}
|
||||||
|
|
||||||
int ApplicationSettings::getJavaMaximumMemory() const
|
int ApplicationSettings::getJavaMaximumMemory() const
|
||||||
{
|
{
|
||||||
return getValue<int>("indexing/java/java_maximum_memory", -1);
|
return getValue<int>("indexing/java/java_maximum_memory", -1);
|
||||||
@@ -377,6 +379,16 @@ bool ApplicationSettings::setJreSystemLibraryPaths(const std::vector<FilePath>&
|
|||||||
return setPathValues("indexing/java/jre_system_library_paths/jre_system_library_path", jreSystemLibraryPaths);
|
return setPathValues("indexing/java/jre_system_library_paths/jre_system_library_path", jreSystemLibraryPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationSettings::getHasPrefilledJreSystemLibraryPaths() const
|
||||||
|
{
|
||||||
|
return getValue<bool>("indexing/java/has_prefilled_jre_system_library_paths", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationSettings::setHasPrefilledJreSystemLibraryPaths(bool v)
|
||||||
|
{
|
||||||
|
setValue<bool>("indexing/java/has_prefilled_jre_system_library_paths", v);
|
||||||
|
}
|
||||||
|
|
||||||
FilePath ApplicationSettings::getMavenPath() const
|
FilePath ApplicationSettings::getMavenPath() const
|
||||||
{
|
{
|
||||||
return FilePath(getValue<std::wstring>("indexing/java/maven_path", L""));
|
return FilePath(getValue<std::wstring>("indexing/java/maven_path", L""));
|
||||||
@@ -387,6 +399,16 @@ void ApplicationSettings::setMavenPath(const FilePath& path)
|
|||||||
setValue<std::wstring>("indexing/java/maven_path", path.wstr());
|
setValue<std::wstring>("indexing/java/maven_path", path.wstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationSettings::getHasPrefilledMavenPath() const
|
||||||
|
{
|
||||||
|
return getValue<bool>("indexing/java/has_prefilled_maven_path", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationSettings::setHasPrefilledMavenPath(bool v)
|
||||||
|
{
|
||||||
|
setValue<bool>("indexing/java/has_prefilled_maven_path", v);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
|
std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
|
||||||
{
|
{
|
||||||
return getPathValues("indexing/cxx/header_search_paths/header_search_path");
|
return getPathValues("indexing/cxx/header_search_paths/header_search_path");
|
||||||
@@ -402,6 +424,16 @@ bool ApplicationSettings::setHeaderSearchPaths(const std::vector<FilePath>& head
|
|||||||
return setPathValues("indexing/cxx/header_search_paths/header_search_path", headerSearchPaths);
|
return setPathValues("indexing/cxx/header_search_paths/header_search_path", headerSearchPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationSettings::getHasPrefilledHeaderSearchPaths() const
|
||||||
|
{
|
||||||
|
return getValue<bool>("indexing/cxx/has_prefilled_header_search_paths", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationSettings::setHasPrefilledHeaderSearchPaths(bool v)
|
||||||
|
{
|
||||||
|
setValue<bool>("indexing/cxx/has_prefilled_header_search_paths", v);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
|
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
|
||||||
{
|
{
|
||||||
return getPathValues("indexing/cxx/framework_search_paths/framework_search_path");
|
return getPathValues("indexing/cxx/framework_search_paths/framework_search_path");
|
||||||
@@ -417,6 +449,16 @@ bool ApplicationSettings::setFrameworkSearchPaths(const std::vector<FilePath>& f
|
|||||||
return setPathValues("indexing/cxx/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
return setPathValues("indexing/cxx/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationSettings::getHasPrefilledFrameworkSearchPaths() const
|
||||||
|
{
|
||||||
|
return getValue<bool>("indexing/cxx/has_prefilled_framework_search_paths", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationSettings::setHasPrefilledFrameworkSearchPaths(bool v)
|
||||||
|
{
|
||||||
|
setValue<bool>("indexing/cxx/has_prefilled_framework_search_paths", v);
|
||||||
|
}
|
||||||
|
|
||||||
int ApplicationSettings::getCodeTabWidth() const
|
int ApplicationSettings::getCodeTabWidth() const
|
||||||
{
|
{
|
||||||
return getValue<int>("code/tab_width", 4);
|
return getValue<int>("code/tab_width", 4);
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ public:
|
|||||||
|
|
||||||
static const size_t VERSION;
|
static const size_t VERSION;
|
||||||
|
|
||||||
ApplicationSettings();
|
ApplicationSettings() = default;
|
||||||
~ApplicationSettings();
|
|
||||||
|
|
||||||
bool load(const FilePath& filePath, bool readOnly = false);
|
bool load(const FilePath& filePath, bool readOnly = false);
|
||||||
|
|
||||||
@@ -97,6 +96,9 @@ public:
|
|||||||
FilePath getJavaPath() const;
|
FilePath getJavaPath() const;
|
||||||
void setJavaPath(const FilePath& path);
|
void setJavaPath(const FilePath& path);
|
||||||
|
|
||||||
|
bool getHasPrefilledJavaPath() const;
|
||||||
|
void setHasPrefilledJavaPath(bool v);
|
||||||
|
|
||||||
int getJavaMaximumMemory() const;
|
int getJavaMaximumMemory() const;
|
||||||
void setJavaMaximumMemory(int size);
|
void setJavaMaximumMemory(int size);
|
||||||
|
|
||||||
@@ -104,17 +106,29 @@ public:
|
|||||||
std::vector<FilePath> getJreSystemLibraryPathsExpanded() const;
|
std::vector<FilePath> getJreSystemLibraryPathsExpanded() const;
|
||||||
bool setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths);
|
bool setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths);
|
||||||
|
|
||||||
|
bool getHasPrefilledJreSystemLibraryPaths() const;
|
||||||
|
void setHasPrefilledJreSystemLibraryPaths(bool v);
|
||||||
|
|
||||||
FilePath getMavenPath() const;
|
FilePath getMavenPath() const;
|
||||||
void setMavenPath(const FilePath& path);
|
void setMavenPath(const FilePath& path);
|
||||||
|
|
||||||
|
bool getHasPrefilledMavenPath() const;
|
||||||
|
void setHasPrefilledMavenPath(bool v);
|
||||||
|
|
||||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||||
std::vector<FilePath> getHeaderSearchPathsExpanded() const;
|
std::vector<FilePath> getHeaderSearchPathsExpanded() const;
|
||||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||||
|
|
||||||
|
bool getHasPrefilledHeaderSearchPaths() const;
|
||||||
|
void setHasPrefilledHeaderSearchPaths(bool v);
|
||||||
|
|
||||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||||
std::vector<FilePath> getFrameworkSearchPathsExpanded() const;
|
std::vector<FilePath> getFrameworkSearchPathsExpanded() const;
|
||||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||||
|
|
||||||
|
bool getHasPrefilledFrameworkSearchPaths() const;
|
||||||
|
void setHasPrefilledFrameworkSearchPaths(bool v);
|
||||||
|
|
||||||
// code
|
// code
|
||||||
int getCodeTabWidth() const;
|
int getCodeTabWidth() const;
|
||||||
void setCodeTabWidth(int codeTabWidth);
|
void setCodeTabWidth(int codeTabWidth);
|
||||||
|
|||||||
Reference in New Issue
Block a user