data: Option to run only C/C++ preprocessor when indexing (issue 297)
* Added as checkbox to indexing start dialog * Only shown for C/C++ projects * Files will be marked incomplete
This commit is contained in:
@@ -25,10 +25,10 @@ void DialogView::hideProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
DialogView::IndexMode DialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh
|
||||
){
|
||||
return INDEX_ABORT;
|
||||
DialogView::IndexingOptions DialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, DialogView::IndexingOptions options)
|
||||
{
|
||||
return IndexingOptions();
|
||||
}
|
||||
|
||||
void DialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
|
||||
@@ -11,11 +11,23 @@ class StorageAccess;
|
||||
class DialogView
|
||||
{
|
||||
public:
|
||||
enum IndexMode
|
||||
struct IndexingOptions
|
||||
{
|
||||
INDEX_ABORT,
|
||||
INDEX_REFRESH,
|
||||
INDEX_FULL
|
||||
IndexingOptions()
|
||||
: startIndexing(false)
|
||||
, fullRefreshVisible(false)
|
||||
, fullRefresh(false)
|
||||
, preprocessorOnlyVisible(false)
|
||||
, preprocessorOnly(false)
|
||||
{}
|
||||
|
||||
bool startIndexing;
|
||||
|
||||
bool fullRefreshVisible;
|
||||
bool fullRefresh;
|
||||
|
||||
bool preprocessorOnlyVisible;
|
||||
bool preprocessorOnly;
|
||||
};
|
||||
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
@@ -27,8 +39,8 @@ public:
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
virtual IndexMode startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh);
|
||||
virtual IndexingOptions startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, IndexingOptions options);
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath);
|
||||
virtual void finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
|
||||
@@ -57,7 +57,7 @@ std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::in
|
||||
|
||||
parserClient->resetStorage();
|
||||
|
||||
if (parserClient->hasFatalErrors())
|
||||
if (parserClient->hasFatalErrors() || indexerCommand->preprocessorOnly())
|
||||
{
|
||||
storage->setAllFilesIncomplete();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ public:
|
||||
bool cancelOnFatalErrors() const;
|
||||
void setCancelOnFatalErrors(bool cancelOnFatalErrors);
|
||||
|
||||
virtual bool preprocessorOnly() const = 0;
|
||||
virtual void setPreprocessorOnly(bool preprocessorOnly) = 0;
|
||||
|
||||
private:
|
||||
FilePath m_sourceFilePath;
|
||||
std::set<FilePath> m_indexedPaths;
|
||||
|
||||
+30
-16
@@ -336,33 +336,45 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
}
|
||||
|
||||
std::set<FilePath> filesToIndex;
|
||||
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
sourceGroup->fetchSourceFilePathsToIndex(staticSourceFilePaths);
|
||||
utility::append(filesToIndex, sourceGroup->getSourceFilePathsToIndex());
|
||||
}
|
||||
|
||||
|
||||
bool hasCXXSourceGroup = false;
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
if (sourceGroup->getLanguage() == LANGUAGE_C || sourceGroup->getLanguage() == LANGUAGE_CPP)
|
||||
{
|
||||
hasCXXSourceGroup = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool fullRefresh = forceRefresh | needsFullRefresh;
|
||||
bool preprocessorOnly = false;
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
DialogView::IndexMode mode = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(),
|
||||
forceRefresh, needsFullRefresh
|
||||
);
|
||||
DialogView::IndexingOptions options;
|
||||
options.fullRefreshVisible = !needsFullRefresh;
|
||||
options.fullRefresh = forceRefresh;
|
||||
|
||||
switch (mode)
|
||||
options.preprocessorOnlyVisible = hasCXXSourceGroup;
|
||||
options.preprocessorOnly = false;
|
||||
|
||||
options = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(), options);
|
||||
|
||||
if (!options.startIndexing)
|
||||
{
|
||||
case DialogView::INDEX_ABORT:
|
||||
return false;
|
||||
case DialogView::INDEX_REFRESH:
|
||||
fullRefresh = false;
|
||||
break;
|
||||
case DialogView::INDEX_FULL:
|
||||
fullRefresh = true;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
fullRefresh = options.fullRefresh | needsFullRefresh;
|
||||
preprocessorOnly = options.preprocessorOnly;
|
||||
}
|
||||
|
||||
if (fullRefresh)
|
||||
@@ -379,12 +391,12 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
|
||||
MessageStatus((fullRefresh ? "Reindexing Project" : "Refreshing Project"), false, true).dispatch();
|
||||
|
||||
buildIndex(filesToClean, fullRefresh);
|
||||
buildIndex(filesToClean, fullRefresh, preprocessorOnly);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh)
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh, bool preprocessorOnly)
|
||||
{
|
||||
MessageClearErrorCount().dispatch();
|
||||
|
||||
@@ -414,6 +426,8 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
|
||||
for (std::shared_ptr<IndexerCommand> command: sourceGroup->getIndexerCommands(fullRefresh))
|
||||
{
|
||||
command->setCancelOnFatalErrors(cancelIndexingOnFatalErrors);
|
||||
command->setPreprocessorOnly(preprocessorOnly);
|
||||
|
||||
indexerCommandList->addCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public: // todo: make private again
|
||||
private:
|
||||
bool requestIndex(bool forceRefresh, bool needsFullRefresh);
|
||||
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh);
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh, bool preprocessorOnly);
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
|
||||
Reference in New Issue
Block a user