blob: 0017afa0684ff149471bcee6588b6be45268519f (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#pragma once
#include <yql/essentials/sql/v1/complete/core/name.h>
#include <yql/essentials/sql/v1/complete/sql_complete.h>
#include <yql/essentials/sql/v1/lexer/lexer.h>
#include <util/generic/string.h>
#include <util/generic/hash.h>
#include <util/generic/hash_set.h>
#include <util/generic/maybe.h>
namespace NSQLComplete {
struct TEditRange {
size_t Begin = 0;
size_t Length = 0;
};
struct TLocalSyntaxContext {
using TKeywords = THashMap<TString, TVector<TString>>;
struct TPragma {
TString Namespace;
};
struct TFunction {
TString Namespace;
};
struct THint {
EStatementKind StatementKind;
};
struct TCluster {
TString Provider;
};
struct TObject {
TString Provider;
TString Cluster;
TString Path;
THashSet<EObjectKind> Kinds;
bool IsQuoted = false;
bool HasCluster() const {
return !Cluster.empty();
}
};
TKeywords Keywords;
TMaybe<TPragma> Pragma;
bool Type = false;
TMaybe<TFunction> Function;
TMaybe<THint> Hint;
TMaybe<TObject> Object;
TMaybe<TCluster> Cluster;
TEditRange EditRange;
};
class ILocalSyntaxAnalysis {
public:
using TPtr = THolder<ILocalSyntaxAnalysis>;
virtual TLocalSyntaxContext Analyze(TCompletionInput input) = 0;
virtual ~ILocalSyntaxAnalysis() = default;
};
ILocalSyntaxAnalysis::TPtr MakeLocalSyntaxAnalysis(
TLexerSupplier lexer, const THashSet<TString>& IgnoredRules);
} // namespace NSQLComplete
|