aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/public/issue/yql_warning.h
blob: d1d6a909225191643403126c58ab13e1ca9e563f (plain) (blame)
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
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include "yql_issue_id.h"

#include <util/generic/hash.h>
#include <util/generic/string.h>

#if defined(_win_)
#undef ERROR
#endif

namespace NYql {

enum class EWarningAction {
    DISABLE,
    ERROR,
    DEFAULT,
};

class TWarningRule {
public:
    const TString& GetPattern() const { return IssueCodePattern; }
    EWarningAction GetAction() const  { return Action; }

    enum class EParseResult { PARSE_OK, PARSE_PATTERN_FAIL, PARSE_ACTION_FAIL };
    static EParseResult ParseFrom(const TString& codePattern, const TString& action,
                                  TWarningRule& result, TString& errorMessage);
private:
    TString IssueCodePattern;
    EWarningAction Action = EWarningAction::DEFAULT;
};

using TWarningRules = TVector<TWarningRule>;

class TWarningPolicy {
public:
    void AddRule(const TWarningRule& rule);

    EWarningAction GetAction(TIssueCode code) const;

    const TWarningRules& GetRules() const { return Rules; }

    void Clear();

private:
    TWarningRules Rules;
    EWarningAction BaseAction = EWarningAction::DEFAULT;
    THashMap<TIssueCode, EWarningAction> Overrides;
};

}