[ty] Attach salsa db when running ide tests for easier debugging (#21917)

This commit is contained in:
Micha Reiser 2025-12-11 19:03:52 +01:00 committed by GitHub
parent fbeeb050af
commit c9fe4e2703
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 12 deletions

View File

@ -2785,8 +2785,9 @@ def ab(a: int, *, c: int): ...
impl CursorTest {
fn goto_declaration(&self) -> String {
let Some(targets) = goto_declaration(&self.db, self.cursor.file, self.cursor.offset)
else {
let Some(targets) = salsa::attach(&self.db, || {
goto_declaration(&self.db, self.cursor.file, self.cursor.offset)
}) else {
return "No goto target found".to_string();
};

View File

@ -1697,8 +1697,9 @@ Traceb<CURSOR>ackType
impl CursorTest {
fn goto_definition(&self) -> String {
let Some(targets) = goto_definition(&self.db, self.cursor.file, self.cursor.offset)
else {
let Some(targets) = salsa::attach(&self.db, || {
goto_definition(&self.db, self.cursor.file, self.cursor.offset)
}) else {
return "No goto target found".to_string();
};

View File

@ -1900,9 +1900,9 @@ def function():
impl CursorTest {
fn goto_type_definition(&self) -> String {
let Some(targets) =
let Some(targets) = salsa::attach(&self.db, || {
goto_type_definition(&self.db, self.cursor.file, self.cursor.offset)
else {
}) else {
return "No goto target found".to_string();
};

View File

@ -98,7 +98,9 @@ mod tests {
impl CursorTest {
fn prepare_rename(&self) -> String {
let Some(range) = can_rename(&self.db, self.cursor.file, self.cursor.offset) else {
let Some(range) = salsa::attach(&self.db, || {
can_rename(&self.db, self.cursor.file, self.cursor.offset)
}) else {
return "Cannot rename".to_string();
};
@ -106,13 +108,13 @@ mod tests {
}
fn rename(&self, new_name: &str) -> String {
let Some(_) = can_rename(&self.db, self.cursor.file, self.cursor.offset) else {
return "Cannot rename".to_string();
};
let rename_results = salsa::attach(&self.db, || {
can_rename(&self.db, self.cursor.file, self.cursor.offset)?;
let Some(rename_results) =
rename(&self.db, self.cursor.file, self.cursor.offset, new_name)
else {
});
let Some(rename_results) = rename_results else {
return "Cannot rename".to_string();
};