blob: 6b6ec2c71948834f35fac4f58c2064ad344149ed (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#pragma once
#include "yql_issue.h"
#include "yql_warning.h"
#include <util/generic/maybe.h>
#include <util/generic/stack.h>
#include <util/generic/hash_set.h>
#include <array>
namespace NYql {
class TIssueManager: private TNonCopyable {
public:
void AddScope(std::function<TIssuePtr()> fn);
void LeaveScope();
void RaiseIssue(const TIssue& issue);
void RaiseIssues(const TIssues& issues);
bool RaiseWarning(TIssue issue);
void AddIssues(const TIssues& errors);
void AddIssues(const TPosition& pos, const TIssues& issues);
TIssues GetIssues();
TIssues GetCompletedIssues() const;
void Reset(const TIssues& issues);
void Reset();
void AddWarningRule(const TWarningRule &rule);
void SetWarningToErrorTreatMessage(const TString& msg);
void SetIssueCountLimit(size_t limit) {
IssueLimit_ = limit;
}
void RaiseIssueForEmptyScope();
private:
TIssuePtr CheckUniqAndLimit(const TIssue& issue);
TIssuePtr CheckUniqAndLimit(TIssuePtr issue);
void LeaveAllScopes();
bool HasOpenScopes() const;
struct TIssueHash {
ui64 operator()(const TIssuePtr& p) {
return p->Hash();
}
};
struct TIssueEqual {
bool operator()(const TIssuePtr& l, const TIssuePtr& r) {
return *l == *r;
}
};
TStack<std::pair<TMaybe<TIssuePtr>, std::function<TIssuePtr()>>> RawIssues_;
TIssues CompletedIssues_;
TMaybe<TString> WarningToErrorTreatMessage_;
TWarningPolicy WarningPolicy_;
std::array<TIssuePtr, NYql::TSeverityIds::ESeverityId_ARRAYSIZE> OverflowIssues_;
std::array<THashSet<TIssuePtr, TIssueHash, TIssueEqual>, NYql::TSeverityIds::ESeverityId_ARRAYSIZE> UniqueIssues_;
size_t IssueLimit_ = 0;
};
class TIssueScopeGuard: private TNonCopyable {
TIssueManager& Manager_;
public:
TIssueScopeGuard(TIssueManager& manager, std::function<TIssuePtr()> fn)
: Manager_(manager)
{
Manager_.AddScope(fn);
}
void RaiseIssueForEmptyScope() {
Manager_.RaiseIssueForEmptyScope();
}
~TIssueScopeGuard()
{
Manager_.LeaveScope();
}
};
}
|