diff options
| author | vitya-smirnov <[email protected]> | 2025-10-20 09:58:22 +0300 |
|---|---|---|
| committer | vitya-smirnov <[email protected]> | 2025-10-20 10:31:38 +0300 |
| commit | 321c6567eaec0530e3ab479ac507392c3297fe38 (patch) | |
| tree | b054cc947b6f105d1898c08c0eacd1c64056f7ec /yql/essentials/sql/v1/highlight/sql_highlight.cpp | |
| parent | d6427b59fba7225b222f4137dcb9646ec80e0a31 (diff) | |
YQL-20496: Fix an option highlighting pattern
There was a bug with highlighting an identifier a in expression a == b
as an option. So for an option match we expect an exactly = token. So
all hints are enumerated and the solid regex is built.
commit_hash:8df3cd082a7eaa99fc06daa282ba6dd9f0798f6f
Diffstat (limited to 'yql/essentials/sql/v1/highlight/sql_highlight.cpp')
| -rw-r--r-- | yql/essentials/sql/v1/highlight/sql_highlight.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/yql/essentials/sql/v1/highlight/sql_highlight.cpp b/yql/essentials/sql/v1/highlight/sql_highlight.cpp index 3f17934cef4..9ad8c6b383b 100644 --- a/yql/essentials/sql/v1/highlight/sql_highlight.cpp +++ b/yql/essentials/sql/v1/highlight/sql_highlight.cpp @@ -1,10 +1,11 @@ #include "sql_highlight.h" +#include "data_language_json.h" + #include <yql/essentials/sql/v1/lexer/regex/regex.h> #include <contrib/libs/re2/re2/re2.h> -#include <library/cpp/json/json_reader.h> #include <library/cpp/resource/resource.h> #include <util/generic/algorithm.h> @@ -104,6 +105,11 @@ TUnit MakeUnit<EUnitKind::BindParameterIdentifier>(Syntax& s) { template <> TUnit MakeUnit<EUnitKind::OptionIdentifier>(Syntax& s) { + TVector<NSQLTranslationV1::TRegexPattern> hints; + for (const TString& type : LoadHints()) { + hints.emplace_back(CaseInsensitive(type)); + } + return { .Kind = EUnitKind::OptionIdentifier, .Patterns = { @@ -113,25 +119,16 @@ TUnit MakeUnit<EUnitKind::OptionIdentifier>(Syntax& s) { .Before = TStringBuilder() << "PRAGMA" << s.Get("WS"), .IsCaseInsensitive = true, }, - { - .Body = s.Get("ID_PLAIN"), - .Before = TStringBuilder() << "WITH" << s.Get("WS"), - .IsCaseInsensitive = true, - }, - { - .Body = s.Get("ID_PLAIN"), - .After = " ?" + s.Get("EQUALS"), - .IsCaseInsensitive = true, - }}, + {Merged(std::move(hints))}, + }, }; } template <> TUnit MakeUnit<EUnitKind::TypeIdentifier>(Syntax& s) { TVector<NSQLTranslationV1::TRegexPattern> types; - NJson::TJsonValue json = NJson::ReadJsonFastTree(NResource::Find("types.json")); - for (const NJson::TJsonValue& value : json.GetArraySafe()) { - types.emplace_back(CaseInsensitive(value["name"].GetStringSafe())); + for (const TString& type : LoadTypes()) { + types.emplace_back(CaseInsensitive(type)); } return { |
