Skip to content

Commit fbeedb8

Browse files
rename
1 parent 926de5d commit fbeedb8

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

crates/pgt_statement_splitter/src/splitter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub use common::source;
88
use pgt_lexer::{Lexed, SyntaxKind};
99
use pgt_text_size::TextRange;
1010

11-
use crate::splitter::common::SplitterException;
11+
use crate::splitter::common::ReachedEOFException;
1212

1313
pub struct SplitResult {
1414
pub ranges: Vec<TextRange>,
@@ -105,7 +105,7 @@ impl<'a> Splitter<'a> {
105105
self.lexed.kind(self.current_pos)
106106
}
107107

108-
fn eat(&mut self, kind: SyntaxKind) -> Result<bool, SplitterException> {
108+
fn eat(&mut self, kind: SyntaxKind) -> Result<bool, ReachedEOFException> {
109109
if self.current() == kind {
110110
self.advance()?;
111111
Ok(true)
@@ -121,9 +121,9 @@ impl<'a> Splitter<'a> {
121121
/// Advances the parser to the next relevant token and returns it.
122122
///
123123
/// NOTE: This will skip trivia tokens.
124-
fn advance(&mut self) -> Result<SyntaxKind, SplitterException> {
124+
fn advance(&mut self) -> Result<SyntaxKind, ReachedEOFException> {
125125
if self.current() == SyntaxKind::EOF {
126-
return Err(SplitterException);
126+
return Err(ReachedEOFException);
127127
}
128128

129129
let pos = (self.current_pos + 1..self.lexed.len())
@@ -171,7 +171,7 @@ impl<'a> Splitter<'a> {
171171

172172
/// Will advance if the `kind` matches the current token.
173173
/// Otherwise, will add a diagnostic to the internal `errors`.
174-
fn expect(&mut self, kind: SyntaxKind) -> Result<(), SplitterException> {
174+
fn expect(&mut self, kind: SyntaxKind) -> Result<(), ReachedEOFException> {
175175
if self.current() == kind {
176176
self.advance()?;
177177
} else {

crates/pgt_statement_splitter/src/splitter/common.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ use super::{
1111
};
1212

1313
#[derive(Debug)]
14-
pub struct SplitterException;
14+
pub struct ReachedEOFException;
1515

16-
impl std::fmt::Display for SplitterException {
16+
impl std::fmt::Display for ReachedEOFException {
1717
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18-
// todo
19-
write!(f, "SplitterException")
18+
write!(f, "ReachedEOFException")
2019
}
2120
}
2221

23-
impl Error for SplitterException {}
22+
impl Error for ReachedEOFException {}
2423

25-
pub fn source(p: &mut Splitter) -> Result<(), SplitterException> {
24+
pub fn source(p: &mut Splitter) -> Result<(), ReachedEOFException> {
2625
loop {
2726
match p.current() {
2827
SyntaxKind::EOF => {
@@ -43,7 +42,7 @@ pub fn source(p: &mut Splitter) -> Result<(), SplitterException> {
4342
Ok(())
4443
}
4544

46-
pub(crate) fn statement(p: &mut Splitter) -> Result<(), SplitterException> {
45+
pub(crate) fn statement(p: &mut Splitter) -> Result<(), ReachedEOFException> {
4746
p.start_stmt();
4847

4948
// Currently, Err means that we reached EOF.
@@ -65,7 +64,7 @@ pub(crate) fn statement(p: &mut Splitter) -> Result<(), SplitterException> {
6564
Ok(())
6665
}
6766

68-
pub(crate) fn begin_end(p: &mut Splitter) -> Result<(), SplitterException> {
67+
pub(crate) fn begin_end(p: &mut Splitter) -> Result<(), ReachedEOFException> {
6968
p.expect(SyntaxKind::BEGIN_KW)?;
7069

7170
let mut depth = 1;
@@ -94,7 +93,7 @@ pub(crate) fn begin_end(p: &mut Splitter) -> Result<(), SplitterException> {
9493
Ok(())
9594
}
9695

97-
pub(crate) fn parenthesis(p: &mut Splitter) -> Result<(), SplitterException> {
96+
pub(crate) fn parenthesis(p: &mut Splitter) -> Result<(), ReachedEOFException> {
9897
p.expect(SyntaxKind::L_PAREN)?;
9998

10099
let mut depth = 1;
@@ -123,7 +122,7 @@ pub(crate) fn parenthesis(p: &mut Splitter) -> Result<(), SplitterException> {
123122
Ok(())
124123
}
125124

126-
pub(crate) fn plpgsql_command(p: &mut Splitter) -> Result<(), SplitterException> {
125+
pub(crate) fn plpgsql_command(p: &mut Splitter) -> Result<(), ReachedEOFException> {
127126
p.expect(SyntaxKind::BACKSLASH)?;
128127

129128
loop {
@@ -143,7 +142,7 @@ pub(crate) fn plpgsql_command(p: &mut Splitter) -> Result<(), SplitterException>
143142
Ok(())
144143
}
145144

146-
pub(crate) fn case(p: &mut Splitter) -> Result<(), SplitterException> {
145+
pub(crate) fn case(p: &mut Splitter) -> Result<(), ReachedEOFException> {
147146
p.expect(SyntaxKind::CASE_KW)?;
148147

149148
loop {
@@ -161,7 +160,7 @@ pub(crate) fn case(p: &mut Splitter) -> Result<(), SplitterException> {
161160
Ok(())
162161
}
163162

164-
pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) -> Result<(), SplitterException> {
163+
pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) -> Result<(), ReachedEOFException> {
165164
loop {
166165
match p.current() {
167166
SyntaxKind::SEMICOLON => {

crates/pgt_statement_splitter/src/splitter/ddl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use pgt_lexer::SyntaxKind;
22

3-
use crate::splitter::common::SplitterException;
3+
use crate::splitter::common::ReachedEOFException;
44

55
use super::{Splitter, common::unknown};
66

7-
pub(crate) fn create(p: &mut Splitter) -> Result<(), SplitterException> {
7+
pub(crate) fn create(p: &mut Splitter) -> Result<(), ReachedEOFException> {
88
p.expect(SyntaxKind::CREATE_KW)?;
99

1010
unknown(p, &[SyntaxKind::WITH_KW])
1111
}
1212

13-
pub(crate) fn alter(p: &mut Splitter) -> Result<(), SplitterException> {
13+
pub(crate) fn alter(p: &mut Splitter) -> Result<(), ReachedEOFException> {
1414
p.expect(SyntaxKind::ALTER_KW)?;
1515

1616
unknown(p, &[SyntaxKind::ALTER_KW])

crates/pgt_statement_splitter/src/splitter/dml.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use pgt_lexer::SyntaxKind;
22

3-
use crate::splitter::common::SplitterException;
3+
use crate::splitter::common::ReachedEOFException;
44

55
use super::{
66
Splitter,
77
common::{parenthesis, unknown},
88
};
99

10-
pub(crate) fn cte(p: &mut Splitter) -> Result<(), SplitterException> {
10+
pub(crate) fn cte(p: &mut Splitter) -> Result<(), ReachedEOFException> {
1111
p.expect(SyntaxKind::WITH_KW)?;
1212
p.eat(SyntaxKind::RECURSIVE_KW)?;
1313

@@ -36,26 +36,26 @@ pub(crate) fn cte(p: &mut Splitter) -> Result<(), SplitterException> {
3636
Ok(())
3737
}
3838

39-
pub(crate) fn select(p: &mut Splitter) -> Result<(), SplitterException> {
39+
pub(crate) fn select(p: &mut Splitter) -> Result<(), ReachedEOFException> {
4040
p.expect(SyntaxKind::SELECT_KW)?;
4141

4242
unknown(p, &[])
4343
}
4444

45-
pub(crate) fn insert(p: &mut Splitter) -> Result<(), SplitterException> {
45+
pub(crate) fn insert(p: &mut Splitter) -> Result<(), ReachedEOFException> {
4646
p.expect(SyntaxKind::INSERT_KW)?;
4747
p.expect(SyntaxKind::INTO_KW)?;
4848

4949
unknown(p, &[SyntaxKind::SELECT_KW])
5050
}
5151

52-
pub(crate) fn update(p: &mut Splitter) -> Result<(), SplitterException> {
52+
pub(crate) fn update(p: &mut Splitter) -> Result<(), ReachedEOFException> {
5353
p.expect(SyntaxKind::UPDATE_KW)?;
5454

5555
unknown(p, &[])
5656
}
5757

58-
pub(crate) fn delete(p: &mut Splitter) -> Result<(), SplitterException> {
58+
pub(crate) fn delete(p: &mut Splitter) -> Result<(), ReachedEOFException> {
5959
p.expect(SyntaxKind::DELETE_KW)?;
6060
p.expect(SyntaxKind::FROM_KW)?;
6161

0 commit comments

Comments
 (0)