@@ -8,137 +8,139 @@ describe('Flink semantic context collector tests', () => {
88 const flinkSql = new FlinkSQL ( ) ;
99 const text = fs . readFileSync ( path . join ( __dirname , 'fixtures' , 'semantic.sql' ) , 'utf-8' ) ;
1010
11- test ( 'new statement with uncomplete keyword' , ( ) => {
11+ test ( 'beginning of statement with uncomplete keyword' , ( ) => {
1212 const sql = readSQLByRange ( { sql : text } , { startLine : 1 , endLine : 1 } ) ;
13- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
13+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
1414 lineNumber : 1 ,
1515 column : 5 ,
1616 } ) ;
17- expect ( isNewStatement ) . toBeTruthy ( ) ;
17+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
1818 } ) ;
1919
20- test ( 'new statement with complete keyword' , ( ) => {
20+ test ( 'beginning of statement with complete keyword' , ( ) => {
2121 const sql = readSQLByRange ( { sql : text } , { startLine : 3 , endLine : 3 } ) ;
22- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
22+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
2323 lineNumber : 1 ,
2424 column : 7 ,
2525 } ) ;
26- expect ( isNewStatement ) . toBeTruthy ( ) ;
26+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
2727 } ) ;
2828
29- test ( 'not new statement with uncomplete keyword' , ( ) => {
29+ test ( 'not beginning of statement with uncomplete keyword' , ( ) => {
3030 const sql = readSQLByRange ( { sql : text } , { startLine : 5 , endLine : 5 } ) ;
31- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
31+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
3232 lineNumber : 1 ,
3333 column : 22 ,
3434 } ) ;
35- expect ( isNewStatement ) . toBeFalsy ( ) ;
35+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
3636 } ) ;
3737
38- test ( 'not new statement with complete keyword' , ( ) => {
38+ test ( 'not beginning of statement with complete keyword' , ( ) => {
3939 const sql = readSQLByRange ( { sql : text } , { startLine : 7 , endLine : 7 } ) ;
40- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
40+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
4141 lineNumber : 1 ,
4242 column : 22 ,
4343 } ) ;
44- expect ( isNewStatement ) . toBeFalsy ( ) ;
44+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
4545 } ) ;
4646
47- test ( 'not new statement if type white space after keyword' , ( ) => {
47+ test ( 'not beginning of statement if type white space after keyword' , ( ) => {
4848 const sql = readSQLByRange ( { sql : text } , { startLine : 9 , endLine : 9 } ) ;
49- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
49+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
5050 lineNumber : 1 ,
5151 column : 8 ,
5252 } ) ;
53- expect ( isNewStatement ) . toBeFalsy ( ) ;
53+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
5454 } ) ;
5555
56- test ( 'new statement after an exists statement' , ( ) => {
56+ test ( 'beginning of statement after an exists statement' , ( ) => {
5757 const sql = readSQLByRange ( { sql : text } , { startLine : 11 , endLine : 12 } ) ;
58- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
58+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
5959 lineNumber : 2 ,
6060 column : 4 ,
6161 } ) ;
62- expect ( isNewStatement ) . toBeTruthy ( ) ;
62+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
6363 } ) ;
6464
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' , ( ) => {
6666 const sql = readSQLByRange ( { sql : text } , { startLine : 14 , endLine : 15 } ) ;
67- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
67+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
6868 lineNumber : 2 ,
6969 column : 2 ,
7070 } ) ;
71- expect ( isNewStatement ) . toBeTruthy ( ) ;
71+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
7272 } ) ;
7373
74- test ( 'not new statement if previous statement exists error' , ( ) => {
74+ test ( 'not beginning of statement if previous statement exists error' , ( ) => {
7575 const sql = readSQLByRange ( { sql : text } , { startLine : 17 , endLine : 22 } ) ;
76- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
76+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
7777 lineNumber : 6 ,
7878 column : 4 ,
7979 } ) ;
80- expect ( isNewStatement ) . toBeFalsy ( ) ;
80+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
8181 } ) ;
8282
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' , ( ) => {
8484 const sql = readSQLByRange ( { sql : text } , { startLine : 24 , endLine : 24 } ) ;
8585 // typed keyword
8686 const ctx1 = flinkSql . getSemanticContextAtCaretPosition ( sql , {
8787 lineNumber : 1 ,
8888 column : 13 ,
8989 } ) ;
90- expect ( ctx1 . isNewStatement ) . toBeTruthy ( ) ;
90+ expect ( ctx1 . isStatementBeginning ) . toBeTruthy ( ) ;
9191
9292 // typed white space
9393 const ctx2 = flinkSql . getSemanticContextAtCaretPosition ( sql , {
9494 lineNumber : 1 ,
9595 column : 9 ,
9696 } ) ;
97- expect ( ctx2 . isNewStatement ) . toBeTruthy ( ) ;
97+ expect ( ctx2 . isStatementBeginning ) . toBeTruthy ( ) ;
9898 } ) ;
9999
100- test ( 'new statement between two statement' , ( ) => {
100+ test ( 'beginning of statement between two statement' , ( ) => {
101101 const sql = readSQLByRange ( { sql : text } , { startLine : 26 , endLine : 28 } ) ;
102- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
102+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
103103 lineNumber : 2 ,
104104 column : 4 ,
105105 } ) ;
106- expect ( isNewStatement ) . toBeTruthy ( ) ;
106+ expect ( isStatementBeginning ) . toBeTruthy ( ) ;
107107 } ) ;
108108
109- test ( 'not new statement between two statement' , ( ) => {
109+ test ( 'not beginning of statement between two statement' , ( ) => {
110110 const sql = readSQLByRange ( { sql : text } , { startLine : 30 , endLine : 32 } ) ;
111- const { isNewStatement } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
111+ const { isStatementBeginning } = flinkSql . getSemanticContextAtCaretPosition ( sql , {
112112 lineNumber : 2 ,
113113 column : 13 ,
114114 } ) ;
115- expect ( isNewStatement ) . toBeFalsy ( ) ;
115+ expect ( isStatementBeginning ) . toBeFalsy ( ) ;
116116 } ) ;
117117
118118 test ( 'test sqlSplitStrategy' , ( ) => {
119119 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 ( ) ;
131132
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 ( ) ;
143145 } ) ;
144146} ) ;
0 commit comments