Skip to content

Commit 1a7cc0f

Browse files
resolve
2 parents 03a06b3 + 4867189 commit 1a7cc0f

23 files changed

+981
-578
lines changed

.github/workflows/publish.reusable.yml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
runs-on: ubuntu-latest
1717
permissions:
1818
contents: write
19-
# ? what's this?! required for executing the node script?
2019
id-token: write
2120
steps:
2221
- uses: actions/checkout@v4

.github/workflows/pull_request.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,20 @@ jobs:
102102
version: latest
103103
- name: Run Lints
104104
run: |
105+
cargo sqlx prepare --check --workspace
105106
cargo clippy
106107
cargo run -p rules_check
107108
biome lint
108-
cargo sqlx prepare --check --workspace
109109
110110
test:
111111
name: Test
112112
runs-on: ${{ matrix.os }}
113113
strategy:
114114
matrix:
115115
include:
116-
# reactive once we upgrade to the latest version of pg_query that is windows-compatible
117-
- os: windows-latest
118-
- os: ubuntu-latest
116+
# use the same images we use for compiling
117+
- os: windows-2022
118+
- os: ubuntu-22.04
119119
steps:
120120
- name: Checkout PR branch
121121
uses: actions/checkout@v4
@@ -138,8 +138,10 @@ jobs:
138138
run: cargo test --workspace
139139

140140
test-js-bindings:
141-
name: Test JS Bindings
142-
runs-on: ubuntu-latest
141+
name:
142+
Test JS Bindings
143+
# use the same image we use for compiling
144+
runs-on: ubuntu-22.04
143145
services:
144146
postgres:
145147
image: postgres:latest
@@ -173,7 +175,7 @@ jobs:
173175

174176
codegen:
175177
name: Check Codegen
176-
runs-on: ubuntu-latest
178+
runs-on: ubuntu-22.04
177179
services:
178180
postgres:
179181
image: postgres:latest

.github/workflows/release.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
strategy:
3838
matrix:
3939
config:
40-
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
41-
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu }
42-
- { os: macos-latest, target: x86_64-apple-darwin }
43-
- { os: macos-latest, target: aarch64-apple-darwin }
44-
- { os: windows-latest, target: x86_64-pc-windows-msvc }
45-
- { os: windows-latest, target: aarch64-pc-windows-msvc }
40+
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
41+
- { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu }
42+
- { os: macos-14, target: x86_64-apple-darwin }
43+
- { os: macos-14, target: aarch64-apple-darwin }
44+
- { os: windows-2022, target: x86_64-pc-windows-msvc }
45+
- { os: windows-2022, target: aarch64-pc-windows-msvc }
4646

4747
runs-on: ${{ matrix.config.os }}
4848

@@ -87,12 +87,12 @@ jobs:
8787

8888
# windows is a special snowflake too, it saves binaries as .exe
8989
- name: 👦 Name the Binary
90-
if: matrix.config.os == 'windows-latest'
90+
if: matrix.config.os == 'windows-2022'
9191
run: |
9292
mkdir dist
9393
cp target/${{ matrix.config.target }}/release/postgrestools.exe ./dist/postgrestools_${{ matrix.config.target }}
9494
- name: 👦 Name the Binary
95-
if: matrix.config.os != 'windows-latest'
95+
if: matrix.config.os != 'windows-2022'
9696
run: |
9797
mkdir dist
9898
cp target/${{ matrix.config.target }}/release/postgrestools ./dist/postgrestools_${{ matrix.config.target }}

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ syn = "1.0.109"
4646
termcolor = "1.4.1"
4747
test-log = "0.2.17"
4848
tokio = { version = "1.40.0", features = ["full"] }
49-
tower-lsp = "0.20.0"
5049
tracing = { version = "0.1.40", default-features = false, features = ["std"] }
5150
tracing-bunyan-formatter = { version = "0.3.10 " }
5251
tracing-subscriber = "0.3.18"
@@ -57,7 +56,6 @@ unicode-width = "0.1.12"
5756
# postgres specific crates
5857
pgt_analyse = { path = "./crates/pgt_analyse", version = "0.0.0" }
5958
pgt_analyser = { path = "./crates/pgt_analyser", version = "0.0.0" }
60-
pgt_base_db = { path = "./crates/pgt_base_db", version = "0.0.0" }
6159
pgt_cli = { path = "./crates/pgt_cli", version = "0.0.0" }
6260
pgt_completions = { path = "./crates/pgt_completions", version = "0.0.0" }
6361
pgt_configuration = { path = "./crates/pgt_configuration", version = "0.0.0" }
@@ -69,9 +67,7 @@ pgt_flags = { path = "./crates/pgt_flags", version = "0.0.0" }
6967
pgt_fs = { path = "./crates/pgt_fs", version = "0.0.0" }
7068
pgt_lexer = { path = "./crates/pgt_lexer", version = "0.0.0" }
7169
pgt_lexer_codegen = { path = "./crates/pgt_lexer_codegen", version = "0.0.0" }
72-
pgt_lint = { path = "./crates/pgt_lint", version = "0.0.0" }
7370
pgt_lsp = { path = "./crates/pgt_lsp", version = "0.0.0" }
74-
pgt_lsp_converters = { path = "./crates/pgt_lsp_converters", version = "0.0.0" }
7571
pgt_markup = { path = "./crates/pgt_markup", version = "0.0.0" }
7672
pgt_query_ext = { path = "./crates/pgt_query_ext", version = "0.0.0" }
7773
pgt_query_ext_codegen = { path = "./crates/pgt_query_ext_codegen", version = "0.0.0" }
@@ -81,14 +77,11 @@ pgt_statement_splitter = { path = "./crates/pgt_statement_splitter", version
8177
pgt_text_edit = { path = "./crates/pgt_text_edit", version = "0.0.0" }
8278
pgt_text_size = { path = "./crates/pgt_text_size", version = "0.0.0" }
8379
pgt_treesitter_queries = { path = "./crates/pgt_treesitter_queries", version = "0.0.0" }
84-
pgt_type_resolver = { path = "./crates/pgt_type_resolver", version = "0.0.0" }
8580
pgt_typecheck = { path = "./crates/pgt_typecheck", version = "0.0.0" }
8681
pgt_workspace = { path = "./crates/pgt_workspace", version = "0.0.0" }
8782

8883
pgt_test_macros = { path = "./crates/pgt_test_macros" }
8984
pgt_test_utils = { path = "./crates/pgt_test_utils" }
9085

91-
docs_codegen = { path = "./docs/codegen", version = "0.0.0" }
92-
9386
[profile.dev.package]
9487
insta.opt-level = 3

crates/pgt_completions/src/complete.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct CompletionParams<'a> {
1515
pub position: TextSize,
1616
pub schema: &'a pgt_schema_cache::SchemaCache,
1717
pub text: String,
18-
pub tree: Option<&'a tree_sitter::Tree>,
18+
pub tree: &'a tree_sitter::Tree,
1919
}
2020

2121
#[tracing::instrument(level = "debug", skip_all, fields(

crates/pgt_completions/src/sanitization.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,9 @@ where
2323
type Error = String;
2424

2525
fn try_from(params: CompletionParams<'larger>) -> Result<Self, Self::Error> {
26-
let tree = match &params.tree {
27-
Some(tree) => tree,
28-
None => return Err("Tree required for autocompletions.".to_string()),
29-
};
30-
31-
if cursor_inbetween_nodes(tree, params.position)
32-
|| cursor_prepared_to_write_token_after_last_node(tree, params.position)
33-
|| cursor_before_semicolon(tree, params.position)
26+
if cursor_inbetween_nodes(params.tree, params.position)
27+
|| cursor_prepared_to_write_token_after_last_node(params.tree, params.position)
28+
|| cursor_before_semicolon(params.tree, params.position)
3429
{
3530
Ok(SanitizedCompletionParams::with_adjusted_sql(params))
3631
} else {
@@ -75,7 +70,7 @@ where
7570
position: params.position,
7671
text: params.text.clone(),
7772
schema: params.schema,
78-
tree: Cow::Borrowed(params.tree.unwrap()),
73+
tree: Cow::Borrowed(params.tree),
7974
}
8075
}
8176

crates/pgt_completions/src/test_helper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(crate) fn get_test_params<'a>(
6969
CompletionParams {
7070
position: (position as u32).into(),
7171
schema: schema_cache,
72-
tree: Some(tree),
72+
tree,
7373
text,
7474
}
7575
}

crates/pgt_lsp/src/handlers/code_actions.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn get_actions(
4343
title: title.clone(),
4444
command: command_id,
4545
arguments: Some(vec![
46-
serde_json::Value::Number(stmt_id.into()),
46+
serde_json::to_value(&stmt_id).unwrap(),
4747
serde_json::to_value(&url).unwrap(),
4848
]),
4949
}
@@ -81,17 +81,16 @@ pub async fn execute_command(
8181

8282
match command.as_str() {
8383
"pgt.executeStatement" => {
84-
let id: usize = serde_json::from_value(params.arguments[0].clone())?;
84+
let statement_id = serde_json::from_value::<pgt_workspace::workspace::StatementId>(
85+
params.arguments[0].clone(),
86+
)?;
8587
let doc_url: lsp_types::Url = serde_json::from_value(params.arguments[1].clone())?;
8688

8789
let path = session.file_path(&doc_url)?;
8890

8991
let result = session
9092
.workspace
91-
.execute_statement(ExecuteStatementParams {
92-
statement_id: id,
93-
path,
94-
})?;
93+
.execute_statement(ExecuteStatementParams { statement_id, path })?;
9594

9695
/*
9796
* Updating all diagnostics: the changes caused by the statement execution

crates/pgt_typecheck/src/diagnostics.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,22 @@ impl Advices for TypecheckAdvices {
9696

9797
pub(crate) fn create_type_error(
9898
pg_err: &PgDatabaseError,
99-
ts: Option<&tree_sitter::Tree>,
99+
ts: &tree_sitter::Tree,
100100
) -> TypecheckDiagnostic {
101101
let position = pg_err.position().and_then(|pos| match pos {
102102
sqlx::postgres::PgErrorPosition::Original(pos) => Some(pos - 1),
103103
_ => None,
104104
});
105105

106106
let range = position.and_then(|pos| {
107-
ts.and_then(|tree| {
108-
tree.root_node()
109-
.named_descendant_for_byte_range(pos, pos)
110-
.map(|node| {
111-
TextRange::new(
112-
node.start_byte().try_into().unwrap(),
113-
node.end_byte().try_into().unwrap(),
114-
)
115-
})
116-
})
107+
ts.root_node()
108+
.named_descendant_for_byte_range(pos, pos)
109+
.map(|node| {
110+
TextRange::new(
111+
node.start_byte().try_into().unwrap(),
112+
node.end_byte().try_into().unwrap(),
113+
)
114+
})
117115
});
118116

119117
let severity = match pg_err.severity() {

crates/pgt_typecheck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct TypecheckParams<'a> {
1313
pub conn: &'a PgPool,
1414
pub sql: &'a str,
1515
pub ast: &'a pgt_query_ext::NodeEnum,
16-
pub tree: Option<&'a tree_sitter::Tree>,
16+
pub tree: &'a tree_sitter::Tree,
1717
}
1818

1919
#[derive(Debug, Clone)]

crates/pgt_typecheck/tests/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ async fn test(name: &str, query: &str, setup: &str) {
2121
.expect("Error loading sql language");
2222

2323
let root = pgt_query_ext::parse(query).unwrap();
24-
let tree = parser.parse(query, None);
24+
let tree = parser.parse(query, None).unwrap();
2525

2626
let conn = &test_db;
2727
let result = check_sql(TypecheckParams {
2828
conn,
2929
sql: query,
3030
ast: &root,
31-
tree: tree.as_ref(),
31+
tree: &tree,
3232
})
3333
.await;
3434

crates/pgt_workspace/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ futures = "0.3.31"
1818
globset = "0.4.16"
1919

2020
ignore = { workspace = true }
21-
itertools = { version = "0.14.0" }
2221
pgt_analyse = { workspace = true, features = ["serde"] }
2322
pgt_analyser = { workspace = true }
2423
pgt_completions = { workspace = true }

0 commit comments

Comments
 (0)