@@ -118,12 +118,12 @@ describe('Hive SQL Syntax Suggestion with collect entity', () => {
118
118
expect ( entities . length ) . toBe ( 2 ) ;
119
119
expect ( entities [ 0 ] . text ) . toBe ( 'a' ) ;
120
120
expect ( entities [ 0 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
121
- expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
121
+ expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
122
122
expect ( entities [ 0 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
123
123
124
124
expect ( entities [ 1 ] . text ) . toBe ( 'b' ) ;
125
125
expect ( entities [ 1 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
126
- expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
126
+ expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
127
127
expect ( entities [ 1 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
128
128
} ) ;
129
129
@@ -145,12 +145,12 @@ describe('Hive SQL Syntax Suggestion with collect entity', () => {
145
145
expect ( entities . length ) . toBe ( 2 ) ;
146
146
expect ( entities [ 0 ] . text ) . toBe ( 'a' ) ;
147
147
expect ( entities [ 0 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
148
- expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
148
+ expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
149
149
expect ( entities [ 0 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
150
150
151
151
expect ( entities [ 1 ] . text ) . toBe ( 'b' ) ;
152
152
expect ( entities [ 1 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
153
- expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
153
+ expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
154
154
expect ( entities [ 1 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
155
155
} ) ;
156
156
@@ -172,12 +172,12 @@ describe('Hive SQL Syntax Suggestion with collect entity', () => {
172
172
expect ( entities . length ) . toBe ( 2 ) ;
173
173
expect ( entities [ 0 ] . text ) . toBe ( 'page_view_stg' ) ;
174
174
expect ( entities [ 0 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
175
- expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
175
+ expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
176
176
expect ( entities [ 0 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
177
177
178
178
expect ( entities [ 1 ] . text ) . toBe ( 'page_view' ) ;
179
179
expect ( entities [ 1 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
180
- expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
180
+ expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
181
181
expect ( entities [ 1 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
182
182
} ) ;
183
183
@@ -199,12 +199,12 @@ describe('Hive SQL Syntax Suggestion with collect entity', () => {
199
199
expect ( entities . length ) . toBe ( 2 ) ;
200
200
expect ( entities [ 0 ] . text ) . toBe ( 'page_view_stg' ) ;
201
201
expect ( entities [ 0 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
202
- expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
202
+ expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
203
203
expect ( entities [ 0 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
204
204
205
205
expect ( entities [ 1 ] . text ) . toBe ( 'page_view' ) ;
206
206
expect ( entities [ 1 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
207
- expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
207
+ expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
208
208
expect ( entities [ 1 ] . belongStmt . rootStmt . isContainCaret ) . toBeTruthy ( ) ;
209
209
} ) ;
210
210
@@ -307,4 +307,24 @@ describe('Hive SQL Syntax Suggestion with collect entity', () => {
307
307
expect ( entities [ 1 ] . entityContextType ) . toBe ( EntityContextType . TABLE ) ;
308
308
expect ( entities [ 1 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
309
309
} ) ;
310
+
311
+ test ( 'isContainCaret should be truthy if caret position is whitespace at the end of statement' , ( ) => {
312
+ const pos : CaretPosition = {
313
+ lineNumber : 25 ,
314
+ column : 25 ,
315
+ } ;
316
+ const sql = commentOtherLine ( syntaxSql , pos . lineNumber ) ;
317
+ const entities = hive . getAllEntities ( sql , pos ) ;
318
+ expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeTruthy ( ) ;
319
+ } ) ;
320
+
321
+ test ( 'isContainCaret should be falsy if caret position is whitespace after semicolon' , ( ) => {
322
+ const pos : CaretPosition = {
323
+ lineNumber : 27 ,
324
+ column : 32 ,
325
+ } ;
326
+ const sql = commentOtherLine ( syntaxSql , pos . lineNumber ) ;
327
+ const entities = hive . getAllEntities ( sql , pos ) ;
328
+ expect ( entities [ 0 ] . belongStmt . isContainCaret ) . toBeFalsy ( ) ;
329
+ } ) ;
310
330
} ) ;
0 commit comments