logic: shallow python indexing (issue #725)
This commit is contained in:
@@ -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)",
|
||||
"<p>Enable a post processing step to solve unsolved references after the indexing is done. </p>"
|
||||
"<p>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 "
|
||||
|
||||
@@ -138,10 +138,11 @@ void QtDialogView::hideProgressDialog()
|
||||
}
|
||||
|
||||
void QtDialogView::startIndexingDialog(
|
||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode,
|
||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState,
|
||||
std::function<void(const RefreshInfo& info)> onStartIndexing, std::function<void()> 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<QtIndexingStartDialog>(enabledModes, initialMode);
|
||||
QtIndexingStartDialog* window = createWindow<QtIndexingStartDialog>(enabledModes, initialMode, enabledShallowOption, initialShallowState);
|
||||
|
||||
connect(window, &QtIndexingStartDialog::setShallowIndexing,
|
||||
[=](bool enabled)
|
||||
{
|
||||
m_shallowIndexingEnabled = enabled;
|
||||
}
|
||||
);
|
||||
|
||||
std::function<void(RefreshMode)> 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<TaskLambda>(
|
||||
[=]()
|
||||
{
|
||||
@@ -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<QtIndexingReportDialog>(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time, interrupted);
|
||||
QtIndexingReportDialog* window = createWindow<QtIndexingReportDialog>(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);
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
void hideProgressDialog() override;
|
||||
|
||||
void startIndexingDialog(
|
||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode,
|
||||
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState,
|
||||
std::function<void(const RefreshInfo& info)> onStartIndexing, std::function<void()> onCancelIndexing) override;
|
||||
void updateIndexingDialog(
|
||||
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths) override;
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& 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<std::wstring>& options) override;
|
||||
|
||||
@@ -78,6 +78,7 @@ private:
|
||||
QtThreadedLambdaFunctor m_onQtThread3;
|
||||
|
||||
std::map<RefreshMode, RefreshInfo> m_refreshInfos;
|
||||
bool m_shallowIndexingEnabled;
|
||||
|
||||
bool m_resultReady;
|
||||
bool m_uiBlocked = false;
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#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(
|
||||
"<i>You can now browse your project while running a second pass for in-depth indexing!</i>"
|
||||
);
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "QtIndexingStartDialog.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QRadioButton>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
|
||||
#include "QtHelpButton.h"
|
||||
|
||||
QtIndexingStartDialog::QtIndexingStartDialog(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, QWidget* parent)
|
||||
QtIndexingStartDialog::QtIndexingStartDialog(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState, QWidget* parent)
|
||||
: QtIndexingDialog(true, parent)
|
||||
{
|
||||
setSizeGripStyle(false);
|
||||
@@ -37,11 +38,18 @@ QtIndexingStartDialog::QtIndexingStartDialog(const std::vector<RefreshMode>& ena
|
||||
|
||||
QtHelpButton* helpButton = new QtHelpButton(
|
||||
"Indexing Modes",
|
||||
"<b>Updated files:</b> Reindexes all files that were modified since the last indexing, all files depending "
|
||||
"on those and new files.<br /><br />"
|
||||
"<b>Incomplete & updated files:</b> Reindexes all files that had errors during last indexing, all files "
|
||||
"depending on those and all updated files.<br /><br />"
|
||||
"<b>All files:</b> Deletes the previous index and reindexes all files.<br /><br />"
|
||||
QString("<b>Updated files:</b> Reindexes all files that were modified since the last indexing, all new files and all files depending "
|
||||
"on those.<br /><br />"
|
||||
"<b>Incomplete & updated files:</b> Reindexes all files that had errors during last indexing, all updated files and all files "
|
||||
"depending on those.<br /><br />"
|
||||
"<b>All files:</b> Deletes the previous index and reindexes all files from scratch.<br /><br />") +
|
||||
(enabledShallowOption ?
|
||||
"<br /><b>Shallow Python Indexing:</b> References within your code base (calls, usages, etc.) are resolved by name, which is "
|
||||
"imprecise but much faster than in-depth indexing.<br />"
|
||||
"<i>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.<br /><br />" :
|
||||
""
|
||||
)
|
||||
);
|
||||
helpButton->setColor(Qt::white);
|
||||
modeTitleLayout->addWidget(helpButton);
|
||||
@@ -91,6 +99,14 @@ QtIndexingStartDialog::QtIndexingStartDialog(const std::vector<RefreshMode>& 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);
|
||||
|
||||
|
||||
@@ -14,10 +14,11 @@ class QtIndexingStartDialog
|
||||
|
||||
signals:
|
||||
void setMode(RefreshMode mode);
|
||||
void setShallowIndexing(bool enabled);
|
||||
void startIndexing(RefreshMode mode);
|
||||
|
||||
public:
|
||||
QtIndexingStartDialog(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, QWidget* parent = 0);
|
||||
QtIndexingStartDialog(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, bool enabledShallowOption, bool initialShallowState, QWidget* parent = 0);
|
||||
QSize sizeHint() const override;
|
||||
|
||||
void updateRefreshInfo(const RefreshInfo& info);
|
||||
|
||||
Reference in New Issue
Block a user