forked from qt-creator/qt-creator
TaskTree: Add TreeStorage::operator*()
Reuse it in some places. Change-Id: I335f38fa0384ea17bd8e981d743f835c3f05b731 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -74,6 +74,7 @@ class TreeStorage : public TreeStorageBase
|
||||
{
|
||||
public:
|
||||
TreeStorage() : TreeStorageBase(TreeStorage::ctor(), TreeStorage::dtor()) {}
|
||||
StorageStruct &operator*() const noexcept { return *activeStorage(); }
|
||||
StorageStruct *operator->() const noexcept { return activeStorage(); }
|
||||
StorageStruct *activeStorage() const {
|
||||
return static_cast<StorageStruct *>(activeStorageVoid());
|
||||
|
@@ -111,11 +111,10 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
|
||||
};
|
||||
const TreeStorage<ClangToolStorage> storage;
|
||||
|
||||
const auto mainToolArguments = [=](const ClangToolStorage *data)
|
||||
{
|
||||
const auto mainToolArguments = [=](const ClangToolStorage &data) {
|
||||
QStringList result;
|
||||
result << "-export-fixes=" + data->outputFilePath.nativePath();
|
||||
if (!input.overlayFilePath.isEmpty() && isVFSOverlaySupported(data->executable))
|
||||
result << "-export-fixes=" + data.outputFilePath.nativePath();
|
||||
if (!input.overlayFilePath.isEmpty() && isVFSOverlaySupported(data.executable))
|
||||
result << "--vfsoverlay=" + input.overlayFilePath;
|
||||
result << input.unit.file.nativePath();
|
||||
return result;
|
||||
@@ -147,13 +146,13 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
|
||||
process.setLowPriority();
|
||||
process.setWorkingDirectory(input.outputDirPath); // Current clang-cl puts log file into working dir.
|
||||
|
||||
const ClangToolStorage *data = storage.activeStorage();
|
||||
const ClangToolStorage &data = *storage;
|
||||
|
||||
const QStringList args = checksArguments(input.tool, input.config)
|
||||
+ mainToolArguments(data)
|
||||
+ QStringList{"--"}
|
||||
+ clangArguments(input.config, input.unit.arguments);
|
||||
const CommandLine commandLine = {data->executable, args};
|
||||
const CommandLine commandLine = {data.executable, args};
|
||||
|
||||
qCDebug(LOG).noquote() << "Starting" << commandLine.toUserOutput();
|
||||
process.setCommand(commandLine);
|
||||
@@ -162,8 +161,7 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
|
||||
qCDebug(LOG).noquote() << "Output:\n" << process.cleanedStdOut();
|
||||
if (!outputHandler)
|
||||
return;
|
||||
const ClangToolStorage *data = storage.activeStorage();
|
||||
outputHandler({true, input.unit.file, data->outputFilePath, input.tool});
|
||||
outputHandler({true, input.unit.file, storage->outputFilePath, input.tool});
|
||||
};
|
||||
const auto onProcessError = [=](const QtcProcess &process) {
|
||||
if (!outputHandler)
|
||||
@@ -172,15 +170,15 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
|
||||
.arg(process.commandLine().toUserOutput())
|
||||
.arg(process.error())
|
||||
.arg(process.cleanedStdOut());
|
||||
const ClangToolStorage *data = storage.activeStorage();
|
||||
const ClangToolStorage &data = *storage;
|
||||
QString message;
|
||||
if (process.result() == ProcessResult::StartFailed)
|
||||
message = Tr::tr("An error occurred with the %1 process.").arg(data->name);
|
||||
message = Tr::tr("An error occurred with the %1 process.").arg(data.name);
|
||||
else if (process.result() == ProcessResult::FinishedWithError)
|
||||
message = Tr::tr("%1 finished with exit code: %2.").arg(data->name).arg(process.exitCode());
|
||||
message = Tr::tr("%1 finished with exit code: %2.").arg(data.name).arg(process.exitCode());
|
||||
else
|
||||
message = Tr::tr("%1 crashed.").arg(data->name);
|
||||
outputHandler({false, input.unit.file, data->outputFilePath, input.tool, message, details});
|
||||
message = Tr::tr("%1 crashed.").arg(data.name);
|
||||
outputHandler({false, input.unit.file, data.outputFilePath, input.tool, message, details});
|
||||
};
|
||||
|
||||
const Group group {
|
||||
|
@@ -135,7 +135,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
|
||||
taskTree.setupRoot(tasks);
|
||||
};
|
||||
const auto onTreeDone = [this, storage] {
|
||||
const QList<std::optional<FileData>> &results = *storage.activeStorage();
|
||||
const QList<std::optional<FileData>> &results = *storage;
|
||||
QList<FileData> finalList;
|
||||
for (const std::optional<FileData> &result : results) {
|
||||
if (result.has_value())
|
||||
|
@@ -171,7 +171,7 @@ GitDiffEditorController::GitDiffEditorController(IDocument *document,
|
||||
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
|
||||
};
|
||||
const auto onDiffDone = [diffInputStorage](const QtcProcess &process) {
|
||||
*diffInputStorage.activeStorage() = process.cleanedStdOut();
|
||||
*diffInputStorage = process.cleanedStdOut();
|
||||
};
|
||||
|
||||
const Group root {
|
||||
@@ -258,7 +258,7 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
|
||||
};
|
||||
|
||||
const auto onStagingDone = [storage, diffInputStorage] {
|
||||
*diffInputStorage.activeStorage() = storage->m_stagedOutput + storage->m_unstagedOutput;
|
||||
*diffInputStorage = storage->m_stagedOutput + storage->m_unstagedOutput;
|
||||
};
|
||||
|
||||
const Group root {
|
||||
@@ -455,7 +455,7 @@ ShowController::ShowController(IDocument *document, const QString &id)
|
||||
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
|
||||
};
|
||||
const auto onDiffDone = [diffInputStorage](const QtcProcess &process) {
|
||||
*diffInputStorage.activeStorage() = process.cleanedStdOut();
|
||||
*diffInputStorage = process.cleanedStdOut();
|
||||
};
|
||||
|
||||
const Group root {
|
||||
|
@@ -60,7 +60,7 @@ MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document
|
||||
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
|
||||
};
|
||||
const auto onDiffDone = [diffInputStorage](const QtcProcess &process) {
|
||||
*diffInputStorage.activeStorage() = process.cleanedStdOut();
|
||||
*diffInputStorage = process.cleanedStdOut();
|
||||
};
|
||||
|
||||
const Group root {
|
||||
|
@@ -203,7 +203,7 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume
|
||||
process.setCommand(command);
|
||||
};
|
||||
const auto onDiffDone = [diffInputStorage](const QtcProcess &process) {
|
||||
*diffInputStorage.activeStorage() = process.cleanedStdOut();
|
||||
*diffInputStorage = process.cleanedStdOut();
|
||||
};
|
||||
|
||||
const Group root {
|
||||
|
Reference in New Issue
Block a user