diff --git a/src/lib/component/view/DialogView.cpp b/src/lib/component/view/DialogView.cpp index 906d613e..a915767d 100644 --- a/src/lib/component/view/DialogView.cpp +++ b/src/lib/component/view/DialogView.cpp @@ -42,7 +42,7 @@ void DialogView::hideProgressDialog() } void DialogView::startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshMode initialMode, + Project* project, const std::vector& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool shallow, std::function onStartIndexing, std::function onCancelIndexing) { } @@ -59,7 +59,7 @@ void DialogView::updateCustomIndexingDialog( DatabasePolicy DialogView::finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, - float time, ErrorCountInfo errorInfo, bool interrupted) + float time, ErrorCountInfo errorInfo, bool interrupted, bool shallow) { return DATABASE_POLICY_KEEP; // used in non-gui mode } diff --git a/src/lib/component/view/DialogView.h b/src/lib/component/view/DialogView.h index d7fbb719..ef8bee71 100644 --- a/src/lib/component/view/DialogView.h +++ b/src/lib/component/view/DialogView.h @@ -15,6 +15,7 @@ enum DatabasePolicy { DATABASE_POLICY_KEEP, DATABASE_POLICY_DISCARD, + DATABASE_POLICY_REFRESH, DATABASE_POLICY_UNKNOWN }; @@ -45,7 +46,7 @@ public: virtual void hideProgressDialog(); virtual void startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshMode initialMode, + Project* project, const std::vector& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool shallow, std::function onStartIndexing, std::function onCancelIndexing); virtual void updateIndexingDialog( size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths); @@ -53,7 +54,7 @@ public: size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths); virtual DatabasePolicy finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, - float time, ErrorCountInfo errorInfo, bool interrupted); + float time, ErrorCountInfo errorInfo, bool interrupted, bool shallow); int confirm(const std::wstring& message); virtual int confirm(const std::wstring& message, const std::vector& options); diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index 277eaf6f..f587a4e0 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -61,6 +61,9 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa bool interruptedIndexing = false; blackboard->get("interrupted_indexing", interruptedIndexing); + bool shallowIndexing = false; + blackboard->get("shallow_indexing", shallowIndexing); + ErrorCountInfo errorInfo = m_storage->getErrorCount(); std::wstring status; @@ -82,7 +85,8 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa stats.fileCount, time, errorInfo, - interruptedIndexing + interruptedIndexing, + shallowIndexing ); MessageIndexingStatus(false).dispatch(); @@ -95,6 +99,11 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa { blackboard->set("discard_database", true); } + else if (policy == DATABASE_POLICY_REFRESH) + { + blackboard->set("keep_database", true); + blackboard->set("refresh_database", true); + } return STATE_SUCCESS; } diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp index 4a89976b..2813cf2f 100644 --- a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp +++ b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp @@ -260,7 +260,7 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora std::vector unsolvedLocationIds; for (const StorageSourceLocation location : storage.getStorageSourceLocations()) { - if (intToLocationType(location.type) == LOCATION_UNSOLVED) + if (intToLocationType(location.type) == LOCATION_UNSOLVED) // FIXME: this doesn't catch unsolved qualifiers -> convert Qualifier location type to qualifier edge { unsolvedLocationIds.push_back(location.id); } @@ -286,9 +286,9 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora storage.setMode(SqliteIndexStorage::STORAGE_MODE_READ); std::vector dataToInsert; - std::set elementsToDelete; + std::vector occurrencesToDelete; locationCollection->forEachSourceLocationFile( - [&nodeNameToStorageNodes, &storage, &dataToInsert, &elementsToDelete](std::shared_ptr locationFile) + [&nodeNameToStorageNodes, &storage, &dataToInsert, &occurrencesToDelete](std::shared_ptr locationFile) { const FilePath filePath = locationFile->getFilePath(); if (filePath.empty()) @@ -305,7 +305,7 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora if (textAccess) { locationFile->forEachStartSourceLocation( - [textAccess, &nodeNameToStorageNodes, &storage, &dataToInsert, &elementsToDelete](const SourceLocation* startLoc) + [textAccess, &nodeNameToStorageNodes, &storage, &dataToInsert, &occurrencesToDelete](const SourceLocation* startLoc) { if (!startLoc) { @@ -319,23 +319,20 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora const std::wstring token = utility::decodeFromUtf8(textAccess->getLine(startLoc->getLineNumber()).substr(startLoc->getColumnNumber() - 1, endLoc->getColumnNumber() - startLoc->getColumnNumber() + 1)); - for (const Id tokenId : startLoc->getTokenIds()) + for (const Id elementId : startLoc->getTokenIds()) { - const StorageEdge edge = storage.getEdgeById(tokenId); + const StorageEdge edge = storage.getEdgeById(elementId); if (edge.id != 0) { for (const StorageNode& targetNode : nodeNameToStorageNodes[token]) { - if (Edge::intToType(edge.type) == Edge::EDGE_CALL && - ( - NodeType::intToType(targetNode.type) != NodeType::NODE_FUNCTION || - NodeType::intToType(targetNode.type) != NodeType::NODE_METHOD - ) - ){ + if (Edge::intToType(edge.type) == Edge::EDGE_INHERITANCE && + NodeType::intToType(targetNode.type) != NodeType::NODE_CLASS) + { continue; } dataToInsert.push_back({ StorageEdgeData(edge.type, edge.sourceNodeId, targetNode.id) , startLoc->getLocationId() }); - elementsToDelete.insert(edge.id); + occurrencesToDelete.push_back(StorageOccurrence(edge.id, startLoc->getLocationId())); } } } @@ -364,7 +361,15 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora storage.addOccurrence(StorageOccurrence(ambiguousEdgeIds[i], dataToInsert[i].sourceLocationId)); } storage.setMode(SqliteIndexStorage::STORAGE_MODE_CLEAR); - storage.removeElements(utility::toVector(elementsToDelete)); + + storage.removeOccurrences(occurrencesToDelete); + std::set edgeIds; + for (const StorageOccurrence& occurrence : occurrencesToDelete) + { + edgeIds.insert(occurrence.elementId); + } + storage.removeElementsWithoutOccurrences(utility::toVector(edgeIds)); + storage.finishInjection(); LOG_INFO("Finished Python post processing."); } diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 5a74e0bf..7573672f 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -165,6 +165,21 @@ void PersistentStorage::removeElements(const std::vector& ids) m_sqliteIndexStorage.removeElements(ids); } +void PersistentStorage::removeOccurrence(const StorageOccurrence& occurrence) +{ + m_sqliteIndexStorage.removeOccurrence(occurrence); +} + +void PersistentStorage::removeOccurrences(const std::vector& occurrences) +{ + m_sqliteIndexStorage.removeOccurrences(occurrences); +} + +void PersistentStorage::removeElementsWithoutOccurrences(const std::vector& elementIds) +{ + m_sqliteIndexStorage.removeElementsWithoutOccurrences(elementIds); +} + const std::vector& PersistentStorage::getStorageNodes() const { return m_storageData.nodes = m_sqliteIndexStorage.getAll(); diff --git a/src/lib/data/storage/PersistentStorage.h b/src/lib/data/storage/PersistentStorage.h index 738659a2..acf0ba87 100644 --- a/src/lib/data/storage/PersistentStorage.h +++ b/src/lib/data/storage/PersistentStorage.h @@ -40,6 +40,9 @@ public: void removeElement(const Id id); void removeElements(const std::vector& ids); + void removeOccurrence(const StorageOccurrence& occurrence); + void removeOccurrences(const std::vector& occurrences); + void removeElementsWithoutOccurrences(const std::vector& elementIds); const std::vector& getStorageNodes() const override; const std::vector& getStorageFiles() const override; diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index 3b08daa3..41f9c722 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -477,6 +477,28 @@ void SqliteIndexStorage::removeElements(const std::vector& ids) ); } +void SqliteIndexStorage::removeOccurrence(const StorageOccurrence& occurrence) +{ + executeStatement( + "DELETE FROM occurrence WHERE element_id = " + std::to_string(occurrence.elementId) + " AND source_location_id = " + std::to_string(occurrence.sourceLocationId) + ";" + ); +} + +void SqliteIndexStorage::removeOccurrences(const std::vector& occurrences) +{ + for (const StorageOccurrence& occurrence : occurrences) + { + removeOccurrence(occurrence); + } +} + +void SqliteIndexStorage::removeElementsWithoutOccurrences(const std::vector& elementIds) +{ + executeStatement( + "DELETE FROM element WHERE id IN (" + utility::join(utility::toStrings(elementIds), ',') + ") AND id NOT IN (SELECT element_id FROM occurrence);" + ); +} + void SqliteIndexStorage::removeElementsWithLocationInFiles( const std::vector& fileIds, std::function updateStatusCallback) { diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.h b/src/lib/data/storage/sqlite/SqliteIndexStorage.h index da04ccae..b24a97ce 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.h +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.h @@ -72,6 +72,9 @@ public: void removeElement(Id id); void removeElements(const std::vector& ids); + void removeOccurrence(const StorageOccurrence& occurrence); + void removeOccurrences(const std::vector& occurrences); + void removeElementsWithoutOccurrences(const std::vector& elementIds); void removeElementsWithLocationInFiles(const std::vector& fileIds, std::function updateStatusCallback); void removeAllErrors(); diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 59fb95dd..293909ac 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -26,6 +26,7 @@ #include "FileSystem.h" #include "MessageErrorCountClear.h" #include "MessageIndexingFinished.h" +#include "MessageIndexingShowDialog.h" #include "MessageIndexingStarted.h" #include "MessageIndexingStatus.h" #include "MessageRefresh.h" @@ -73,14 +74,14 @@ bool Project::isLoaded() const { switch (m_state) { - case PROJECT_STATE_EMPTY: - case PROJECT_STATE_LOADED: - case PROJECT_STATE_OUTDATED: - case PROJECT_STATE_NEEDS_MIGRATION: - return true; + case PROJECT_STATE_EMPTY: + case PROJECT_STATE_LOADED: + case PROJECT_STATE_OUTDATED: + case PROJECT_STATE_NEEDS_MIGRATION: + return true; - default: - break; + default: + break; } return false; @@ -354,6 +355,18 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr dialo refreshMode = REFRESH_UPDATED_FILES; } + bool allowsShallowIndexing = false; + for (const std::shared_ptr& sourceGroup : m_sourceGroups) + { + if (sourceGroup->getStatus() == SOURCE_GROUP_STATUS_ENABLED && sourceGroup->allowsShallowIndexing()) + { + allowsShallowIndexing = true; + break; + } + } + + const bool useShallowIndexing = allowsShallowIndexing && (!isLoaded() || m_state == PROJECT_STATE_EMPTY); + if (m_hasGUI) { std::vector enabledModes = { REFRESH_ALL_FILES }; @@ -362,7 +375,7 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr dialo enabledModes.insert(enabledModes.end(), { REFRESH_UPDATED_FILES, REFRESH_UPDATED_AND_INCOMPLETE_FILES }); } - dialogView->startIndexingDialog(this, enabledModes, refreshMode, + dialogView->startIndexingDialog(this, enabledModes, refreshMode, allowsShallowIndexing, useShallowIndexing, [this, dialogView](const RefreshInfo& info) { buildIndex(info, dialogView); @@ -453,7 +466,9 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie } else { + const bool shallow = info.shallow; info = getRefreshInfo(REFRESH_ALL_FILES); + info.shallow = shallow; } } @@ -476,6 +491,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie if (info.mode != REFRESH_ALL_FILES) { + // store the indexed data into the temp db but keep the current state to allow browsing while indexing FileSystem::copyFile(indexDbFilePath, tempIndexDbFilePath); } @@ -507,17 +523,18 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie if (sourceGroup->getType() == SOURCE_GROUP_CUSTOM_COMMAND || sourceGroup->getType() == SOURCE_GROUP_PYTHON_EMPTY) { - customIndexerCommandProvider->addProvider(sourceGroup->getIndexerCommandProvider(info.filesToIndex)); + customIndexerCommandProvider->addProvider(sourceGroup->getIndexerCommandProvider(info)); } else { - indexerCommandProvider->addProvider(sourceGroup->getIndexerCommandProvider(info.filesToIndex)); + indexerCommandProvider->addProvider(sourceGroup->getIndexerCommandProvider(info)); } } } size_t sourceFileCount = indexerCommandProvider->size() + customIndexerCommandProvider->size(); + taskSequential->addTask(std::make_shared>("shallow_indexing", info.shallow)); taskSequential->addTask(std::make_shared>("source_file_count", sourceFileCount)); taskSequential->addTask(std::make_shared>("indexed_source_file_count", 0)); taskSequential->addTask(std::make_shared>("interrupted_indexing", false)); @@ -670,6 +687,24 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie MessageIndexingFinished().dispatch(); })); + taskSequential->addTask(std::make_shared()->addChildTasks( + std::make_shared()->addChildTasks( + std::make_shared("refresh_database"), + std::make_shared([dialogView, this]() { + Task::dispatch(TabId::app(), std::make_shared([dialogView, this]() { + MessageIndexingShowDialog().dispatch(); + MessageRefresh().refreshAll().dispatch(); + })); + }) + ), + std::make_shared()->addChildTasks( + std::make_shared([this]() { + Task::dispatch(TabId::app(), std::make_shared([this]() { + })); + }) + ) + )); + taskSequential->setIsBackgroundTask(true); Task::dispatch(TabId::app(), taskSequential); diff --git a/src/lib/project/RefreshInfo.h b/src/lib/project/RefreshInfo.h index e8962bee..4c468761 100644 --- a/src/lib/project/RefreshInfo.h +++ b/src/lib/project/RefreshInfo.h @@ -20,6 +20,7 @@ struct RefreshInfo std::set nonIndexedFilesToClear; RefreshMode mode = REFRESH_NONE; + bool shallow = true; }; #endif // REFRESH_INFO_H diff --git a/src/lib/project/SourceGroup.cpp b/src/lib/project/SourceGroup.cpp index ed80ae70..3bc750ad 100644 --- a/src/lib/project/SourceGroup.cpp +++ b/src/lib/project/SourceGroup.cpp @@ -7,9 +7,9 @@ #include "SourceGroupSettings.h" #include "TaskLambda.h" -std::shared_ptr SourceGroup::getIndexerCommandProvider(const std::set& filesToIndex) const +std::shared_ptr SourceGroup::getIndexerCommandProvider(const RefreshInfo& info) const { - return std::make_shared(getIndexerCommands(filesToIndex)); + return std::make_shared(getIndexerCommands(info)); } std::shared_ptr SourceGroup::getPreIndexTask( @@ -43,6 +43,11 @@ bool SourceGroup::allowsPartialClearing() const return true; } +bool SourceGroup::allowsShallowIndexing() const +{ + return false; +} + std::set SourceGroup::filterToContainedSourceFilePath(const std::set& sourceFilePaths) const { std::set filteredSourceFilePaths; diff --git a/src/lib/project/SourceGroup.h b/src/lib/project/SourceGroup.h index 49e97b02..e79981b2 100644 --- a/src/lib/project/SourceGroup.h +++ b/src/lib/project/SourceGroup.h @@ -18,6 +18,8 @@ class SourceGroupSettings; class StorageProvider; class Task; +struct RefreshInfo; + class SourceGroup { public: @@ -25,11 +27,12 @@ public: virtual bool prepareIndexing(); virtual bool allowsPartialClearing() const; + virtual bool allowsShallowIndexing() const; virtual std::set filterToContainedFilePaths(const std::set& filePaths) const = 0; virtual std::set getAllSourceFilePaths() const = 0; - virtual std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const; - virtual std::vector> getIndexerCommands(const std::set& filesToIndex) const = 0; + virtual std::shared_ptr getIndexerCommandProvider(const RefreshInfo& info) const; + virtual std::vector> getIndexerCommands(const RefreshInfo& info) const = 0; virtual std::shared_ptr getPreIndexTask( std::shared_ptr storageProvider, std::shared_ptr dialogView) const; diff --git a/src/lib/project/SourceGroupCustomCommand.cpp b/src/lib/project/SourceGroupCustomCommand.cpp index 98040cb3..b0d81604 100644 --- a/src/lib/project/SourceGroupCustomCommand.cpp +++ b/src/lib/project/SourceGroupCustomCommand.cpp @@ -3,6 +3,7 @@ #include "FileManager.h" #include "IndexerCommandCustom.h" #include "ProjectSettings.h" +#include "RefreshInfo.h" #include "SourceGroupSettingsCustomCommand.h" #include "SqliteIndexStorage.h" #include "utility.h" @@ -38,7 +39,7 @@ std::set SourceGroupCustomCommand::getAllSourceFilePaths() const return fileManager.getAllSourceFilePaths(); } -std::vector> SourceGroupCustomCommand::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupCustomCommand::getIndexerCommands(const RefreshInfo& info) const { const std::wstring customCommand = m_settings->getCustomCommand(); const bool runInParallel = m_settings->getRunInParallel(); @@ -46,7 +47,7 @@ std::vector> SourceGroupCustomCommand::getIndexe std::vector> indexerCommands; for (const FilePath& sourcePath: getAllSourceFilePaths()) { - if (filesToIndex.find(sourcePath) != filesToIndex.end()) + if (info.filesToIndex.find(sourcePath) != info.filesToIndex.end()) { indexerCommands.push_back(std::make_shared( customCommand, diff --git a/src/lib/project/SourceGroupCustomCommand.h b/src/lib/project/SourceGroupCustomCommand.h index 1fc4c0c6..20271067 100644 --- a/src/lib/project/SourceGroupCustomCommand.h +++ b/src/lib/project/SourceGroupCustomCommand.h @@ -18,7 +18,7 @@ public: std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; private: std::shared_ptr getSourceGroupSettings() override; diff --git a/src/lib_cxx/project/SourceGroupCxxCdb.cpp b/src/lib_cxx/project/SourceGroupCxxCdb.cpp index f44b8ad7..06d8e8bb 100644 --- a/src/lib_cxx/project/SourceGroupCxxCdb.cpp +++ b/src/lib_cxx/project/SourceGroupCxxCdb.cpp @@ -80,7 +80,7 @@ std::set SourceGroupCxxCdb::getAllSourceFilePaths(std::shared_ptr SourceGroupCxxCdb::getIndexerCommandProvider(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxCdb::getIndexerCommandProvider(const RefreshInfo& info) const { std::shared_ptr provider = std::make_shared(); @@ -112,7 +112,7 @@ std::shared_ptr SourceGroupCxxCdb::getIndexerCommandProv } } - if (filesToIndex.find(sourcePath) != filesToIndex.end() && + if (info.filesToIndex.find(sourcePath) != info.filesToIndex.end() && sourceFilePaths.find(sourcePath) != sourceFilePaths.end()) { std::vector cdbFlags = utility::convert( @@ -143,9 +143,9 @@ std::shared_ptr SourceGroupCxxCdb::getIndexerCommandProv return provider; } -std::vector> SourceGroupCxxCdb::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupCxxCdb::getIndexerCommands(const RefreshInfo& info) const { - return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); + return getIndexerCommandProvider(info)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxCdb::getPreIndexTask( diff --git a/src/lib_cxx/project/SourceGroupCxxCdb.h b/src/lib_cxx/project/SourceGroupCxxCdb.h index ce829c7e..7d9e2a5a 100644 --- a/src/lib_cxx/project/SourceGroupCxxCdb.h +++ b/src/lib_cxx/project/SourceGroupCxxCdb.h @@ -25,8 +25,8 @@ public: std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; std::set getAllSourceFilePaths(std::shared_ptr cdb) const; - std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::shared_ptr getIndexerCommandProvider(const RefreshInfo& info) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; std::shared_ptr getPreIndexTask( std::shared_ptr storageProvider, std::shared_ptr dialogView) const override; diff --git a/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp b/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp index f20d8857..fe66583c 100644 --- a/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp +++ b/src/lib_cxx/project/SourceGroupCxxCodeblocks.cpp @@ -68,7 +68,7 @@ std::set SourceGroupCxxCodeblocks::getAllSourceFilePaths() const return sourceFilePaths; } -std::shared_ptr SourceGroupCxxCodeblocks::getIndexerCommandProvider(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxCodeblocks::getIndexerCommandProvider(const RefreshInfo& info) const { std::shared_ptr provider = std::make_shared(); @@ -78,7 +78,7 @@ std::shared_ptr SourceGroupCxxCodeblocks::getIndexerComm { for (std::shared_ptr indexerCommand: project->getIndexerCommands(m_settings, ApplicationSettings::getInstance())) { - if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end()) + if (info.filesToIndex.find(indexerCommand->getSourceFilePath()) != info.filesToIndex.end()) { provider->addCommand(indexerCommand); } @@ -87,9 +87,9 @@ std::shared_ptr SourceGroupCxxCodeblocks::getIndexerComm return provider; } -std::vector> SourceGroupCxxCodeblocks::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupCxxCodeblocks::getIndexerCommands(const RefreshInfo& info) const { - return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); + return getIndexerCommandProvider(info)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxCodeblocks::getSourceGroupSettings() diff --git a/src/lib_cxx/project/SourceGroupCxxCodeblocks.h b/src/lib_cxx/project/SourceGroupCxxCodeblocks.h index 3acafeed..e8589d34 100644 --- a/src/lib_cxx/project/SourceGroupCxxCodeblocks.h +++ b/src/lib_cxx/project/SourceGroupCxxCodeblocks.h @@ -17,8 +17,8 @@ public: bool prepareIndexing() override; std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::shared_ptr getIndexerCommandProvider(const RefreshInfo& info) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; private: std::shared_ptr getSourceGroupSettings() override; diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp index d25f38e2..969aaa5d 100644 --- a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp @@ -5,6 +5,7 @@ #include "FileManager.h" #include "IndexerCommandCxx.h" #include "logging.h" +#include "RefreshInfo.h" #include "SourceGroupSettingsCEmpty.h" #include "SourceGroupSettingsCppEmpty.h" #include "SourceGroupSettingsWithCppStandard.h" @@ -69,7 +70,7 @@ std::set SourceGroupCxxEmpty::getAllSourceFilePaths() const return fileManager.getAllSourceFilePaths(); } -std::shared_ptr SourceGroupCxxEmpty::getIndexerCommandProvider(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxEmpty::getIndexerCommandProvider(const RefreshInfo& info) const { std::set indexedPaths; std::set excludeFilters; @@ -93,7 +94,7 @@ std::shared_ptr SourceGroupCxxEmpty::getIndexerCommandPr std::shared_ptr provider = std::make_shared(); for (const FilePath& sourcePath: getAllSourceFilePaths()) { - if (filesToIndex.find(sourcePath) != filesToIndex.end()) + if (info.filesToIndex.find(sourcePath) != info.filesToIndex.end()) { provider->addCommand(std::make_shared( sourcePath, @@ -109,9 +110,9 @@ std::shared_ptr SourceGroupCxxEmpty::getIndexerCommandPr return provider; } -std::vector> SourceGroupCxxEmpty::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupCxxEmpty::getIndexerCommands(const RefreshInfo& info) const { - return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); + return getIndexerCommandProvider(info)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxEmpty::getPreIndexTask( diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.h b/src/lib_cxx/project/SourceGroupCxxEmpty.h index 45050b0f..2a0e6eee 100644 --- a/src/lib_cxx/project/SourceGroupCxxEmpty.h +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.h @@ -16,8 +16,8 @@ public: std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::shared_ptr getIndexerCommandProvider(const RefreshInfo& info) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; std::shared_ptr getPreIndexTask( std::shared_ptr storageProvider, std::shared_ptr dialogView) const override; diff --git a/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp b/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp index 227c7b9f..920eec59 100644 --- a/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp +++ b/src/lib_cxx/project/SourceGroupCxxSonargraph.cpp @@ -1,13 +1,13 @@ #include "SourceGroupCxxSonargraph.h" +#include "Application.h" +#include "ApplicationSettings.h" #include "CxxIndexerCommandProvider.h" #include "IndexerCommandCxx.h" -#include "ApplicationSettings.h" -#include "SourceGroupSettingsCxxSonargraph.h" #include "MessageStatus.h" +#include "SourceGroupSettingsCxxSonargraph.h" #include "SonargraphProject.h" #include "utility.h" -#include "Application.h" SourceGroupCxxSonargraph::SourceGroupCxxSonargraph(std::shared_ptr settings) : m_settings(settings) @@ -55,7 +55,7 @@ std::set SourceGroupCxxSonargraph::getAllSourceFilePaths() const return sourceFilePaths; } -std::shared_ptr SourceGroupCxxSonargraph::getIndexerCommandProvider(const std::set& filesToIndex) const +std::shared_ptr SourceGroupCxxSonargraph::getIndexerCommandProvider(const RefreshInfo& info) const { std::shared_ptr provider = std::make_shared(); if (std::shared_ptr project = Sonargraph::Project::load( @@ -66,7 +66,7 @@ std::shared_ptr SourceGroupCxxSonargraph::getIndexerComm { if (std::shared_ptr indexerCommandCxx = std::dynamic_pointer_cast(indexerCommand)) { - if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end()) + if (info.filesToIndex.find(indexerCommand->getSourceFilePath()) != info.filesToIndex.end()) { provider->addCommand(indexerCommandCxx); } @@ -76,9 +76,9 @@ std::shared_ptr SourceGroupCxxSonargraph::getIndexerComm return provider; } -std::vector> SourceGroupCxxSonargraph::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupCxxSonargraph::getIndexerCommands(const RefreshInfo& info) const { - return getIndexerCommandProvider(filesToIndex)->consumeAllCommands(); + return getIndexerCommandProvider(info)->consumeAllCommands(); } std::shared_ptr SourceGroupCxxSonargraph::getSourceGroupSettings() diff --git a/src/lib_cxx/project/SourceGroupCxxSonargraph.h b/src/lib_cxx/project/SourceGroupCxxSonargraph.h index 99a12f47..fb7dcbe9 100644 --- a/src/lib_cxx/project/SourceGroupCxxSonargraph.h +++ b/src/lib_cxx/project/SourceGroupCxxSonargraph.h @@ -17,8 +17,8 @@ public: bool prepareIndexing() override; std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::shared_ptr getIndexerCommandProvider(const std::set& filesToIndex) const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::shared_ptr getIndexerCommandProvider(const RefreshInfo& info) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; private: std::shared_ptr getSourceGroupSettings() override; diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp index cc5b5745..97f62935 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp @@ -372,7 +372,7 @@ void QtProjectWizardContentPreferences::populate(QGridLayout* layout, int& row) addTitle("Python", layout, row); m_pythonPostProcessing = addCheckBox("Post Processing", - "Add ambiguous edges for unsolved references", + "Add ambiguous edges for unsolved references (recommended)", "

Enable a post processing step to solve unsolved references after the indexing is done.

" "

These references will be marked \"ambiguous\" to indicate that some of these edges may never " "be encountered during runtime of the indexed code because the post processing only relies on " diff --git a/src/lib_gui/qt/view/QtDialogView.cpp b/src/lib_gui/qt/view/QtDialogView.cpp index 30cf7232..dd76849a 100644 --- a/src/lib_gui/qt/view/QtDialogView.cpp +++ b/src/lib_gui/qt/view/QtDialogView.cpp @@ -138,10 +138,11 @@ void QtDialogView::hideProgressDialog() } void QtDialogView::startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshMode initialMode, + Project* project, const std::vector& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState, std::function onStartIndexing, std::function onCancelIndexing) { m_refreshInfos.clear(); + m_shallowIndexingEnabled = initialShallowState; m_onQtThread( [=]() @@ -149,7 +150,14 @@ void QtDialogView::startIndexingDialog( m_dialogsVisible = true; m_windowStack.clearWindows(); - QtIndexingStartDialog* window = createWindow(enabledModes, initialMode); + QtIndexingStartDialog* window = createWindow(enabledModes, initialMode, enabledShallowOption, initialShallowState); + + connect(window, &QtIndexingStartDialog::setShallowIndexing, + [=](bool enabled) + { + m_shallowIndexingEnabled = enabled; + } + ); std::function onRefreshModeChanged = ( [=](RefreshMode refreshMode) @@ -200,6 +208,7 @@ void QtDialogView::startIndexingDialog( [=](RefreshMode refreshMode) { RefreshInfo info = m_refreshInfos.find(refreshMode)->second; + info.shallow = m_shallowIndexingEnabled; Task::dispatch(TabId::app(), std::make_shared( [=]() { @@ -288,7 +297,7 @@ void QtDialogView::updateCustomIndexingDialog( DatabasePolicy QtDialogView::finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, - float time, ErrorCountInfo errorInfo, bool interrupted) + float time, ErrorCountInfo errorInfo, bool interrupted, bool shallow) { DatabasePolicy policy = DATABASE_POLICY_UNKNOWN; m_resultReady = false; @@ -299,7 +308,7 @@ DatabasePolicy QtDialogView::finishedIndexingDialog( m_dialogsVisible = true; m_windowStack.clearWindows(); - QtIndexingReportDialog* window = createWindow(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time, interrupted); + QtIndexingReportDialog* window = createWindow(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time, interrupted, shallow); window->updateErrorCount(errorInfo.total, errorInfo.fatal); connect(window, &QtIndexingDialog::finished, [this, &policy]() @@ -317,6 +326,14 @@ DatabasePolicy QtDialogView::finishedIndexingDialog( m_resultReady = true; } ); + connect(window, &QtIndexingReportDialog::requestReindexing, + [this, &policy]() + { + setUIBlocked(false); + policy = DATABASE_POLICY_REFRESH; + m_resultReady = true; + } + ); m_mainWindow->hideWindowsTaskbarProgress(); setUIBlocked(true); diff --git a/src/lib_gui/qt/view/QtDialogView.h b/src/lib_gui/qt/view/QtDialogView.h index 34a8643f..8a8502ca 100644 --- a/src/lib_gui/qt/view/QtDialogView.h +++ b/src/lib_gui/qt/view/QtDialogView.h @@ -37,7 +37,7 @@ public: void hideProgressDialog() override; void startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshMode initialMode, + Project* project, const std::vector& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState, std::function onStartIndexing, std::function onCancelIndexing) override; void updateIndexingDialog( size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths) override; @@ -45,7 +45,7 @@ public: size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths) override; DatabasePolicy finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, - float time, ErrorCountInfo errorInfo, bool interrupted) override; + float time, ErrorCountInfo errorInfo, bool interrupted, bool shallow) override; int confirm(const std::wstring& message, const std::vector& options) override; @@ -78,6 +78,7 @@ private: QtThreadedLambdaFunctor m_onQtThread3; std::map m_refreshInfos; + bool m_shallowIndexingEnabled; bool m_resultReady; bool m_uiBlocked = false; diff --git a/src/lib_gui/qt/window/QtIndexingReportDialog.cpp b/src/lib_gui/qt/window/QtIndexingReportDialog.cpp index fa03c95e..8acee891 100644 --- a/src/lib_gui/qt/window/QtIndexingReportDialog.cpp +++ b/src/lib_gui/qt/window/QtIndexingReportDialog.cpp @@ -4,10 +4,12 @@ #include #include "MessageErrorsHelpMessage.h" +#include "MessageIndexingShowDialog.h" +#include "MessageRefresh.h" #include "TimeStamp.h" QtIndexingReportDialog::QtIndexingReportDialog( - size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted, QWidget* parent) + size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted, bool shallow, QWidget* parent) : QtIndexingDialog(true, parent) , m_interrupted(interrupted) { @@ -17,6 +19,10 @@ QtIndexingReportDialog::QtIndexingReportDialog( { QtIndexingDialog::createTitleLabel("Interrupted Indexing", m_layout); } + else if (shallow) + { + QtIndexingDialog::createTitleLabel("Finished Shallow Indexing", m_layout); + } else { QtIndexingDialog::createTitleLabel("Finished Indexing", m_layout); @@ -40,6 +46,14 @@ QtIndexingReportDialog::QtIndexingReportDialog( m_layout->addStretch(); + if (shallow) + { + createMessageLabel(m_layout)->setText( + "You can now browse your project while running a second pass for in-depth indexing!" + ); + m_layout->addSpacing(12); + } + { QHBoxLayout* buttons = new QHBoxLayout(); if (interrupted) @@ -49,10 +63,17 @@ QtIndexingReportDialog::QtIndexingReportDialog( connect(discardButton, &QPushButton::clicked, this, &QtIndexingReportDialog::onDiscardPressed); buttons->addWidget(discardButton); } + else if (shallow) + { + QPushButton* startInDepthButton = new QPushButton("Start In-Depth Indexing"); + startInDepthButton->setObjectName("windowButton"); + connect(startInDepthButton, &QPushButton::clicked, this, &QtIndexingReportDialog::onStartInDepthPressed); + buttons->addWidget(startInDepthButton); + } buttons->addStretch(); - QPushButton* confirmButton = new QPushButton(interrupted ? "Keep" : "OK"); + QPushButton* confirmButton = new QPushButton(interrupted ? "Keep" : (shallow ? "Quit" : "OK")); confirmButton->setObjectName("windowButton"); confirmButton->setDefault(true); connect(confirmButton, &QPushButton::clicked, this, &QtIndexingReportDialog::onConfirmPressed); @@ -128,3 +149,8 @@ void QtIndexingReportDialog::onDiscardPressed() { emit QtIndexingDialog::canceled(); } + +void QtIndexingReportDialog::onStartInDepthPressed() +{ + emit requestReindexing(); +} diff --git a/src/lib_gui/qt/window/QtIndexingReportDialog.h b/src/lib_gui/qt/window/QtIndexingReportDialog.h index 34455b6f..14e437af 100644 --- a/src/lib_gui/qt/window/QtIndexingReportDialog.h +++ b/src/lib_gui/qt/window/QtIndexingReportDialog.h @@ -8,8 +8,11 @@ class QtIndexingReportDialog { Q_OBJECT +signals : + void requestReindexing(); + public: - QtIndexingReportDialog(size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted, QWidget* parent = 0); + QtIndexingReportDialog(size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted, bool shallow, QWidget* parent = 0); QSize sizeHint() const override; void updateErrorCount(size_t errorCount, size_t fatalCount); @@ -21,6 +24,7 @@ protected: private: void onConfirmPressed(); void onDiscardPressed(); + void onStartInDepthPressed(); QWidget* m_errorWidget; bool m_interrupted; diff --git a/src/lib_gui/qt/window/QtIndexingStartDialog.cpp b/src/lib_gui/qt/window/QtIndexingStartDialog.cpp index 08ebf630..3e1bf757 100644 --- a/src/lib_gui/qt/window/QtIndexingStartDialog.cpp +++ b/src/lib_gui/qt/window/QtIndexingStartDialog.cpp @@ -1,12 +1,13 @@ #include "QtIndexingStartDialog.h" +#include #include -#include #include +#include #include "QtHelpButton.h" -QtIndexingStartDialog::QtIndexingStartDialog(const std::vector& enabledModes, const RefreshMode initialMode, QWidget* parent) +QtIndexingStartDialog::QtIndexingStartDialog(const std::vector& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState, QWidget* parent) : QtIndexingDialog(true, parent) { setSizeGripStyle(false); @@ -37,11 +38,18 @@ QtIndexingStartDialog::QtIndexingStartDialog(const std::vector& ena QtHelpButton* helpButton = new QtHelpButton( "Indexing Modes", - "Updated files: Reindexes all files that were modified since the last indexing, all files depending " - "on those and new files.

" - "Incomplete & updated files: Reindexes all files that had errors during last indexing, all files " - "depending on those and all updated files.

" - "All files: Deletes the previous index and reindexes all files.

" + QString("Updated files: Reindexes all files that were modified since the last indexing, all new files and all files depending " + "on those.

" + "Incomplete & updated files: Reindexes all files that had errors during last indexing, all updated files and all files " + "depending on those.

" + "All files: Deletes the previous index and reindexes all files from scratch.

") + + (enabledShallowOption ? + "
Shallow Python Indexing: References within your code base (calls, usages, etc.) are resolved by name, which is " + "imprecise but much faster than in-depth indexing.
" + "Hint: Use this option for a quick first indexing pass and start browsing the code base " + "while running a second pass for in-depth indexing.

" : + "" + ) ); helpButton->setColor(Qt::white); modeTitleLayout->addWidget(helpButton); @@ -91,6 +99,14 @@ QtIndexingStartDialog::QtIndexingStartDialog(const std::vector& ena m_refreshModeButtons[mode]->setEnabled(true); } + if (enabledShallowOption) + { + QCheckBox* shallowIndexingCheckBox = new QCheckBox("Shallow Python Indexing"); + connect(shallowIndexingCheckBox, &QCheckBox::toggled, [=]() { emit setShallowIndexing(shallowIndexingCheckBox->isChecked()); }); + shallowIndexingCheckBox->setChecked(initialShallowState); + modeLayout->addWidget(shallowIndexingCheckBox); + } + subLayout->addLayout(modeLayout); m_layout->addLayout(subLayout); diff --git a/src/lib_gui/qt/window/QtIndexingStartDialog.h b/src/lib_gui/qt/window/QtIndexingStartDialog.h index 0aaad08c..e81505a5 100644 --- a/src/lib_gui/qt/window/QtIndexingStartDialog.h +++ b/src/lib_gui/qt/window/QtIndexingStartDialog.h @@ -14,10 +14,11 @@ class QtIndexingStartDialog signals: void setMode(RefreshMode mode); + void setShallowIndexing(bool enabled); void startIndexing(RefreshMode mode); public: - QtIndexingStartDialog(const std::vector& enabledModes, const RefreshMode initialMode, QWidget* parent = 0); + QtIndexingStartDialog(const std::vector& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState, QWidget* parent = 0); QSize sizeHint() const override; void updateRefreshInfo(const RefreshInfo& info); diff --git a/src/lib_java/project/SourceGroupJava.cpp b/src/lib_java/project/SourceGroupJava.cpp index ff60d95a..de51384b 100644 --- a/src/lib_java/project/SourceGroupJava.cpp +++ b/src/lib_java/project/SourceGroupJava.cpp @@ -3,6 +3,7 @@ #include "IndexerCommandJava.h" #include "FileManager.h" #include "logging.h" +#include "RefreshInfo.h" #include "SourceGroupSettings.h" #include "SourceGroupSettingsWithExcludeFilters.h" #include "SourceGroupSettingsWithJavaStandard.h" @@ -33,7 +34,7 @@ std::set SourceGroupJava::getAllSourceFilePaths() const return fileManager.getAllSourceFilePaths(); } -std::vector> SourceGroupJava::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupJava::getIndexerCommands(const RefreshInfo& info) const { const std::wstring languageStandard = dynamic_cast(getSourceGroupSettings().get())->getJavaStandard(); @@ -43,7 +44,7 @@ std::vector> SourceGroupJava::getIndexerCommands std::vector> indexerCommands; for (const FilePath& sourcePath: getAllSourceFilePaths()) { - if (filesToIndex.find(sourcePath) != filesToIndex.end()) + if (info.filesToIndex.find(sourcePath) != info.filesToIndex.end()) { indexerCommands.push_back(std::make_shared( sourcePath, languageStandard, classPath diff --git a/src/lib_java/project/SourceGroupJava.h b/src/lib_java/project/SourceGroupJava.h index 9419a846..8fef4c47 100644 --- a/src/lib_java/project/SourceGroupJava.h +++ b/src/lib_java/project/SourceGroupJava.h @@ -13,7 +13,7 @@ class SourceGroupJava public: std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; private: virtual std::vector getAllSourcePaths() const = 0; diff --git a/src/lib_java/project/SourceGroupJavaSonargraph.cpp b/src/lib_java/project/SourceGroupJavaSonargraph.cpp index bc04c87d..464d0304 100644 --- a/src/lib_java/project/SourceGroupJavaSonargraph.cpp +++ b/src/lib_java/project/SourceGroupJavaSonargraph.cpp @@ -1,12 +1,13 @@ #include "SourceGroupJavaSonargraph.h" -#include "IndexerCommandJava.h" -#include "ApplicationSettings.h" -#include "SourceGroupSettingsJavaSonargraph.h" -#include "MessageStatus.h" -#include "SonargraphProject.h" -#include "utilityJava.h" #include "Application.h" +#include "ApplicationSettings.h" +#include "IndexerCommandJava.h" +#include "MessageStatus.h" +#include "RefreshInfo.h" +#include "SonargraphProject.h" +#include "SourceGroupSettingsJavaSonargraph.h" +#include "utilityJava.h" SourceGroupJavaSonargraph::SourceGroupJavaSonargraph(std::shared_ptr settings) : m_settings(settings) @@ -65,7 +66,7 @@ std::set SourceGroupJavaSonargraph::getAllSourceFilePaths() const return std::set(); } -std::vector> SourceGroupJavaSonargraph::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupJavaSonargraph::getIndexerCommands(const RefreshInfo& info) const { std::vector> indexerCommands; @@ -75,7 +76,7 @@ std::vector> SourceGroupJavaSonargraph::getIndex { for (std::shared_ptr indexerCommand : project->getIndexerCommands(m_settings, ApplicationSettings::getInstance())) { - if (filesToIndex.find(indexerCommand->getSourceFilePath()) != filesToIndex.end()) + if (info.filesToIndex.find(indexerCommand->getSourceFilePath()) != info.filesToIndex.end()) { indexerCommands.push_back(indexerCommand); } diff --git a/src/lib_java/project/SourceGroupJavaSonargraph.h b/src/lib_java/project/SourceGroupJavaSonargraph.h index c0584ad7..d92c2cbb 100644 --- a/src/lib_java/project/SourceGroupJavaSonargraph.h +++ b/src/lib_java/project/SourceGroupJavaSonargraph.h @@ -17,7 +17,7 @@ public: bool prepareIndexing() override; std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; private: std::shared_ptr getSourceGroupSettings() override; diff --git a/src/lib_python/project/SourceGroupPythonEmpty.cpp b/src/lib_python/project/SourceGroupPythonEmpty.cpp index 6403c420..e5bd7fac 100644 --- a/src/lib_python/project/SourceGroupPythonEmpty.cpp +++ b/src/lib_python/project/SourceGroupPythonEmpty.cpp @@ -4,6 +4,7 @@ #include "FileManager.h" #include "IndexerCommandCustom.h" #include "ProjectSettings.h" +#include "RefreshInfo.h" #include "ResourcePaths.h" #include "SourceGroupSettingsPythonEmpty.h" #include "SqliteIndexStorage.h" @@ -19,6 +20,12 @@ bool SourceGroupPythonEmpty::allowsPartialClearing() const return false; } +bool SourceGroupPythonEmpty::allowsShallowIndexing() const +{ + return true; +} + + std::set SourceGroupPythonEmpty::filterToContainedFilePaths(const std::set& filePaths) const { return SourceGroup::filterToContainedFilePaths( @@ -40,7 +47,7 @@ std::set SourceGroupPythonEmpty::getAllSourceFilePaths() const return fileManager.getAllSourceFilePaths(); } -std::vector> SourceGroupPythonEmpty::getIndexerCommands(const std::set& filesToIndex) const +std::vector> SourceGroupPythonEmpty::getIndexerCommands(const RefreshInfo& info) const { std::wstring args = L""; @@ -57,10 +64,15 @@ std::vector> SourceGroupPythonEmpty::getIndexerC args += L" --verbose"; } + if (info.shallow) + { + args += L" --shallow"; + } + std::vector> indexerCommands; for (const FilePath& sourceFilePath : getAllSourceFilePaths()) { - if (filesToIndex.find(sourceFilePath) != filesToIndex.end()) + if (info.filesToIndex.find(sourceFilePath) != info.filesToIndex.end()) { indexerCommands.push_back(std::make_shared( INDEXER_COMMAND_PYTHON, diff --git a/src/lib_python/project/SourceGroupPythonEmpty.h b/src/lib_python/project/SourceGroupPythonEmpty.h index a14fe8ea..5d38f9c3 100644 --- a/src/lib_python/project/SourceGroupPythonEmpty.h +++ b/src/lib_python/project/SourceGroupPythonEmpty.h @@ -14,9 +14,10 @@ public: SourceGroupPythonEmpty(std::shared_ptr settings); bool allowsPartialClearing() const override; + bool allowsShallowIndexing() const override; std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; - std::vector> getIndexerCommands(const std::set& filesToIndex) const override; + std::vector> getIndexerCommands(const RefreshInfo& info) const override; private: std::shared_ptr getSourceGroupSettings() override; diff --git a/src/test/RefreshInfoGeneratorTestSuite.cpp b/src/test/RefreshInfoGeneratorTestSuite.cpp index b4b8e138..d6accd0a 100644 --- a/src/test/RefreshInfoGeneratorTestSuite.cpp +++ b/src/test/RefreshInfoGeneratorTestSuite.cpp @@ -80,7 +80,7 @@ namespace return m_sourceFilePaths; } - std::vector> getIndexerCommands(const std::set& filesToIndex) const override + std::vector> getIndexerCommands(const RefreshInfo& info) const override { return std::vector>(); } diff --git a/src/test/SourceGroupTestSuite.cpp b/src/test/SourceGroupTestSuite.cpp index b310d62e..d065569e 100644 --- a/src/test/SourceGroupTestSuite.cpp +++ b/src/test/SourceGroupTestSuite.cpp @@ -157,7 +157,9 @@ namespace { const FilePath projectDataRoot = getInputDirectoryPath(projectName).makeAbsolute(); - std::vector> indexerCommands = sourceGroup->getIndexerCommands(sourceGroup->getAllSourceFilePaths()); + RefreshInfo info; + info.filesToIndex = sourceGroup->getAllSourceFilePaths(); + std::vector> indexerCommands = sourceGroup->getIndexerCommands(info); std::sort( indexerCommands.begin(),