mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Move Query
This commit is contained in:
parent
ad247aa670
commit
0509a0a34e
2 changed files with 42 additions and 41 deletions
|
@ -40,7 +40,47 @@ use ra_syntax::{
|
||||||
#[cfg(not(feature = "wasm"))]
|
#[cfg(not(feature = "wasm"))]
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{ide_db::RootDatabase, Query};
|
use crate::ide_db::RootDatabase;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Query {
|
||||||
|
query: String,
|
||||||
|
lowercased: String,
|
||||||
|
only_types: bool,
|
||||||
|
libs: bool,
|
||||||
|
exact: bool,
|
||||||
|
limit: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Query {
|
||||||
|
pub fn new(query: String) -> Query {
|
||||||
|
let lowercased = query.to_lowercase();
|
||||||
|
Query {
|
||||||
|
query,
|
||||||
|
lowercased,
|
||||||
|
only_types: false,
|
||||||
|
libs: false,
|
||||||
|
exact: false,
|
||||||
|
limit: usize::max_value(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn only_types(&mut self) {
|
||||||
|
self.only_types = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn libs(&mut self) {
|
||||||
|
self.libs = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn exact(&mut self) {
|
||||||
|
self.exact = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn limit(&mut self, limit: usize) {
|
||||||
|
self.limit = limit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[salsa::query_group(SymbolsDatabaseStorage)]
|
#[salsa::query_group(SymbolsDatabaseStorage)]
|
||||||
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
|
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
|
||||||
|
|
|
@ -78,6 +78,7 @@ pub use crate::{
|
||||||
feature_flags::FeatureFlags,
|
feature_flags::FeatureFlags,
|
||||||
line_index::{LineCol, LineIndex},
|
line_index::{LineCol, LineIndex},
|
||||||
line_index_utils::translate_offset_with_edit,
|
line_index_utils::translate_offset_with_edit,
|
||||||
|
symbol_index::Query,
|
||||||
},
|
},
|
||||||
inlay_hints::{InlayHint, InlayKind},
|
inlay_hints::{InlayHint, InlayKind},
|
||||||
references::{
|
references::{
|
||||||
|
@ -103,46 +104,6 @@ pub struct Diagnostic {
|
||||||
pub severity: Severity,
|
pub severity: Severity,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Query {
|
|
||||||
query: String,
|
|
||||||
lowercased: String,
|
|
||||||
only_types: bool,
|
|
||||||
libs: bool,
|
|
||||||
exact: bool,
|
|
||||||
limit: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Query {
|
|
||||||
pub fn new(query: String) -> Query {
|
|
||||||
let lowercased = query.to_lowercase();
|
|
||||||
Query {
|
|
||||||
query,
|
|
||||||
lowercased,
|
|
||||||
only_types: false,
|
|
||||||
libs: false,
|
|
||||||
exact: false,
|
|
||||||
limit: usize::max_value(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn only_types(&mut self) {
|
|
||||||
self.only_types = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn libs(&mut self) {
|
|
||||||
self.libs = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn exact(&mut self) {
|
|
||||||
self.exact = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn limit(&mut self, limit: usize) {
|
|
||||||
self.limit = limit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Info associated with a text range.
|
/// Info associated with a text range.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RangeInfo<T> {
|
pub struct RangeInfo<T> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue