logic: added project setup support for Sonargraph projects (Java and CMake-JSON modules supported)
* added classes for loading a Sonargraph project * added Sonargraph options to project setup wizard * added test for generating indexer commands from Sonargraph modules * fixed sqlite storage crashing in constructor when parent directory of provided path does not exist * removed unused FileRegister from Java indexing * removed unused info from IndexerCommandJava * refactored loading and saving of SourceGroupSettings * extracted sourcepaths settings to own class that can be re-used * merged CDB wizard contentents for source file and indexed paths * unified wizard content for sonargraph project path * removed include filters from default source groups * extracted generation of RefreshInfo from Project to RefreshInfoGenerator * added tests for RefreshInfoGenerator * added language and standard selection to sonargraph project setup * added auto-detection for indexed header paths of sonargraph cmake json modules * Sonargraph::Project can enable/disable support for specific modules * warn if sonargraph project contains no matching modules * indexed headers can be detected from sonargraph project
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
#include "utility/utilityGradle.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "settings/SourceGroupSettingsWithClasspath.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "Application.h"
|
||||
|
||||
namespace utility
|
||||
{
|
||||
@@ -63,4 +72,114 @@ namespace utility
|
||||
|
||||
return errorString;
|
||||
}
|
||||
|
||||
bool prepareJavaEnvironmentAndDisplayOccurringErrors()
|
||||
{
|
||||
const std::wstring errorString = utility::decodeFromUtf8(utility::prepareJavaEnvironment());
|
||||
|
||||
if (!errorString.empty())
|
||||
{
|
||||
LOG_ERROR(errorString);
|
||||
MessageStatus(errorString, true, false).dispatch();
|
||||
}
|
||||
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
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.empty())
|
||||
{
|
||||
dialogMessage += L"\n\nError: " + errorString;
|
||||
}
|
||||
|
||||
MessageStatus(dialogMessage, true, false).dispatch();
|
||||
|
||||
Application::getInstance()->handleDialog(dialogMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::set<FilePath> fetchRootDirectories(const std::set<FilePath>& sourceFilePaths)
|
||||
{
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gathering Root\nDirectories");
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView]() {
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
std::set<FilePath> rootDirectories;
|
||||
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
for (const FilePath& filePath : sourceFilePaths)
|
||||
{
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
|
||||
std::string packageName = "";
|
||||
javaEnvironment->callStaticStringMethod("com/sourcetrail/JavaIndexer", "getPackageName", packageName, textAccess->getText());
|
||||
|
||||
if (packageName.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FilePath rootPath = filePath.getParentDirectory();
|
||||
bool success = true;
|
||||
|
||||
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() != utility::decodeFromUtf8(*it))
|
||||
{
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
rootPath = rootPath.getParentDirectory();
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
rootDirectories.insert(rootPath);
|
||||
}
|
||||
}
|
||||
|
||||
return rootDirectories;
|
||||
}
|
||||
|
||||
std::vector<FilePath> getClassPath(std::shared_ptr<const SourceGroupSettingsWithClasspath> settings, const std::set<FilePath>& sourceFilePaths)
|
||||
{
|
||||
std::vector<FilePath> classPath;
|
||||
|
||||
for (const FilePath& classpath : settings->getClasspathExpandedAndAbsolute())
|
||||
{
|
||||
if (classpath.exists())
|
||||
{
|
||||
LOG_INFO(L"Adding path to classpath: " + classpath.wstr());
|
||||
classPath.push_back(classpath);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings->getUseJreSystemLibrary())
|
||||
{
|
||||
for (const FilePath& systemLibraryPath : ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded())
|
||||
{
|
||||
LOG_INFO(L"Adding JRE system library path to classpath: " + systemLibraryPath.wstr());
|
||||
classPath.push_back(systemLibraryPath);
|
||||
}
|
||||
}
|
||||
|
||||
for (const FilePath& rootDirectory : utility::fetchRootDirectories(sourceFilePaths))
|
||||
{
|
||||
if (rootDirectory.exists())
|
||||
{
|
||||
LOG_INFO(L"Adding root directory to classpath: " + rootDirectory.wstr());
|
||||
classPath.push_back(rootDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
return classPath;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user