Skip to content

Commit 79e2810

Browse files
committed
fix: save
1 parent eeb64f5 commit 79e2810

File tree

6 files changed

+261
-1209
lines changed

6 files changed

+261
-1209
lines changed

crates/pg_lexer/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static PATTERN_LEXER: LazyLock<Regex> =
6565
fn 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;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)