Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/ty_ide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ ruff_python_trivia = { workspace = true }
ruff_source_file = { workspace = true }
ruff_text_size = { workspace = true }
ty_python_semantic = { workspace = true }
ty_project = { workspace = true, features = ["testing"] }

itertools = { workspace = true }
regex = { workspace = true }
rustc-hash = { workspace = true }
salsa = { workspace = true }
smallvec = { workspace = true }
tracing = { workspace = true }

[dev-dependencies]
ty_vendored = { workspace = true }

insta = { workspace = true, features = ["filters"] }

Expand Down
117 changes: 0 additions & 117 deletions crates/ty_ide/src/db.rs

This file was deleted.

10 changes: 6 additions & 4 deletions crates/ty_ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ mod tests {
};
use ruff_text_size::TextSize;

use crate::db::tests::TestDb;

use ruff_db::system::{DbWithWritableSystem, SystemPathBuf};
use ty_project::ProjectMetadata;
use ty_python_semantic::{
Program, ProgramSettings, PythonPlatform, PythonVersionWithSource, SearchPathSettings,
};
Expand All @@ -167,7 +166,10 @@ mod tests {
const START: &str = "<START>";
const END: &str = "<END>";

let mut db = TestDb::new();
let mut db = ty_project::TestDb::new(ProjectMetadata::new(
"test".into(),
SystemPathBuf::from("/"),
));

let start = source.find(START);
let end = source
Expand Down Expand Up @@ -205,7 +207,7 @@ mod tests {
}

pub(super) struct InlayHintTest {
pub(super) db: TestDb,
pub(super) db: ty_project::TestDb,
pub(super) file: File,
pub(super) range: TextRange,
}
Expand Down
13 changes: 8 additions & 5 deletions crates/ty_ide/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod completion;
mod db;
mod docstring;
mod find_node;
mod goto;
Expand All @@ -14,7 +13,6 @@ mod signature_help;
mod stub_mapping;

pub use completion::completion;
pub use db::Db;
pub use docstring::get_parameter_documentation;
pub use goto::{goto_declaration, goto_definition, goto_type_definition};
pub use hover::hover;
Expand All @@ -29,6 +27,7 @@ use ruff_db::files::{File, FileRange};
use ruff_text_size::{Ranged, TextRange};
use rustc_hash::FxHashSet;
use std::ops::{Deref, DerefMut};
use ty_project::Db;
use ty_python_semantic::types::{Type, TypeDefinition};

/// Information associated with a text range.
Expand Down Expand Up @@ -211,13 +210,13 @@ impl HasNavigationTargets for TypeDefinition<'_> {

#[cfg(test)]
mod tests {
use crate::db::tests::TestDb;
use insta::internals::SettingsBindDropGuard;
use ruff_db::Db;
use ruff_db::diagnostic::{Diagnostic, DiagnosticFormat, DisplayDiagnosticConfig};
use ruff_db::files::{File, system_path_to_file};
use ruff_db::system::{DbWithWritableSystem, SystemPath, SystemPathBuf};
use ruff_text_size::TextSize;
use ty_project::ProjectMetadata;
use ty_python_semantic::{
Program, ProgramSettings, PythonPlatform, PythonVersionWithSource, SearchPathSettings,
};
Expand All @@ -231,7 +230,7 @@ mod tests {
}

pub(super) struct CursorTest {
pub(super) db: TestDb,
pub(super) db: ty_project::TestDb,
pub(super) cursor: Cursor,
_insta_settings_guard: SettingsBindDropGuard,
}
Expand Down Expand Up @@ -286,7 +285,11 @@ mod tests {

impl CursorTestBuilder {
pub(super) fn build(&self) -> CursorTest {
let mut db = TestDb::new();
let mut db = ty_project::TestDb::new(ProjectMetadata::new(
"test".into(),
SystemPathBuf::from("/"),
));

let mut cursor: Option<Cursor> = None;
for &Source {
ref path,
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_project/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ruff_options_metadata = { workspace = true }
ruff_python_ast = { workspace = true, features = ["serde"] }
ruff_python_formatter = { workspace = true, optional = true }
ruff_text_size = { workspace = true }
ty_ide = { workspace = true }
ty_python_semantic = { workspace = true, features = ["serde"] }
ty_vendored = { workspace = true }

Expand Down Expand Up @@ -53,6 +52,7 @@ deflate = ["ty_vendored/deflate"]
schemars = ["dep:schemars", "ruff_db/schemars", "ty_python_semantic/schemars"]
zstd = ["ty_vendored/zstd"]
format = ["ruff_python_formatter"]
testing = []

[lints]
workspace = true
12 changes: 4 additions & 8 deletions crates/ty_project/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use ruff_db::system::System;
use ruff_db::vendored::VendoredFileSystem;
use salsa::plumbing::ZalsaDatabase;
use salsa::{Event, Setter};
use ty_ide::Db as IdeDb;
use ty_python_semantic::lint::{LintRegistry, RuleSelection};
use ty_python_semantic::{Db as SemanticDb, Program};

Expand Down Expand Up @@ -404,9 +403,6 @@ impl SalsaMemoryDump {
}
}

#[salsa::db]
impl IdeDb for ProjectDatabase {}

#[salsa::db]
impl SemanticDb for ProjectDatabase {
fn should_check_file(&self, file: File) -> bool {
Expand Down Expand Up @@ -468,7 +464,7 @@ mod format {
}
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub(crate) mod tests {
use std::sync::{Arc, Mutex};

Expand All @@ -487,7 +483,7 @@ pub(crate) mod tests {

#[salsa::db]
#[derive(Clone)]
pub(crate) struct TestDb {
pub struct TestDb {
storage: salsa::Storage<Self>,
events: Events,
files: Files,
Expand All @@ -497,7 +493,7 @@ pub(crate) mod tests {
}

impl TestDb {
pub(crate) fn new(project: ProjectMetadata) -> Self {
pub fn new(project: ProjectMetadata) -> Self {
let events = Events::default();
let mut db = Self {
storage: salsa::Storage::new(Some(Box::new({
Expand All @@ -522,7 +518,7 @@ pub(crate) mod tests {

impl TestDb {
/// Takes the salsa events.
pub(crate) fn take_salsa_events(&mut self) -> Vec<salsa::Event> {
pub fn take_salsa_events(&mut self) -> Vec<salsa::Event> {
let mut events = self.events.lock().unwrap();

std::mem::take(&mut *events)
Expand Down
2 changes: 2 additions & 0 deletions crates/ty_project/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::glob::{GlobFilterCheckMode, IncludeResult};
use crate::metadata::options::{OptionDiagnostic, ToSettingsError};
use crate::walk::{ProjectFilesFilter, ProjectFilesWalker};
#[cfg(feature = "testing")]
pub use db::tests::TestDb;
pub use db::{ChangeResult, CheckMode, Db, ProjectDatabase, SalsaMemoryDump};
use files::{Index, Indexed, IndexedFiles};
use metadata::settings::Settings;
Expand Down
7 changes: 4 additions & 3 deletions crates/ty_server/src/document/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use lsp_types::Location;
use ruff_db::files::FileRange;
use ruff_db::source::{line_index, source_text};
use ruff_text_size::Ranged;
use ty_ide::{Db, NavigationTarget};
use ty_ide::NavigationTarget;
use ty_project::Db;

pub(crate) trait ToLink {
fn to_location(&self, db: &dyn ty_ide::Db, encoding: PositionEncoding) -> Option<Location>;
fn to_location(&self, db: &dyn Db, encoding: PositionEncoding) -> Option<Location>;

fn to_link(
&self,
db: &dyn ty_ide::Db,
db: &dyn Db,
src: Option<FileRange>,
encoding: PositionEncoding,
) -> Option<lsp_types::LocationLink>;
Expand Down
Loading