blob: 865507b0de89a5e5a6c217c0dab2131a5d0e2337 (
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/essentials/sql/v1/ide/completion/core/input.h>
#include <yql/essentials/sql/v1/ide/completion/text/word.h>
#include <yql/essentials/parser/lexer_common/lexer.h>
#include <util/generic/maybe.h>
namespace NSQLComplete {
using NSQLTranslation::ILexer;
using NSQLTranslation::TParsedToken;
using NSQLTranslation::TParsedTokenList;
struct TCursor {
TMaybe<size_t> PrevTokenIndex = Nothing();
size_t NextTokenIndex = PrevTokenIndex ? *PrevTokenIndex : 0;
size_t Position = 0;
};
struct TRichParsedToken {
const TParsedToken* Base = nullptr;
size_t Index = 0;
size_t Position = 0;
[[nodiscard]] bool IsLiteral() const;
[[nodiscard]] size_t End() const;
};
struct TCursorTokenContext {
TParsedTokenList Tokens;
TVector<size_t> TokenPositions;
TCursor Cursor;
[[nodiscard]] TMaybe<TRichParsedToken> Enclosing() const;
[[nodiscard]] TMaybe<TRichParsedToken> MatchCursorPrefix(const TVector<TStringBuf>& pattern) const;
};
bool GetStatement(
ILexer::TPtr& lexer,
const TMaterializedInput& input,
TCompletionInput& output,
size_t& output_position);
bool GetCursorTokenContext(
ILexer::TPtr& lexer,
TCompletionInput input,
TCursorTokenContext& context);
} // namespace NSQLComplete
|