File tree Expand file tree Collapse file tree 6 files changed +261
-1209
lines changed
pg_statement_splitter/src Expand file tree Collapse file tree 6 files changed +261
-1209
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ static PATTERN_LEXER: LazyLock<Regex> =
6565fn whitespace_tokens ( input : & str ) -> VecDeque < Token > {
6666 let mut tokens = VecDeque :: new ( ) ;
6767
68- for cap in PATTERN_LEXER . captures_iter ( & input) {
68+ for cap in PATTERN_LEXER . captures_iter ( input) {
6969 if let Some ( whitespace) = cap. name ( "whitespace" ) {
7070 tokens. push_back ( Token {
7171 token_type : TokenType :: Whitespace ,
@@ -139,8 +139,8 @@ pub fn lex(text: &str) -> Vec<Token> {
139139 kind : SyntaxKind :: from ( & pg_query_token) ,
140140 text : token_text,
141141 span : TextRange :: new (
142- TextSize :: try_from ( u32:: try_from ( pg_query_token. start ) . unwrap ( ) ) . unwrap ( ) ,
143- TextSize :: try_from ( u32:: try_from ( pg_query_token. end ) . unwrap ( ) ) . unwrap ( ) ,
142+ TextSize :: from ( u32:: try_from ( pg_query_token. start ) . unwrap ( ) ) ,
143+ TextSize :: from ( u32:: try_from ( pg_query_token. end ) . unwrap ( ) ) ,
144144 ) ,
145145 } ) ;
146146 pos += len;
Original file line number Diff line number Diff line change 1+ use pg_lexer:: SyntaxKind ;
2+
3+ pub static STATEMENT_START_TOKENS : & [ SyntaxKind ] = & [
4+ SyntaxKind :: With ,
5+ SyntaxKind :: Select ,
6+ SyntaxKind :: Insert ,
7+ SyntaxKind :: Update ,
8+ SyntaxKind :: DeleteP ,
9+ SyntaxKind :: Create ,
10+ ] ;
11+
12+ pub ( crate ) fn at_statement_start ( kind : SyntaxKind ) -> bool {
13+ STATEMENT_START_TOKENS . contains ( & kind)
14+ }
You can’t perform that action at this time.
0 commit comments