mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
⬆️ salsa
This commit is contained in:
parent
454cc31358
commit
a2ca03d10b
14 changed files with 172 additions and 216 deletions
|
@ -1,7 +1,9 @@
|
|||
use std::{fmt, sync::Arc};
|
||||
|
||||
use salsa::{self, Database};
|
||||
use ra_db::{LocationIntener, BaseDatabase, FileId, Canceled};
|
||||
use ra_db::{
|
||||
LocationIntener, BaseDatabase, FileId, Canceled,
|
||||
salsa::{self, Database},
|
||||
};
|
||||
|
||||
use crate::{symbol_index, LineIndex};
|
||||
|
||||
|
@ -73,12 +75,9 @@ impl AsRef<LocationIntener<hir::MacroCallLoc, hir::MacroCallId>> for RootDatabas
|
|||
}
|
||||
}
|
||||
|
||||
salsa::query_group! {
|
||||
pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase {
|
||||
fn line_index(file_id: FileId) -> Arc<LineIndex> {
|
||||
type LineIndexQuery;
|
||||
}
|
||||
}
|
||||
#[salsa::query_group]
|
||||
pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase {
|
||||
fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
|
||||
}
|
||||
|
||||
fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex> {
|
||||
|
@ -109,10 +108,10 @@ salsa::database_storage! {
|
|||
}
|
||||
impl hir::db::HirDatabase {
|
||||
fn hir_source_file() for hir::db::HirSourceFileQuery;
|
||||
fn expand_macro_invocation() for hir::db::ExpandMacroCallQuery;
|
||||
fn expand_macro_invocation() for hir::db::ExpandMacroInvocationQuery;
|
||||
fn module_tree() for hir::db::ModuleTreeQuery;
|
||||
fn fn_scopes() for hir::db::FnScopesQuery;
|
||||
fn file_items() for hir::db::SourceFileItemsQuery;
|
||||
fn file_items() for hir::db::FileItemsQuery;
|
||||
fn file_item() for hir::db::FileItemQuery;
|
||||
fn input_module_items() for hir::db::InputModuleItemsQuery;
|
||||
fn item_map() for hir::db::ItemMapQuery;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use salsa::Database;
|
||||
|
||||
use hir::{
|
||||
self, Problem, source_binder,
|
||||
};
|
||||
use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase};
|
||||
use ra_db::{
|
||||
FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase,
|
||||
salsa::{self, Database},
|
||||
};
|
||||
use ra_ide_api_light::{self, assists, LocalEdit, Severity};
|
||||
use ra_syntax::{
|
||||
TextRange, AstNode, SourceFile,
|
||||
|
@ -89,7 +90,7 @@ impl db::RootDatabase {
|
|||
fn gc_syntax_trees(&mut self) {
|
||||
self.query(ra_db::SourceFileQuery)
|
||||
.sweep(salsa::SweepStrategy::default().discard_values());
|
||||
self.query(hir::db::SourceFileItemsQuery)
|
||||
self.query(hir::db::FileItemsQuery)
|
||||
.sweep(salsa::SweepStrategy::default().discard_values());
|
||||
self.query(hir::db::FileItemQuery)
|
||||
.sweep(salsa::SweepStrategy::default().discard_values());
|
||||
|
|
|
@ -28,11 +28,13 @@ use std::{fmt, sync::Arc};
|
|||
|
||||
use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit};
|
||||
use ra_text_edit::TextEdit;
|
||||
use ra_db::{SyntaxDatabase, FilesDatabase, BaseDatabase};
|
||||
use ra_db::{
|
||||
SyntaxDatabase, FilesDatabase, BaseDatabase,
|
||||
salsa::{self, ParallelDatabase},
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use relative_path::RelativePathBuf;
|
||||
use rustc_hash::FxHashMap;
|
||||
use salsa::ParallelDatabase;
|
||||
|
||||
use crate::{
|
||||
symbol_index::{FileSymbol, SymbolIndex},
|
||||
|
|
|
@ -32,8 +32,10 @@ use ra_syntax::{
|
|||
SyntaxKind::{self, *},
|
||||
ast::{self, NameOwner},
|
||||
};
|
||||
use ra_db::{SourceRootId, FilesDatabase, LocalSyntaxPtr};
|
||||
use salsa::ParallelDatabase;
|
||||
use ra_db::{
|
||||
SourceRootId, FilesDatabase, LocalSyntaxPtr,
|
||||
salsa::{self, ParallelDatabase},
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::{
|
||||
|
@ -41,16 +43,11 @@ use crate::{
|
|||
db::RootDatabase,
|
||||
};
|
||||
|
||||
salsa::query_group! {
|
||||
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
|
||||
fn file_symbols(file_id: FileId) -> Arc<SymbolIndex> {
|
||||
type FileSymbolsQuery;
|
||||
}
|
||||
fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> {
|
||||
type LibrarySymbolsQuery;
|
||||
storage input;
|
||||
}
|
||||
}
|
||||
#[salsa::query_group]
|
||||
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
|
||||
fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>;
|
||||
#[salsa::input]
|
||||
fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>;
|
||||
}
|
||||
|
||||
fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue