Skip to content

Commit 294c059

Browse files
committed
cleanup
1 parent fff7377 commit 294c059

File tree

1 file changed

+10
-8
lines changed
  • crates/pg_workspace_new/src/workspace/server

1 file changed

+10
-8
lines changed

crates/pg_workspace_new/src/workspace/server/pg_query.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ pub struct SyntaxDiagnostic {
2626

2727
pub struct PgQueryStore {
2828
ast_db: DashMap<StatementRef, Arc<pg_query_ext::NodeEnum>>,
29-
diagnostics: DashMap<StatementRef, pg_query_ext::Error>,
29+
diagnostics: DashMap<StatementRef, SyntaxDiagnostic>,
3030
}
3131

32-
impl From<&pg_query_ext::Error> for SyntaxDiagnostic {
33-
fn from(err: &pg_query_ext::Error) -> Self {
32+
impl From<pg_query_ext::Error> for SyntaxDiagnostic {
33+
fn from(err: pg_query_ext::Error) -> Self {
3434
SyntaxDiagnostic {
3535
span: None,
3636
message: MessageAndDescription::from(err.to_string()),
@@ -47,9 +47,9 @@ impl PgQueryStore {
4747
}
4848

4949
pub fn pull_diagnostics(&self, ref_: &StatementRef) -> Vec<SDiagnostic> {
50-
self.diagnostics.get(ref_).map_or_else(Vec::new, |err| {
51-
vec![SDiagnostic::new(SyntaxDiagnostic::from(err.value()))]
52-
})
50+
self.diagnostics
51+
.get(ref_)
52+
.map_or_else(Vec::new, |err| vec![SDiagnostic::new(err.value().clone())])
5353
}
5454
}
5555

@@ -63,8 +63,10 @@ impl Store<pg_query_ext::NodeEnum> for PgQueryStore {
6363
if let Ok(ast) = r {
6464
self.ast_db.insert(statement.ref_.clone(), Arc::new(ast));
6565
} else {
66-
self.diagnostics
67-
.insert(statement.ref_.clone(), r.unwrap_err());
66+
self.diagnostics.insert(
67+
statement.ref_.clone(),
68+
SyntaxDiagnostic::from(r.unwrap_err()),
69+
);
6870
}
6971
}
7072

0 commit comments

Comments
 (0)