logic: used wstring in FilePath constructor
* used wstring in FilePath constructor where easily possible * added FilePath concatenate method that accepts string parameter * implemented using only wstring in MessageStatus * used wstring in config
This commit is contained in:
@@ -27,7 +27,7 @@ void JavaEnvironmentFactory::createInstance(std::string classPath, std::string&
|
||||
}
|
||||
|
||||
std::function<jint (JavaVM**, void**, void*)> createInstanceFunction;
|
||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||
const FilePath javaPath = ApplicationSettings::getInstance()->getJavaPath();
|
||||
createInstanceFunction = utility::loadFunctionFromLibrary<jint, JavaVM**, void**, void*>(
|
||||
javaPath,
|
||||
"JNI_CreateJavaVM",
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/utilityJava.h"
|
||||
#include "utility/utilityQString.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupJava::SourceGroupJava()
|
||||
@@ -63,7 +65,7 @@ std::shared_ptr<const SourceGroupSettings> SourceGroupJava::getSourceGroupSettin
|
||||
|
||||
bool SourceGroupJava::prepareJavaEnvironment()
|
||||
{
|
||||
const std::string errorString = utility::prepareJavaEnvironment();
|
||||
const std::wstring errorString = utility::decodeFromUtf8(utility::prepareJavaEnvironment());
|
||||
|
||||
if (errorString.size() > 0)
|
||||
{
|
||||
@@ -73,13 +75,13 @@ bool SourceGroupJava::prepareJavaEnvironment()
|
||||
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
std::string dialogMessage =
|
||||
"Sourcetrail was unable to locate Java on this machine.\n"
|
||||
std::wstring dialogMessage =
|
||||
L"Sourcetrail was unable to locate Java on this machine.\n"
|
||||
"Please make sure to provide the correct Java Path in the preferences.";
|
||||
|
||||
if (errorString.size() > 0)
|
||||
if (!errorString.empty())
|
||||
{
|
||||
dialogMessage += "\n\nError: " + errorString;
|
||||
dialogMessage += L"\n\nError: " + errorString;
|
||||
}
|
||||
|
||||
MessageStatus(dialogMessage, true, false).dispatch();
|
||||
@@ -163,7 +165,7 @@ std::set<FilePath> SourceGroupJava::fetchRootDirectories() const
|
||||
const std::vector<std::string> packageNameParts = utility::splitToVector(packageName, ".");
|
||||
for (std::vector<std::string>::const_reverse_iterator it = packageNameParts.rbegin(); it != packageNameParts.rend(); it++)
|
||||
{
|
||||
if (rootPath.fileName() != (*it))
|
||||
if (rootPath.wFileName() != utility::decodeFromUtf8(*it))
|
||||
{
|
||||
success = false;
|
||||
break;
|
||||
|
||||
@@ -105,8 +105,8 @@ bool SourceGroupJavaMaven::prepareMavenData()
|
||||
|
||||
if (!success)
|
||||
{
|
||||
const std::string dialogMessage =
|
||||
"Sourcetrail was unable to locate Maven on this machine.\n"
|
||||
const std::wstring dialogMessage =
|
||||
L"Sourcetrail was unable to locate Maven on this machine.\n"
|
||||
"Please make sure to provide the correct Maven Path in the preferences.";
|
||||
|
||||
MessageStatus(dialogMessage, true, false).dispatch();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace
|
||||
{
|
||||
if (getenv("JAVA_HOME") == nullptr)
|
||||
{
|
||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||
const FilePath javaPath = ApplicationSettings::getInstance()->getJavaPath();
|
||||
const FilePath javaHomePath = javaPath.getParentDirectory().getParentDirectory().getParentDirectory();
|
||||
|
||||
LOG_WARNING("Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process.");
|
||||
|
||||
@@ -6,29 +6,28 @@
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::vector<std::string> getRequiredJarNames()
|
||||
std::vector<std::wstring> getRequiredJarNames()
|
||||
{
|
||||
std::vector<std::string> jarNames = {
|
||||
"gradle-tooling-api-4.2.jar",
|
||||
"java-indexer.jar",
|
||||
"org.eclipse.core.commands-3.9.0.jar",
|
||||
"org.eclipse.core.contenttype-3.6.0.jar",
|
||||
"org.eclipse.core.expressions-3.6.0.jar",
|
||||
"org.eclipse.core.filesystem-1.7.0.jar",
|
||||
"org.eclipse.core.jobs-3.9.2.jar",
|
||||
"org.eclipse.core.resources-3.12.0.jar",
|
||||
"org.eclipse.core.runtime-3.13.0.jar",
|
||||
"org.eclipse.equinox.app-1.3.400.jar",
|
||||
"org.eclipse.equinox.common-3.9.0.jar",
|
||||
"org.eclipse.equinox.preferences-3.7.0.jar",
|
||||
"org.eclipse.equinox.registry-3.7.0.jar",
|
||||
"org.eclipse.jdt.core-3.13.0.jar",
|
||||
"org.eclipse.osgi-3.12.50.jar",
|
||||
"org.eclipse.text-3.6.100.jar",
|
||||
"slf4j-api-1.7.10.jar",
|
||||
"slf4j-simple-1.7.10.jar"
|
||||
return {
|
||||
L"gradle-tooling-api-4.2.jar",
|
||||
L"java-indexer.jar",
|
||||
L"org.eclipse.core.commands-3.9.0.jar",
|
||||
L"org.eclipse.core.contenttype-3.6.0.jar",
|
||||
L"org.eclipse.core.expressions-3.6.0.jar",
|
||||
L"org.eclipse.core.filesystem-1.7.0.jar",
|
||||
L"org.eclipse.core.jobs-3.9.2.jar",
|
||||
L"org.eclipse.core.resources-3.12.0.jar",
|
||||
L"org.eclipse.core.runtime-3.13.0.jar",
|
||||
L"org.eclipse.equinox.app-1.3.400.jar",
|
||||
L"org.eclipse.equinox.common-3.9.0.jar",
|
||||
L"org.eclipse.equinox.preferences-3.7.0.jar",
|
||||
L"org.eclipse.equinox.registry-3.7.0.jar",
|
||||
L"org.eclipse.jdt.core-3.13.0.jar",
|
||||
L"org.eclipse.osgi-3.12.50.jar",
|
||||
L"org.eclipse.text-3.6.100.jar",
|
||||
L"slf4j-api-1.7.10.jar",
|
||||
L"slf4j-simple-1.7.10.jar"
|
||||
};
|
||||
return jarNames;
|
||||
}
|
||||
|
||||
std::string prepareJavaEnvironment()
|
||||
@@ -45,14 +44,14 @@ namespace utility
|
||||
|
||||
std::string classPath = "";
|
||||
{
|
||||
const std::vector<std::string> jarNames = getRequiredJarNames();
|
||||
const std::vector<std::wstring> jarNames = getRequiredJarNames();
|
||||
for (size_t i = 0; i < jarNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
classPath += separator;
|
||||
}
|
||||
classPath += ResourcePaths::getJavaPath().str() + "lib/" + jarNames[i];
|
||||
classPath += ResourcePaths::getJavaPath().concatenate(L"lib/" + jarNames[i]).str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class FilePath;
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::vector<std::string> getRequiredJarNames();
|
||||
std::vector<std::wstring> getRequiredJarNames();
|
||||
std::string prepareJavaEnvironment();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace
|
||||
{
|
||||
if (getenv("JAVA_HOME") == nullptr)
|
||||
{
|
||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||
const FilePath javaPath = ApplicationSettings::getInstance()->getJavaPath();
|
||||
const FilePath javaHomePath = javaPath.getParentDirectory().getParentDirectory().getParentDirectory();
|
||||
|
||||
LOG_WARNING("Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process.");
|
||||
@@ -165,9 +165,9 @@ namespace utility
|
||||
fetchDirectories(uncheckedDirectories, xmlAccess,
|
||||
utility::createVectorFromElements<std::string>("projects", "project", "build", "sourceDirectory"));
|
||||
fetchDirectories(uncheckedDirectories, xmlAccess,
|
||||
utility::createVectorFromElements<std::string>("project", "build", "directory"), FilePath("generated-sources"));
|
||||
utility::createVectorFromElements<std::string>("project", "build", "directory"), FilePath(L"generated-sources"));
|
||||
fetchDirectories(uncheckedDirectories, xmlAccess,
|
||||
utility::createVectorFromElements<std::string>("projects", "project", "build", "directory"), FilePath("generated-sources"));
|
||||
utility::createVectorFromElements<std::string>("projects", "project", "build", "directory"), FilePath(L"generated-sources"));
|
||||
|
||||
if (addTestDirectories)
|
||||
{
|
||||
@@ -176,9 +176,9 @@ namespace utility
|
||||
fetchDirectories(uncheckedDirectories, xmlAccess,
|
||||
utility::createVectorFromElements<std::string>("projects", "project", "build", "testSourceDirectory"));
|
||||
fetchDirectories(uncheckedDirectories, xmlAccess,
|
||||
utility::createVectorFromElements<std::string>("project", "build", "directory"), FilePath("generated-test-sources"));
|
||||
utility::createVectorFromElements<std::string>("project", "build", "directory"), FilePath(L"generated-test-sources"));
|
||||
fetchDirectories(uncheckedDirectories, xmlAccess,
|
||||
utility::createVectorFromElements<std::string>("projects", "project", "build", "directory"), FilePath("generated-test-sources"));
|
||||
utility::createVectorFromElements<std::string>("projects", "project", "build", "directory"), FilePath(L"generated-test-sources"));
|
||||
}
|
||||
|
||||
std::vector<FilePath> directories;
|
||||
|
||||
Reference in New Issue
Block a user