aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangtools/clangtoolslogfilereader.h
blob: 09c2b79f0219e6ed275d831658834ecf338b3e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once


#include "clangtoolsdiagnostic.h"

#include <QPromise>
#include <optional>

namespace Utils { class FilePath; }

namespace ClangTools {
namespace Internal {

using AcceptDiagsFromFilePath = std::function<bool(const Utils::FilePath &)>;

// Reads diagnostics generated by "clang-tidy/clazy-standalone -export-fixes=path/to/file"
void parseDiagnostics(QPromise<Utils::expected_str<Diagnostics>> &promise,
                      const Utils::FilePath &logFilePath,
                      const AcceptDiagsFromFilePath &acceptFromFilePath = {});

Utils::expected_str<Diagnostics> readExportedDiagnostics(
    const Utils::FilePath &logFilePath,
    const AcceptDiagsFromFilePath &acceptFromFilePath = {});

// Exposed for tests
struct LineColumnInfo {
    int line = 1; // 1-based
    int column = 1; // 1-based
    int lineStartOffset = 0; // for optimiation/caching purposes
};
using OptionalLineColumnInfo = std::optional<LineColumnInfo>;
OptionalLineColumnInfo byteOffsetInUtf8TextToLineColumn(const char *text,
                                                        int offset,
                                                        int startLine = 1);

} // namespace Internal
} // namespace ClangTools