Skip to content

Commit 5714d63

Browse files
authored
ide: goto def & hover tables refs in from clause (#772)
1 parent 138dbcf commit 5714d63

File tree

3 files changed

+226
-76
lines changed

3 files changed

+226
-76
lines changed

β€Žcrates/squawk_ide/src/goto_definition.rsβ€Ž

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,4 +1269,75 @@ delete from users where id$0 = 1 and active = true;
12691269
β•°β•΄ ─ 1. source
12701270
");
12711271
}
1272+
1273+
#[test]
1274+
fn goto_select_from_table() {
1275+
assert_snapshot!(goto("
1276+
create table users(id int, email text);
1277+
select * from users$0;
1278+
"), @r"
1279+
β•­β–Έ
1280+
2 β”‚ create table users(id int, email text);
1281+
β”‚ ───── 2. destination
1282+
3 β”‚ select * from users;
1283+
β•°β•΄ ─ 1. source
1284+
");
1285+
}
1286+
1287+
#[test]
1288+
fn goto_select_from_table_with_schema() {
1289+
assert_snapshot!(goto("
1290+
create table public.users(id int, email text);
1291+
select * from public.users$0;
1292+
"), @r"
1293+
β•­β–Έ
1294+
2 β”‚ create table public.users(id int, email text);
1295+
β”‚ ───── 2. destination
1296+
3 β”‚ select * from public.users;
1297+
β•°β•΄ ─ 1. source
1298+
");
1299+
}
1300+
1301+
#[test]
1302+
fn goto_select_from_table_with_search_path() {
1303+
assert_snapshot!(goto("
1304+
set search_path to foo;
1305+
create table foo.users(id int, email text);
1306+
select * from users$0;
1307+
"), @r"
1308+
β•­β–Έ
1309+
3 β”‚ create table foo.users(id int, email text);
1310+
β”‚ ───── 2. destination
1311+
4 β”‚ select * from users;
1312+
β•°β•΄ ─ 1. source
1313+
");
1314+
}
1315+
1316+
#[test]
1317+
fn goto_select_from_temp_table() {
1318+
assert_snapshot!(goto("
1319+
create temp table users(id int, email text);
1320+
select * from users$0;
1321+
"), @r"
1322+
β•­β–Έ
1323+
2 β”‚ create temp table users(id int, email text);
1324+
β”‚ ───── 2. destination
1325+
3 β”‚ select * from users;
1326+
β•°β•΄ ─ 1. source
1327+
");
1328+
}
1329+
1330+
#[test]
1331+
fn goto_select_from_table_defined_after() {
1332+
assert_snapshot!(goto("
1333+
select * from users$0;
1334+
create table users(id int, email text);
1335+
"), @r"
1336+
β•­β–Έ
1337+
2 β”‚ select * from users;
1338+
β”‚ ─ 1. source
1339+
3 β”‚ create table users(id int, email text);
1340+
β•°β•΄ ───── 2. destination
1341+
");
1342+
}
12721343
}

0 commit comments

Comments
Β (0)