-
Notifications
You must be signed in to change notification settings - Fork 102
refactor: drop change.rs <3 #447
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
Conversation
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.
very nice! much simpler, and I love that there's no separate ParsedDocument
anymore :)
/// Creates a child statement ID with the given content and parent content. | ||
pub fn new_child(child_content: &str, parent_content: &str) -> Self { | ||
StatementId::Child { | ||
content: child_content.into(), | ||
parent_content: parent_content.into(), | ||
} |
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.
Is this used/needed? feels like we could create orphaned childs with this – not a problem right now, but maybe leads to confusion in the future?
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.
nope, thanks!
} | ||
} | ||
|
||
pub fn parent(&self) -> Option<StatementId> { | ||
pub fn content(&self) -> &str { |
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.
love it
@@ -641,9 +637,9 @@ impl Workspace for WorkspaceServer { | |||
}); | |||
|
|||
tracing::debug!( | |||
"Found {} completion items for statement with id {}", | |||
"Found {} completion items for statement with id {:?}", |
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.
that's probably a lot of log output – not sure we even need the print
crates/pgt_lsp/src/capabilities.rs
Outdated
/// Instead, we manually list the command IDs we want to register. | ||
fn available_command_ids() -> Vec<String> { | ||
vec![ | ||
"postgres-tools.executeStatement".to_string(), |
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.
The ID in pgt_lsp/src/handlers/code_actions.rs
also needs to be adjusted 👍
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.
Also, we're now just sending the full statement over to the client anyway, so we might as well change the CommandActionCategory::ExecuteStatement(_) to hold a String
instead of a StatementId
– I think you can then use strum again :)
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.
ah good point!
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.
reverted my changes. I think its simpler to just add a comment to the default implementation
as per PR title. notable changes:
change.rs
in favour of a simpleupdate_document
api that replaces the contentStatementId
to just be a simple wrapper around the actual statement string. The content is wrapped in anArc<str>
to make cloning cheap. turns out string interning only makes sense when we have a lot of duplicate strings.Arc<str>
is much more efficient and simpler in our case.document.rs
and merge it intoparsed_document
to then rename it toDocument
strum
usage to get the available command because it didn't feel right to make an empty string the default for a StatementId. replaced it with a simple manual implementation.I ran a few benchmarks and the statement splitter performance seems to be good enough to run it on every keystroke on the entire file.
ToDo