blob: 755520f88b6c1f98e272b6dafef20090cee3648e (
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
|
#include "parse_tree.h"
#include <yql/essentials/sql/v1/ide/completion/syntax/format.h>
#include <util/system/yassert.h>
#include <util/generic/maybe.h>
namespace NSQLComplete {
TMaybe<std::string> GetName(SQLv1::Bind_parameterContext* ctx) {
if (ctx == nullptr) {
return Nothing();
}
if (auto* x = ctx->an_id_or_type()) {
return x->getText();
} else if (auto* x = ctx->TOKEN_TRUE()) {
return x->getText();
} else if (auto* x = ctx->TOKEN_FALSE()) {
return x->getText();
} else {
return Nothing();
}
}
TPosition GetPosition(SQLv1::Bind_parameterContext* ctx) {
if (ctx == nullptr) {
return {};
}
antlr4::Token* token = ctx->getStart();
if (!token) {
return {};
}
return {
.Line = static_cast<ui32>(token->getLine()),
.Column = static_cast<ui32>(token->getCharPositionInLine()),
};
}
} // namespace NSQLComplete
|