forked from qt-creator/qt-creator
ClangCodeModel: Add menu action to re-index files
... that depend on changed headers. When changing a header file the clangd code model is not updated for files that including it if they are not opened in editor. This is not to be done automatically, as it would be a performance hazard to rescan many files, for example when changing a widely used header. Add a menu action to trigger such re-indexing manually to solve the issue. Task-number: QTCREATORBUG-27387 Change-Id: Ia8033401f847627cee041b102f9ac6f3af3dd709 Reviewed-by: Volodymyr Zibarov <gogan419@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
|
||||
#include <cppeditor/clangdiagnosticconfig.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
#include <cppeditor/cppmodelmanager.h>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
@@ -83,6 +84,20 @@ void ClangCodeModelPlugin::initialize()
|
||||
CppEditor::CppModelManager::activateClangCodeModel(std::make_unique<ClangModelManagerSupport>());
|
||||
createCompilationDBAction();
|
||||
|
||||
QAction * const updateStaleIndexEntries
|
||||
= new QAction(Tr::tr("Update potentially stale clangd index entries"), this);
|
||||
Command * const cmd = ActionManager::registerAction(updateStaleIndexEntries,
|
||||
"ClangCodeModel.UpdateStaleIndexEntries");
|
||||
connect(updateStaleIndexEntries, &QAction::triggered, this,
|
||||
[] { ClangModelManagerSupport::updateStaleIndexEntries(); });
|
||||
const QList<ActionContainer *> menus;
|
||||
namespace CppConstants = CppEditor::Constants;
|
||||
for (ActionContainer * const menu : {ActionManager::actionContainer(CppConstants::M_TOOLS_CPP),
|
||||
ActionManager::actionContainer(CppConstants::M_CONTEXT)}) {
|
||||
QTC_ASSERT(menu, continue);
|
||||
menu->addAction(cmd, CppEditor::Constants::G_GLOBAL);
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
addTest<Tests::ActivationSequenceProcessorTest>();
|
||||
addTest<Tests::ClangdTestCompletion>();
|
||||
|
||||
Reference in New Issue
Block a user