diff options
author | vityaman <vityaman.dev@yandex.ru> | 2025-04-08 16:11:56 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-04-08 16:26:47 +0300 |
commit | 2f90258cf6f1625ba0c99f6f37b6c9f336590534 (patch) | |
tree | 87891b9f23d6c25e134671a920553864a5331e7f /yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp | |
parent | 7077d90968fe79dfe126e92543d669259f02ef3a (diff) | |
download | ydb-2f90258cf6f1625ba0c99f6f37b6c9f336590534.tar.gz |
YQL-19747 Complete after PRAGMA and multi-token names
- [x] Complete after PRAGMA
- [x] Complete multi-token names correctly, for example, `yt.` returns only `DisableStrict`, not `yt.DisableStrict` and `DateTime::` returns `Split`, not `DateTime::Split`.
I tried to implement it using `CompletedToken` edition, but not all completion environments support candidates with various `contextLen` (`Replxx` does not). So I decided that completions should rewrite only the current token, not sequences. For example, on `DateTime::Spl` rewrite only `Spl`. It makes sense as multi-token names have some namespace separated by a punctuation, so used types only namespace and gets names inside of it.
---
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1181
commit_hash:9d8967ac43b9348f6dbb53837d92a9dcc9b51f48
Diffstat (limited to 'yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp b/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp index 57e058fa900..1bfcac47266 100644 --- a/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp +++ b/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp @@ -24,6 +24,11 @@ namespace NSQLComplete { RULE(Keyword_compat), }; + const TVector<TRuleId> PragmaNameRules = { + RULE(Opt_id_prefix_or_type), + RULE(An_id), + }; + const TVector<TRuleId> TypeNameRules = { RULE(Type_name_simple), RULE(An_id_or_type), @@ -62,6 +67,11 @@ namespace NSQLComplete { return Find(stack, rule) != std::end(stack); } + bool IsLikelyPragmaStack(const TParserCallStack& stack) { + return EndsWith({RULE(Pragma_stmt), RULE(Opt_id_prefix_or_type)}, stack) || + EndsWith({RULE(Pragma_stmt), RULE(An_id)}, stack); + } + bool IsLikelyTypeStack(const TParserCallStack& stack) { return EndsWith({RULE(Type_name_simple)}, stack) || (Contains({RULE(Invoke_expr), @@ -75,12 +85,14 @@ namespace NSQLComplete { return EndsWith({RULE(Unary_casual_subexpr), RULE(Id_expr)}, stack) || EndsWith({RULE(Unary_casual_subexpr), RULE(Atom_expr), - RULE(An_id_or_type)}, stack); + RULE(An_id_or_type)}, stack) || + EndsWith({RULE(Atom_expr), RULE(Id_or_type)}, stack); } std::unordered_set<TRuleId> GetC3PreferredRules() { std::unordered_set<TRuleId> preferredRules; preferredRules.insert(std::begin(KeywordRules), std::end(KeywordRules)); + preferredRules.insert(std::begin(PragmaNameRules), std::end(PragmaNameRules)); preferredRules.insert(std::begin(TypeNameRules), std::end(TypeNameRules)); preferredRules.insert(std::begin(FunctionNameRules), std::end(FunctionNameRules)); return preferredRules; |