@@ -462,4 +462,52 @@ describe('Impala SQL Syntax Suggestion', () => {
462462        expect ( suggestion ) . not . toBeUndefined ( ) ; 
463463        expect ( suggestion ?. wordRanges . map ( ( token )  =>  token . text ) ) . toEqual ( [ 'YEAR' ] ) ; 
464464    } ) ; 
465+ 
466+     test ( 'Syntax suggestion after a comment' ,  ( )  =>  { 
467+         const  sql  =  `-- the comment\nSELECT * FROM db.` ; 
468+         const  pos : CaretPosition  =  { 
469+             lineNumber : 2 , 
470+             column : 18 , 
471+         } ; 
472+ 
473+         const  syntaxes  =  impala . getSuggestionAtCaretPosition ( sql ,  pos ) ?. syntax ; 
474+         const  suggestion  =  syntaxes ?. find ( 
475+             ( syn )  =>  syn . syntaxContextType  ===  EntityContextType . TABLE 
476+         ) ; 
477+ 
478+         expect ( suggestion ) . not . toBeUndefined ( ) ; 
479+         expect ( suggestion ?. wordRanges . map ( ( token )  =>  token . text ) ) . toEqual ( [ 'db' ,  '.' ] ) ; 
480+     } ) ; 
481+ 
482+     test ( 'Syntax suggestion after comments' ,  ( )  =>  { 
483+         const  sql  =  `-- the comment 1\n-- the comment 2\nSELECT * FROM db.` ; 
484+         const  pos : CaretPosition  =  { 
485+             lineNumber : 3 , 
486+             column : 18 , 
487+         } ; 
488+ 
489+         const  syntaxes  =  impala . getSuggestionAtCaretPosition ( sql ,  pos ) ?. syntax ; 
490+         const  suggestion  =  syntaxes ?. find ( 
491+             ( syn )  =>  syn . syntaxContextType  ===  EntityContextType . TABLE 
492+         ) ; 
493+ 
494+         expect ( suggestion ) . not . toBeUndefined ( ) ; 
495+         expect ( suggestion ?. wordRanges . map ( ( token )  =>  token . text ) ) . toEqual ( [ 'db' ,  '.' ] ) ; 
496+     } ) ; 
497+ 
498+     test ( 'Syntax suggestion after comments' ,  ( )  =>  { 
499+         const  sql  =  `-- SELECT FROM t1;\n-- the comment 1\n-- the comment 2\nSELECT * FROM db.` ; 
500+         const  pos : CaretPosition  =  { 
501+             lineNumber : 4 , 
502+             column : 18 , 
503+         } ; 
504+ 
505+         const  syntaxes  =  impala . getSuggestionAtCaretPosition ( sql ,  pos ) ?. syntax ; 
506+         const  suggestion  =  syntaxes ?. find ( 
507+             ( syn )  =>  syn . syntaxContextType  ===  EntityContextType . TABLE 
508+         ) ; 
509+ 
510+         expect ( suggestion ) . not . toBeUndefined ( ) ; 
511+         expect ( suggestion ?. wordRanges . map ( ( token )  =>  token . text ) ) . toEqual ( [ 'db' ,  '.' ] ) ; 
512+     } ) ; 
465513} ) ; 
0 commit comments