yql_warning.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "yql_issue_id.h"
  3. #include <util/generic/hash.h>
  4. #include <util/generic/string.h>
  5. #if defined(_win_)
  6. #undef ERROR
  7. #endif
  8. namespace NYql {
  9. enum class EWarningAction {
  10. DISABLE,
  11. ERROR,
  12. DEFAULT,
  13. };
  14. class TWarningRule {
  15. public:
  16. const TString& GetPattern() const { return IssueCodePattern; }
  17. EWarningAction GetAction() const { return Action; }
  18. enum class EParseResult { PARSE_OK, PARSE_PATTERN_FAIL, PARSE_ACTION_FAIL };
  19. static EParseResult ParseFrom(const TString& codePattern, const TString& action,
  20. TWarningRule& result, TString& errorMessage);
  21. private:
  22. TString IssueCodePattern;
  23. EWarningAction Action = EWarningAction::DEFAULT;
  24. };
  25. using TWarningRules = TVector<TWarningRule>;
  26. class TWarningPolicy {
  27. public:
  28. void AddRule(const TWarningRule& rule);
  29. EWarningAction GetAction(TIssueCode code) const;
  30. const TWarningRules& GetRules() const { return Rules; }
  31. void Clear();
  32. private:
  33. TWarningRules Rules;
  34. EWarningAction BaseAction = EWarningAction::DEFAULT;
  35. THashMap<TIssueCode, EWarningAction> Overrides;
  36. };
  37. }