From 0509a0a34e9b171d7ed7ea3e2a706c85c9b69433 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Feb 2020 12:24:13 +0100 Subject: Move Query --- crates/ra_ide/src/ide_db/symbol_index.rs | 42 +++++++++++++++++++++++++++++++- crates/ra_ide/src/lib.rs | 41 +------------------------------ 2 files changed, 42 insertions(+), 41 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/ide_db/symbol_index.rs b/crates/ra_ide/src/ide_db/symbol_index.rs index 4ceb5e66f..c66eeb8e2 100644 --- a/crates/ra_ide/src/ide_db/symbol_index.rs +++ b/crates/ra_ide/src/ide_db/symbol_index.rs @@ -40,7 +40,47 @@ use ra_syntax::{ #[cfg(not(feature = "wasm"))] 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)] pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 3926bc00f..109b5ad9f 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -78,6 +78,7 @@ pub use crate::{ feature_flags::FeatureFlags, line_index::{LineCol, LineIndex}, line_index_utils::translate_offset_with_edit, + symbol_index::Query, }, inlay_hints::{InlayHint, InlayKind}, references::{ @@ -103,46 +104,6 @@ pub struct Diagnostic { 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. #[derive(Debug)] pub struct RangeInfo { -- cgit v1.2.3