-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
naive statement splitter #142
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
79e2810
fix: save
psteinroe 9ae67e0
fix: save
psteinroe 0d757f6
fix: ci
psteinroe 58c0374
fix: address pr feedback
psteinroe 3849cf7
refactor: parser now uses a pointer into the token vector instead of …
psteinroe 4e9dc81
add test helper
psteinroe 345b1ec
feat: add remaining dml statements
psteinroe 2d130d7
cleanup stmts
psteinroe d21f261
fix: handle insert update delete and select within unknown
psteinroe 1308770
fix: cleanup and fix some clippy warnings (sorry, unrelated)
psteinroe e2dba40
fix: handle create rule with select
psteinroe 9f15953
fix: make ntest a dev dep
psteinroe 5f08420
fix: build error
psteinroe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use std::{hash::Hash, hash::Hasher, ops::RangeBounds, usize}; | ||
use std::{hash::Hash, hash::Hasher, ops::RangeBounds}; | ||
|
||
use line_index::LineIndex; | ||
use text_size::{TextRange, TextSize}; | ||
|
@@ -44,18 +44,11 @@ impl Document { | |
pub fn new(url: PgLspPath, text: Option<String>) -> Document { | ||
Document { | ||
version: 0, | ||
line_index: LineIndex::new(&text.as_ref().unwrap_or(&"".to_string())), | ||
line_index: LineIndex::new(text.as_ref().unwrap_or(&"".to_string())), | ||
// TODO: use errors returned by split | ||
statement_ranges: text.as_ref().map_or_else( | ||
|| Vec::new(), | ||
|f| { | ||
pg_statement_splitter::split(&f) | ||
.ranges | ||
.iter() | ||
.map(|range| range.clone()) | ||
.collect() | ||
}, | ||
), | ||
statement_ranges: text.as_ref().map_or_else(Vec::new, |f| { | ||
pg_statement_splitter::split(f).ranges.to_vec() | ||
}), | ||
text: text.unwrap_or("".to_string()), | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretty cool changes here in the file! |
||
url, | ||
} | ||
|
@@ -99,7 +92,7 @@ impl Document { | |
.enumerate() | ||
.map(|(idx, range)| StatementRef { | ||
document_url: self.url.clone(), | ||
text: self.text[range.clone()].to_string(), | ||
text: self.text[range].to_string(), | ||
idx, | ||
}) | ||
.collect() | ||
|
@@ -112,10 +105,10 @@ impl Document { | |
.enumerate() | ||
.map(|(idx, range)| { | ||
( | ||
range.clone(), | ||
*range, | ||
StatementRef { | ||
document_url: self.url.clone(), | ||
text: self.text[range.clone()].to_string(), | ||
text: self.text[*range].to_string(), | ||
idx, | ||
}, | ||
) | ||
|
@@ -130,7 +123,7 @@ impl Document { | |
.enumerate() | ||
.map(|(idx, range)| StatementRef { | ||
document_url: self.url.clone(), | ||
text: self.text[range.clone()].to_string(), | ||
text: self.text[*range].to_string(), | ||
idx, | ||
}) | ||
.collect() | ||
|
@@ -142,7 +135,7 @@ impl Document { | |
.get(pos) | ||
.map(|range| StatementRef { | ||
document_url: self.url.clone(), | ||
text: self.text[range.clone()].to_string(), | ||
text: self.text[*range].to_string(), | ||
idx: pos, | ||
}) | ||
.unwrap() | ||
|
@@ -154,10 +147,10 @@ impl Document { | |
.get(pos) | ||
.map(|range| { | ||
( | ||
range.clone(), | ||
*range, | ||
StatementRef { | ||
document_url: self.url.clone(), | ||
text: self.text[range.clone()].to_string(), | ||
text: self.text[*range].to_string(), | ||
idx: pos, | ||
}, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ text-size = "1.1.1" | |
|
||
[dev-dependencies] | ||
pg_query = "0.8" | ||
ntest = "0.9.3" | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, strange that there's no method on the type for increasing the range 🤷