Merge "Merge remote-tracking branch 'origin/11.0' into work"

This commit is contained in:
The Qt Project
2023-06-26 11:25:55 +00:00
27 changed files with 137 additions and 85 deletions

View File

@@ -5,7 +5,7 @@ add_qtc_library(Tasking OBJECT
SOURCES
barrier.cpp barrier.h
concurrentcall.h
networkquery.cpp
networkquery.cpp networkquery.h
tasking_global.h
tasktree.cpp tasktree.h
EXPLICIT_MOC

View File

@@ -263,15 +263,17 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
if (target->buildConfigurations().first()->buildType() != BuildConfiguration::BuildType::Release)
m_extraAppParams = runControl->commandLine().arguments();
if (auto aspect = runControl->aspect(Constants::ANDROID_AM_START_ARGS)) {
QTC_CHECK(aspect->value.typeId() == QVariant::String);
const QString startArgs = aspect->value.toString();
if (const QVariantMap sd = runControl->settingsData(Constants::ANDROID_AM_START_ARGS);
!sd.values().isEmpty()) {
QTC_CHECK(sd.first().type() == QVariant::String);
const QString startArgs = sd.first().toString();
m_amStartExtraArgs = ProcessArgs::splitArgs(startArgs, OsTypeOtherUnix);
}
if (auto aspect = runControl->aspect(Constants::ANDROID_PRESTARTSHELLCMDLIST)) {
QTC_CHECK(aspect->value.typeId() == QVariant::String);
const QStringList commands = aspect->value.toString().split('\n', Qt::SkipEmptyParts);
if (const QVariantMap sd = runControl->settingsData(Constants::ANDROID_PRESTARTSHELLCMDLIST);
!sd.values().isEmpty()) {
QTC_CHECK(sd.first().type() == QVariant::String);
const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts);
for (const QString &shellCmd : commands)
m_beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd));
}
@@ -279,9 +281,10 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
for (const QString &shellCmd : preStartCmdList.toStringList())
m_beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd));
if (auto aspect = runControl->aspect(Constants::ANDROID_POSTFINISHSHELLCMDLIST)) {
QTC_CHECK(aspect->value.typeId() == QVariant::String);
const QStringList commands = aspect->value.toString().split('\n', Qt::SkipEmptyParts);
if (const QVariantMap sd = runControl->settingsData(Constants::ANDROID_POSTFINISHSHELLCMDLIST);
!sd.values().isEmpty()) {
QTC_CHECK(sd.first().type() == QVariant::String);
const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts);
for (const QString &shellCmd : commands)
m_afterFinishAdbCommands.append(QString("shell %1").arg(shellCmd));
}

View File

@@ -57,9 +57,10 @@ FilePath ITestConfiguration::executableFilePath() const
if (!hasExecutable())
return {};
const Environment env = m_runnable.environment.hasChanges()
? m_runnable.environment : Environment::systemEnvironment();
return env.searchInPath(m_runnable.command.executable().path());
const Environment env = m_runnable.environment.appliedToEnvironment(
m_runnable.command.executable().deviceEnvironment());
return m_runnable.command.executable().searchInDirectories(env.path());
}
Environment ITestConfiguration::filteredEnvironment(const Environment &original) const

View File

@@ -350,8 +350,8 @@ static RunSettings runSettings()
return ClangToolsSettings::instance()->runSettings();
}
ClangTool::ClangTool(const QString &name, Utils::Id id)
: m_name(name), m_perspective{id.toString(), name}
ClangTool::ClangTool(const QString &name, Utils::Id id, ClangToolType type)
: m_name(name), m_perspective{id.toString(), name}, m_type(type)
{
setObjectName(name);
m_diagnosticModel = new ClangToolsDiagnosticModel(this);
@@ -830,8 +830,7 @@ static bool canAnalyzeProject(Project *project)
struct CheckResult {
enum {
InvalidTidyExecutable,
InvalidClazyExecutable,
InvalidExecutable,
ProjectNotOpen,
ProjectNotSuitable,
ReadyToAnalyze,
@@ -839,20 +838,13 @@ struct CheckResult {
QString errorText;
};
static CheckResult canAnalyze()
static CheckResult canAnalyze(ClangToolType type, const QString &name)
{
const ClangDiagnosticConfig config = diagnosticConfig(runSettings().diagnosticConfigId());
if (toolEnabled(ClangToolType::Tidy, config, runSettings())
&& !toolExecutable(ClangToolType::Tidy).isExecutableFile()) {
return {CheckResult::InvalidTidyExecutable,
Tr::tr("Set a valid Clang-Tidy executable.")};
}
if (toolEnabled(ClangToolType::Clazy, config, runSettings())
&& !toolExecutable(ClangToolType::Clazy).isExecutableFile()) {
return {CheckResult::InvalidClazyExecutable,
Tr::tr("Set a valid Clazy-Standalone executable.")};
if (toolEnabled(type, config, runSettings())
&& !toolExecutable(type).isExecutableFile()) {
return {CheckResult::InvalidExecutable, Tr::tr("Set a valid %1 executable.").arg(name)};
}
if (Project *project = ProjectManager::startupProject()) {
@@ -876,10 +868,9 @@ void ClangTool::updateForInitialState()
m_infoBarWidget->reset();
const CheckResult result = canAnalyze();
const CheckResult result = canAnalyze(m_type, m_name);
switch (result.kind)
case CheckResult::InvalidTidyExecutable: {
case CheckResult::InvalidClazyExecutable:
case CheckResult::InvalidExecutable: {
m_infoBarWidget->setError(InfoBarWidget::Warning, makeLink(result.errorText),
[] { ICore::showOptionsDialog(Constants::SETTINGS_PAGE_ID); });
break;
@@ -1084,7 +1075,7 @@ void ClangTool::updateForCurrentState()
QString startActionToolTip = m_startAction->text();
QString startOnCurrentToolTip = m_startOnCurrentFileAction->text();
if (!isRunning) {
const CheckResult result = canAnalyze();
const CheckResult result = canAnalyze(m_type, m_name);
canStart = result.kind == CheckResult::ReadyToAnalyze;
if (!canStart) {
startActionToolTip = result.errorText;
@@ -1171,11 +1162,12 @@ void ClangTool::updateForCurrentState()
m_infoBarWidget->setDiagText(diagText);
}
ClangTidyTool::ClangTidyTool() : ClangTool(Tr::tr("Clang-Tidy"), "ClangTidy.Perspective")
ClangTidyTool::ClangTidyTool() : ClangTool(Tr::tr("Clang-Tidy"), "ClangTidy.Perspective",
ClangToolType::Tidy)
{
m_instance = this;
}
ClazyTool::ClazyTool() : ClangTool(Tr::tr("Clazy"), "Clazy.Perspective")
ClazyTool::ClazyTool() : ClangTool(Tr::tr("Clazy"), "Clazy.Perspective", ClangToolType::Clazy)
{
m_instance = this;
}

View File

@@ -82,7 +82,7 @@ signals:
void finished(const QString &errorText); // For testing.
protected:
ClangTool(const QString &name, Utils::Id id);
ClangTool(const QString &name, Utils::Id id, CppEditor::ClangToolType type);
private:
enum class State {
@@ -154,6 +154,7 @@ private:
QAction *m_expandCollapse = nullptr;
Utils::Perspective m_perspective;
const CppEditor::ClangToolType m_type;
};
class ClangTidyTool : public ClangTool

View File

@@ -218,11 +218,11 @@ GroupItem clangToolTask(const AnalyzeInputData &input,
};
const Group group {
finishAllAndDone,
Storage(storage),
onGroupSetup(onSetup),
Group {
sequential,
finishAllAndDone,
ProcessTask(onProcessSetup, onProcessDone, onProcessError),
AsyncTask<expected_str<Diagnostics>>(onReadSetup, onReadDone, onReadError)
}

View File

@@ -15,6 +15,7 @@
#include <QAction>
using namespace TextEditor;
using namespace Utils;
namespace ClangTools {
namespace Internal {
@@ -22,37 +23,35 @@ namespace Internal {
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic, TextDocument *document)
: TextMark(document,
diagnostic.location.line,
{Tr::tr("Clang Tools"), Utils::Id(Constants::DIAGNOSTIC_MARK_ID)})
{Tr::tr("Clang Tools"), Id(Constants::DIAGNOSTIC_MARK_ID)})
, m_diagnostic(diagnostic)
{
setSettingsPage(Constants::SETTINGS_PAGE_ID);
if (diagnostic.type == "error" || diagnostic.type == "fatal")
setColor(Utils::Theme::CodeModel_Error_TextMarkColor);
else
setColor(Utils::Theme::CodeModel_Warning_TextMarkColor);
setPriority(TextEditor::TextMark::HighPriority);
const bool isError = diagnostic.type == "error" || diagnostic.type == "fatal";
setColor(isError ? Theme::CodeModel_Error_TextMarkColor : Theme::CodeModel_Warning_TextMarkColor);
setPriority(isError ? TextEditor::TextMark::HighPriority : TextEditor::TextMark::NormalPriority);
QIcon markIcon = diagnostic.icon();
setIcon(markIcon.isNull() ? Utils::Icons::CODEMODEL_WARNING.icon() : markIcon);
setIcon(markIcon.isNull() ? Icons::CODEMODEL_WARNING.icon() : markIcon);
setToolTip(createDiagnosticToolTipString(diagnostic, std::nullopt, true));
setLineAnnotation(diagnostic.description);
setActionsProvider([diagnostic] {
// Copy to clipboard action
QList<QAction *> actions;
QAction *action = new QAction();
action->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
action->setIcon(QIcon::fromTheme("edit-copy", Icons::COPY.icon()));
action->setToolTip(Tr::tr("Copy to Clipboard"));
QObject::connect(action, &QAction::triggered, [diagnostic] {
const QString text = createFullLocationString(diagnostic.location)
+ ": "
+ diagnostic.description;
Utils::setClipboardAndSelection(text);
setClipboardAndSelection(text);
});
actions << action;
// Disable diagnostic action
action = new QAction();
action->setIcon(Utils::Icons::BROKEN.icon());
action->setIcon(Icons::BROKEN.icon());
action->setToolTip(Tr::tr("Disable Diagnostic"));
QObject::connect(action, &QAction::triggered, [diagnostic] { disableChecks({diagnostic}); });
actions << action;
@@ -70,10 +69,10 @@ void DiagnosticMark::disable()
return;
m_enabled = false;
if (m_diagnostic.type == "error" || m_diagnostic.type == "fatal")
setIcon(Utils::Icons::CODEMODEL_DISABLED_ERROR.icon());
setIcon(Icons::CODEMODEL_DISABLED_ERROR.icon());
else
setIcon(Utils::Icons::CODEMODEL_DISABLED_WARNING.icon());
setColor(Utils::Theme::Color::IconsDisabledColor);
setIcon(Icons::CODEMODEL_DISABLED_WARNING.icon());
setColor(Theme::Color::IconsDisabledColor);
}
bool DiagnosticMark::enabled() const

View File

@@ -27,9 +27,22 @@ public:
{
using namespace Layouting;
auto warningLabel = new QLabel;
warningLabel->setWordWrap(true);
warningLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse
| Qt::LinksAccessibleByKeyboard
| Qt::TextSelectableByMouse);
warningLabel->setText(Tr::tr(
"Enabling %1 is subject to your agreement and abidance with your applicable "
"%1 terms. It is your responsibility to know and accept the requirements and "
"parameters of using tools like %1. This may include, but is not limited to, "
"ensuring you have the rights to allow %1 access to your code, as well as "
"understanding any implications of your use of %1 and suggestions produced "
"(like copyright, accuracy, etc.)." ).arg("Copilot"));
auto authWidget = new AuthWidget();
QLabel *helpLabel = new QLabel();
auto helpLabel = new QLabel();
helpLabel->setTextFormat(Qt::MarkdownText);
helpLabel->setWordWrap(true);
helpLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse
@@ -52,8 +65,10 @@ public:
.arg("[agent.js](https://github.com/github/copilot.vim/tree/release/copilot/dist)"));
Column {
authWidget, br,
QString("<b>" + Tr::tr("Note:") + "</b>"), br,
warningLabel, br,
CopilotSettings::instance().enableCopilot, br,
authWidget, br,
CopilotSettings::instance().nodeJsPath, br,
CopilotSettings::instance().distPath, br,
CopilotSettings::instance().autoComplete, br,

View File

@@ -20,7 +20,7 @@ static void initEnableAspect(BoolAspect &enableCopilot)
enableCopilot.setDisplayName(Tr::tr("Enable Copilot"));
enableCopilot.setLabelText(Tr::tr("Enable Copilot"));
enableCopilot.setToolTip(Tr::tr("Enables the Copilot integration."));
enableCopilot.setDefaultValue(true);
enableCopilot.setDefaultValue(false);
}
CopilotSettings &CopilotSettings::instance()
@@ -52,6 +52,7 @@ CopilotSettings::CopilotSettings()
nodeJsPath.setLabelText(Tr::tr("Node.js path:"));
nodeJsPath.setHistoryCompleter("Copilot.NodePath.History");
nodeJsPath.setDisplayName(Tr::tr("Node.js Path"));
nodeJsPath.setEnabler(&enableCopilot);
nodeJsPath.setToolTip(
Tr::tr("Select path to node.js executable. See https://nodejs.org/en/download/"
"for installation instructions."));
@@ -62,6 +63,7 @@ CopilotSettings::CopilotSettings()
distPath.setLabelText(Tr::tr("Path to agent.js:"));
distPath.setHistoryCompleter("Copilot.DistPath.History");
distPath.setDisplayName(Tr::tr("Agent.js path"));
distPath.setEnabler(&enableCopilot);
distPath.setToolTip(Tr::tr(
"Select path to agent.js in Copilot Neovim plugin. See "
"https://github.com/github/copilot.vim#getting-started for installation instructions."));
@@ -70,6 +72,7 @@ CopilotSettings::CopilotSettings()
autoComplete.setSettingsKey("Copilot.Autocomplete");
autoComplete.setLabelText(Tr::tr("Request completions automatically"));
autoComplete.setDefaultValue(true);
autoComplete.setEnabler(&enableCopilot);
autoComplete.setToolTip(Tr::tr("Automatically request suggestions for the current text cursor "
"position after changes to the document."));

View File

@@ -61,7 +61,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
const QString &text = block.text();
const Tokens &tks = lexer(text);
for (const Token &tk : tks) {
if (tk.is(T_SEMICOLON) || tk.is(T_LBRACE)) {
if (tk.is(T_SEMICOLON)) {
// No need to continue beyond this, we might already have something meaningful.
cursor.setPosition(block.position() + tk.utf16charsEnd(), QTextCursor::KeepAnchor);
break;
@@ -74,6 +74,11 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
block = block.next();
}
// For the edge case of no semicolons at all, which can e.g. happen if the file
// consists only of empty function definitions.
if (!cursor.hasSelection())
cursor.setPosition(cursor.document()->characterCount() - 1, QTextCursor::KeepAnchor);
if (!cursor.hasSelection())
return QString();

View File

@@ -13,6 +13,7 @@ QtcPlugin {
Depends { name: "ProjectExplorer" }
Depends { name: "Debugger" }
Depends { name: "CMakeProjectManager" }
Depends { name: "QmlJS" }
Depends { name: "QtSupport" }
Depends { name: "qtc_gtest_gmock"; condition: qtc.testsEnabled; required: false }

View File

@@ -87,6 +87,9 @@ void MesonBuildSystem::parsingCompleted(bool success)
UNLOCK(false);
emitBuildSystemUpdated();
}
emitParsingFinished(success);
emit buildConfiguration()->enabledChanged(); // HACK. Should not be needed.
}
ProjectExplorer::Kit *MesonBuildSystem::MesonBuildSystem::kit()

View File

@@ -1107,7 +1107,7 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
FilePaths compilerPaths;
if (!device.isNull()) {
if (device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
// FIXME: Merge with block below
FilePaths searchPaths = detector.searchPaths;
if (searchPaths.isEmpty())

View File

@@ -138,6 +138,8 @@ void TextMark::paintAnnotation(QPainter &painter,
painter.fontMetrics(),
fadeInOffset,
fadeOutOffset);
if (m_staticAnnotationText.text() != rects.text)
m_staticAnnotationText.setText(rects.text);
annotationRect->setRight(rects.fadeOutRect.right());
const QRectF eventRectF(eventRect);
if (!(rects.fadeInRect.intersects(eventRectF) || rects.annotationRect.intersects(eventRectF)
@@ -161,7 +163,7 @@ void TextMark::paintAnnotation(QPainter &painter,
painter.fillRect(rects.annotationRect, colors.rectColor);
painter.setPen(colors.textColor);
paintIcon(&painter, rects.iconRect.toAlignedRect());
painter.drawText(rects.textRect, Qt::AlignLeft, rects.text);
painter.drawStaticText(rects.textRect.topLeft(), m_staticAnnotationText);
if (rects.fadeOutRect.isValid()) {
grad = QLinearGradient(rects.fadeOutRect.topLeft() - contentOffset,
rects.fadeOutRect.topRight() - contentOffset);

View File

@@ -11,6 +11,7 @@
#include <QCoreApplication>
#include <QIcon>
#include <QStaticText>
#include <QVector>
#include <optional>
@@ -139,6 +140,7 @@ private:
bool m_visible = false;
TextMarkCategory m_category;
QString m_lineAnnotation;
mutable QStaticText m_staticAnnotationText;
QString m_toolTip;
std::function<QString()> m_toolTipProvider;
QString m_defaultToolTip;