logic: add auto-detection for JRE System Library

* fixed error columns are not saved to database correctly
* implemented setting JRE System Library paths in app settings
* added detector for JRE System Library that not use Java Runtime specified in AppSettings but detects JRE on its own by reusing the JavaPathDetector.
* added option to use JRE System Library in JavaSourceGroup
This commit is contained in:
malte_langkabel
2017-07-10 18:12:52 +02:00
parent b4166be89b
commit 9bcde198a5
23 changed files with 404 additions and 99 deletions
+1 -1
View File
@@ -265,7 +265,7 @@ Id SqliteIndexStorage::addError(const std::string& message, const FilePath& file
m_insertErrorStmt.bind(3, indexed);
m_insertErrorStmt.bind(4, filePath.str().c_str());
m_insertErrorStmt.bind(5, int(lineNumber));
m_insertErrorStmt.bind(5, int(columnNumber));
m_insertErrorStmt.bind(6, int(columnNumber));
const bool success = executeStatement(m_insertErrorStmt);
m_insertErrorStmt.reset();
+15
View File
@@ -276,6 +276,21 @@ void ApplicationSettings::setJavaMaximumMemory(int size)
setValue<int>("indexing/java/java_maximum_memory", size);
}
std::vector<FilePath> ApplicationSettings::getJreSystemLibraryPaths() const
{
return getPathValues("indexing/java/jre_system_library_paths/jre_system_library_path");
}
std::vector<FilePath> ApplicationSettings::getJreSystemLibraryPathsExpanded() const
{
return expandPaths(getJreSystemLibraryPaths());
}
bool ApplicationSettings::setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths)
{
return setPathValues("indexing/java/jre_system_library_paths/jre_system_library_path", jreSystemLibraryPaths);
}
FilePath ApplicationSettings::getMavenPath() const
{
return FilePath(getValue<std::string>("indexing/java/maven_path", ""));
+4
View File
@@ -82,6 +82,10 @@ public:
int getJavaMaximumMemory() const;
void setJavaMaximumMemory(int size);
std::vector<FilePath> getJreSystemLibraryPaths() const;
std::vector<FilePath> getJreSystemLibraryPathsExpanded() const;
bool setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths);
FilePath getMavenPath() const;
void setMavenPath(const FilePath& path);
+4 -2
View File
@@ -163,7 +163,8 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
case SOURCE_GROUP_JAVA_MAVEN:
{
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::make_shared<SourceGroupSettingsJava>(id, type, this);
javaSettings->setClasspaths(getPathValues(key + "/class_paths/class_path"));
javaSettings->setClasspath(getPathValues(key + "/class_paths/class_path"));
javaSettings->setUseJreSystemLibrary(getValue<bool>(key + "/use_jre_system_library", true));
if (type == SOURCE_GROUP_JAVA_MAVEN)
{
javaSettings->setMavenProjectFilePath(FilePath(getValue<std::string>(key + "/maven/project_file_path", "")));
@@ -237,7 +238,8 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector<std::shared_pt
case SOURCE_GROUP_JAVA_MAVEN:
if (std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(settings))
{
setPathValues(key + "/class_paths/class_path", javaSettings->getClasspaths());
setPathValues(key + "/class_paths/class_path", javaSettings->getClasspath());
setValue(key + "/use_jre_system_library", javaSettings->getUseJreSystemLibrary());
if (type == SOURCE_GROUP_JAVA_MAVEN)
{
+19 -8
View File
@@ -4,7 +4,7 @@
SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, type, projectSettings)
, m_classpaths(std::vector<FilePath>())
, m_classpath(std::vector<FilePath>())
, m_mavenProjectFilePath(FilePath())
, m_mavenDependenciesDirectory(FilePath())
, m_shouldIndexMavenTests(false)
@@ -22,7 +22,8 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other)
return (
otherJava &&
SourceGroupSettings::equals(other) &&
utility::isPermutation(m_classpaths, otherJava->m_classpaths) &&
utility::isPermutation(m_classpath, otherJava->m_classpath) &&
m_useJreSystemLibrary == otherJava->m_useJreSystemLibrary &&
m_mavenProjectFilePath == otherJava->m_mavenProjectFilePath &&
m_mavenDependenciesDirectory == otherJava->m_mavenDependenciesDirectory &&
m_shouldIndexMavenTests == otherJava->m_shouldIndexMavenTests
@@ -34,19 +35,29 @@ std::vector<std::string> SourceGroupSettingsJava::getAvailableLanguageStandards(
return std::vector<std::string>(1, "8");
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspaths() const
bool SourceGroupSettingsJava::getUseJreSystemLibrary() const
{
return m_classpaths;
return m_useJreSystemLibrary;
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspathsExpandedAndAbsolute() const
void SourceGroupSettingsJava::setUseJreSystemLibrary(bool useJreSystemLibrary)
{
return m_projectSettings->makePathsExpandedAndAbsolute(getClasspaths());
m_useJreSystemLibrary = useJreSystemLibrary;
}
void SourceGroupSettingsJava::setClasspaths(const std::vector<FilePath>& classpaths)
std::vector<FilePath> SourceGroupSettingsJava::getClasspath() const
{
m_classpaths = classpaths;
return m_classpath;
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspathExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getClasspath());
}
void SourceGroupSettingsJava::setClasspath(const std::vector<FilePath>& classpath)
{
m_classpath = classpath;
}
FilePath SourceGroupSettingsJava::getMavenProjectFilePath() const
+8 -4
View File
@@ -17,9 +17,12 @@ public:
virtual std::vector<std::string> getAvailableLanguageStandards() const;
std::vector<FilePath> getClasspaths() const;
std::vector<FilePath> getClasspathsExpandedAndAbsolute() const;
void setClasspaths(const std::vector<FilePath>& classpaths);
bool getUseJreSystemLibrary() const;
void setUseJreSystemLibrary(bool useJreSystemLibrary);
std::vector<FilePath> getClasspath() const;
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
void setClasspath(const std::vector<FilePath>& classpath);
FilePath getMavenProjectFilePath() const;
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
@@ -36,7 +39,8 @@ private:
virtual std::vector<std::string> getDefaultSourceExtensions() const;
virtual std::string getDefaultStandard() const;
std::vector<FilePath> m_classpaths;
bool m_useJreSystemLibrary;
std::vector<FilePath> m_classpath;
FilePath m_mavenProjectFilePath;
FilePath m_mavenDependenciesDirectory;
bool m_shouldIndexMavenTests;