logic: Don't store CxxCompilerHeaderPath in Global Include Paths

* show path in Global Include Paths preferences
* add to CXX indexer commands
* add migration to remove from app settings
This commit is contained in:
Eberhard Graether
2019-05-27 16:11:19 +02:00
parent 581b1894f2
commit b6a39a2d66
18 changed files with 1071 additions and 137 deletions
@@ -38,7 +38,6 @@
#include "ScopedFunctor.h"
#include "utility.h"
#include "utilityApp.h"
#include "utilityCxx.h"
#include "utilityFile.h"
#include "utilityPathDetection.h"
#include "utilityString.h"
@@ -1029,46 +1028,38 @@ void QtProjectWizzardContentPathsHeaderSearchGlobal::load()
void QtProjectWizzardContentPathsHeaderSearchGlobal::save()
{
ApplicationSettings::getInstance()->setHeaderSearchPaths(m_list->getPathsAsDisplayed());
std::vector<FilePath> paths;
for (const FilePath& headerPath : m_list->getPathsAsDisplayed())
{
if (headerPath != ResourcePaths::getCxxCompilerHeaderPath())
{
paths.push_back(headerPath);
}
}
ApplicationSettings::getInstance()->setHeaderSearchPaths(paths);
ApplicationSettings::getInstance()->save();
}
bool QtProjectWizzardContentPathsHeaderSearchGlobal::check()
{
bool hasCompilerHeaderPath = false;
if (utility::getOsType() == OS_WINDOWS)
{
return QtProjectWizzardContentPaths::check();
}
bool hasOtherCompilerConfig = false;
for (const FilePath& headerPath : m_list->getPathsAsDisplayed())
{
if (headerPath == ResourcePaths::getCxxCompilerHeaderPath())
{
hasCompilerHeaderPath = true;
}
else if (headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists())
if (headerPath != ResourcePaths::getCxxCompilerHeaderPath() &&
headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists())
{
hasOtherCompilerConfig = true;
break;
}
}
if (!hasCompilerHeaderPath)
{
QMessageBox msgBox;
msgBox.setText("Compiler Header Path missing");
msgBox.setInformativeText("Your Global Include Paths do not contain the path to the compiler headers of "
"Sourcetrail's C/C++ indexer. This can cause a lot of errors during indexing. Do you want to add the "
"path to the list?");
msgBox.addButton("Add", QMessageBox::ButtonRole::YesRole);
msgBox.addButton("Skip", QMessageBox::ButtonRole::NoRole);
msgBox.setIcon(QMessageBox::Icon::Question);
int ret = msgBox.exec();
if (ret == 0) // QMessageBox::Yes
{
m_list->addPaths({ ResourcePaths::getCxxCompilerHeaderPath() }, true);
hasCompilerHeaderPath = true;
}
}
if (utility::getOsType() != OS_WINDOWS && hasOtherCompilerConfig && hasCompilerHeaderPath)
if (hasOtherCompilerConfig)
{
QMessageBox msgBox;
msgBox.setText("Multiple Compiler Headers");
@@ -1086,11 +1077,12 @@ bool QtProjectWizzardContentPathsHeaderSearchGlobal::check()
std::vector<FilePath> paths;
for (const FilePath& headerPath : m_list->getPathsAsDisplayed())
{
if (headerPath == ResourcePaths::getCxxCompilerHeaderPath() ||
!headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists())
if (headerPath != ResourcePaths::getCxxCompilerHeaderPath() &&
headerPath.getCanonical().getConcatenated(L"/stdarg.h").exists())
{
paths.push_back(headerPath);
continue;
}
paths.push_back(headerPath);
}
setPaths(paths);
}
@@ -1101,27 +1093,22 @@ bool QtProjectWizzardContentPathsHeaderSearchGlobal::check()
void QtProjectWizzardContentPathsHeaderSearchGlobal::detectedPaths(const std::vector<FilePath>& paths)
{
setPaths(paths);
std::vector<FilePath> headerPaths;
for (const FilePath& headerPath : paths)
{
if (headerPath != ResourcePaths::getCxxCompilerHeaderPath())
{
headerPaths.push_back(headerPath);
}
}
setPaths(headerPaths);
}
void QtProjectWizzardContentPathsHeaderSearchGlobal::setPaths(const std::vector<FilePath>& paths)
{
m_list->setPaths({});
std::vector<FilePath> nonCxxCompilerHeaderPaths;
for (const FilePath& headerPath : paths)
{
if (headerPath == ResourcePaths::getCxxCompilerHeaderPath())
{
m_list->addPaths({ headerPath }, true);
}
else
{
nonCxxCompilerHeaderPaths.push_back(headerPath);
}
}
m_list->addPaths(nonCxxCompilerHeaderPaths);
m_list->addPaths({ ResourcePaths::getCxxCompilerHeaderPath() }, true);
m_list->addPaths(paths);
}
@@ -3,7 +3,6 @@
#include "FilePath.h"
#include "utilityCxxHeaderDetection.h"
#include "utilityString.h"
#include "utilityCxx.h"
CxxHeaderPathDetector::CxxHeaderPathDetector(const std::string& compilerName)
: PathDetector(compilerName)
@@ -8,7 +8,6 @@
#include "FilePath.h"
#include "utilityCxxHeaderDetection.h"
#include "utility.h"
#include "utilityCxx.h"
CxxVs10To14HeaderPathDetector::CxxVs10To14HeaderPathDetector(VisualStudioType type, bool isExpress, ApplicationArchitectureType architecture)
: PathDetector(visualStudioTypeToString(type) + (isExpress ? " Express" : "") + (architecture == APPLICATION_ARCHITECTURE_X86_64 ? " 64 Bit" : ""))
@@ -7,7 +7,6 @@
#include "utilityCxxHeaderDetection.h"
#include "utility.h"
#include "utilityApp.h"
#include "utilityCxx.h"
CxxVs15HeaderPathDetector::CxxVs15HeaderPathDetector()
: PathDetector("Visual Studio 2017")