@@ -8,137 +8,139 @@ describe('Flink semantic context collector tests', () => {
8
8
const flinkSql = new FlinkSQL ( ) ;
9
9
const text = fs . readFileSync ( path . join ( __dirname , 'fixtures' , 'semantic.sql' ) , 'utf-8' ) ;
10
10
11
- test ( 'new statement with uncomplete keyword' , ( ) => {
11
+ test ( 'beginning of statement with uncomplete keyword' , ( ) => {
12
12
const sql = readSQLByRange ( { sql : text } , { startLine : 1 , endLine : 1 } ) ;
13
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
13
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
14
14
lineNumber : 1 ,
15
15
column : 5 ,
16
16
} ) ;
17
- expect ( isNewStatement ) . toBeTruthy ( ) ;
17
+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
18
18
} ) ;
19
19
20
- test ( 'new statement with complete keyword' , ( ) => {
20
+ test ( 'beginning of statement with complete keyword' , ( ) => {
21
21
const sql = readSQLByRange ( { sql : text } , { startLine : 3 , endLine : 3 } ) ;
22
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
22
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
23
23
lineNumber : 1 ,
24
24
column : 7 ,
25
25
} ) ;
26
- expect ( isNewStatement ) . toBeTruthy ( ) ;
26
+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
27
27
} ) ;
28
28
29
- test ( 'not new statement with uncomplete keyword' , ( ) => {
29
+ test ( 'not beginning of statement with uncomplete keyword' , ( ) => {
30
30
const sql = readSQLByRange ( { sql : text } , { startLine : 5 , endLine : 5 } ) ;
31
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
31
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
32
32
lineNumber : 1 ,
33
33
column : 22 ,
34
34
} ) ;
35
- expect ( isNewStatement ) . toBeFalsy ( ) ;
35
+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
36
36
} ) ;
37
37
38
- test ( 'not new statement with complete keyword' , ( ) => {
38
+ test ( 'not beginning of statement with complete keyword' , ( ) => {
39
39
const sql = readSQLByRange ( { sql : text } , { startLine : 7 , endLine : 7 } ) ;
40
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
40
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
41
41
lineNumber : 1 ,
42
42
column : 22 ,
43
43
} ) ;
44
- expect ( isNewStatement ) . toBeFalsy ( ) ;
44
+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
45
45
} ) ;
46
46
47
- test ( 'not new statement if type white space after keyword' , ( ) => {
47
+ test ( 'not beginning of statement if type white space after keyword' , ( ) => {
48
48
const sql = readSQLByRange ( { sql : text } , { startLine : 9 , endLine : 9 } ) ;
49
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
49
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
50
50
lineNumber : 1 ,
51
51
column : 8 ,
52
52
} ) ;
53
- expect ( isNewStatement ) . toBeFalsy ( ) ;
53
+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
54
54
} ) ;
55
55
56
- test ( 'new statement after an exists statement' , ( ) => {
56
+ test ( 'beginning of statement after an exists statement' , ( ) => {
57
57
const sql = readSQLByRange ( { sql : text } , { startLine : 11 , endLine : 12 } ) ;
58
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
58
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
59
59
lineNumber : 2 ,
60
60
column : 4 ,
61
61
} ) ;
62
- expect ( isNewStatement ) . toBeTruthy ( ) ;
62
+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
63
63
} ) ;
64
64
65
- test ( 'new statement after an exists statement and typed white space' , ( ) => {
65
+ test ( 'beginning of statement after an exists statement and typed white space' , ( ) => {
66
66
const sql = readSQLByRange ( { sql : text } , { startLine : 14 , endLine : 15 } ) ;
67
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
67
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
68
68
lineNumber : 2 ,
69
69
column : 2 ,
70
70
} ) ;
71
- expect ( isNewStatement ) . toBeTruthy ( ) ;
71
+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
72
72
} ) ;
73
73
74
- test ( 'not new statement if previous statement exists error' , ( ) => {
74
+ test ( 'not beginning of statement if previous statement exists error' , ( ) => {
75
75
const sql = readSQLByRange ( { sql : text } , { startLine : 17 , endLine : 22 } ) ;
76
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
76
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
77
77
lineNumber : 6 ,
78
78
column : 4 ,
79
79
} ) ;
80
- expect ( isNewStatement ) . toBeFalsy ( ) ;
80
+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
81
81
} ) ;
82
82
83
- test ( 'new statement if previous token text is semicolon even if has error' , ( ) => {
83
+ test ( 'beginning of statement if previous token text is semicolon even if has error' , ( ) => {
84
84
const sql = readSQLByRange ( { sql : text } , { startLine : 24 , endLine : 24 } ) ;
85
85
// typed keyword
86
86
const ctx1 = flinkSql . getSemanticContextAtCaretPosition ( sql , {
87
87
lineNumber : 1 ,
88
88
column : 13 ,
89
89
} ) ;
90
- expect ( ctx1 . isNewStatement ) . toBeTruthy ( ) ;
90
+ expect ( ctx1 . isStatementBeginning ) . toBeTruthy ( ) ;
91
91
92
92
// typed white space
93
93
const ctx2 = flinkSql . getSemanticContextAtCaretPosition ( sql , {
94
94
lineNumber : 1 ,
95
95
column : 9 ,
96
96
} ) ;
97
- expect ( ctx2 . isNewStatement ) . toBeTruthy ( ) ;
97
+ expect ( ctx2 . isStatementBeginning ) . toBeTruthy ( ) ;
98
98
} ) ;
99
99
100
- test ( 'new statement between two statement' , ( ) => {
100
+ test ( 'beginning of statement between two statement' , ( ) => {
101
101
const sql = readSQLByRange ( { sql : text } , { startLine : 26 , endLine : 28 } ) ;
102
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
102
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
103
103
lineNumber : 2 ,
104
104
column : 4 ,
105
105
} ) ;
106
- expect ( isNewStatement ) . toBeTruthy ( ) ;
106
+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
107
107
} ) ;
108
108
109
- test ( 'not new statement between two statement' , ( ) => {
109
+ test ( 'not beginning of statement between two statement' , ( ) => {
110
110
const sql = readSQLByRange ( { sql : text } , { startLine : 30 , endLine : 32 } ) ;
111
- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
111
+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
112
112
lineNumber : 2 ,
113
113
column : 13 ,
114
114
} ) ;
115
- expect ( isNewStatement ) . toBeFalsy ( ) ;
115
+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
116
116
} ) ;
117
117
118
118
test ( 'test sqlSplitStrategy' , ( ) => {
119
119
const sql = readSQLByRange ( { sql : text } , { startLine : 34 , endLine : 35 } ) ;
120
- const { isNewStatement : isNewStatement1 } = flinkSql . getSemanticContextAtCaretPosition (
121
- sql ,
122
- {
123
- lineNumber : 2 ,
124
- column : 7 ,
125
- } ,
126
- {
127
- sqlSplitStrategy : SqlSplitStrategy . LOOSE ,
128
- }
129
- ) ;
130
- expect ( isNewStatement1 ) . toBeTruthy ( ) ;
120
+ const { isStatementBeginning : isStatementBeginning1 } =
121
+ flinkSql . getSemanticContextAtCaretPosition (
122
+ sql ,
123
+ {
124
+ lineNumber : 2 ,
125
+ column : 7 ,
126
+ } ,
127
+ {
128
+ sqlSplitStrategy : SqlSplitStrategy . LOOSE ,
129
+ }
130
+ ) ;
131
+ expect ( isStatementBeginning1 ) . toBeTruthy ( ) ;
131
132
132
- const { isNewStatement : isNewStatement2 } = flinkSql . getSemanticContextAtCaretPosition (
133
- sql ,
134
- {
135
- lineNumber : 2 ,
136
- column : 7 ,
137
- } ,
138
- {
139
- sqlSplitStrategy : SqlSplitStrategy . STRICT ,
140
- }
141
- ) ;
142
- expect ( isNewStatement2 ) . toBeFalsy ( ) ;
133
+ const { isStatementBeginning : isStatementBeginning2 } =
134
+ flinkSql . getSemanticContextAtCaretPosition (
135
+ sql ,
136
+ {
137
+ lineNumber : 2 ,
138
+ column : 7 ,
139
+ } ,
140
+ {
141
+ sqlSplitStrategy : SqlSplitStrategy . STRICT ,
142
+ }
143
+ ) ;
144
+ expect ( isStatementBeginning2 ) . toBeFalsy ( ) ;
143
145
} ) ;
144
146
} ) ;
0 commit comments