diff options
author | Aleksey Kladov <[email protected]> | 2020-02-06 11:24:13 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-06 11:24:13 +0000 |
commit | 0509a0a34e9b171d7ed7ea3e2a706c85c9b69433 (patch) | |
tree | a1ae6c63bd2d849a18069981115b7b6f5305747a /crates/ra_ide/src/ide_db | |
parent | ad247aa67061f4dcba85e20b82ca47e9a86eff56 (diff) |
Move Query
Diffstat (limited to 'crates/ra_ide/src/ide_db')
-rw-r--r-- | crates/ra_ide/src/ide_db/symbol_index.rs | 42 |
1 files changed, 41 insertions, 1 deletions
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::{ | |||
40 | #[cfg(not(feature = "wasm"))] | 40 | #[cfg(not(feature = "wasm"))] |
41 | use rayon::prelude::*; | 41 | use rayon::prelude::*; |
42 | 42 | ||
43 | use crate::{ide_db::RootDatabase, Query}; | 43 | use crate::ide_db::RootDatabase; |
44 | |||
45 | #[derive(Debug)] | ||
46 | pub struct Query { | ||
47 | query: String, | ||
48 | lowercased: String, | ||
49 | only_types: bool, | ||
50 | libs: bool, | ||
51 | exact: bool, | ||
52 | limit: usize, | ||
53 | } | ||
54 | |||
55 | impl Query { | ||
56 | pub fn new(query: String) -> Query { | ||
57 | let lowercased = query.to_lowercase(); | ||
58 | Query { | ||
59 | query, | ||
60 | lowercased, | ||
61 | only_types: false, | ||
62 | libs: false, | ||
63 | exact: false, | ||
64 | limit: usize::max_value(), | ||
65 | } | ||
66 | } | ||
67 | |||
68 | pub fn only_types(&mut self) { | ||
69 | self.only_types = true; | ||
70 | } | ||
71 | |||
72 | pub fn libs(&mut self) { | ||
73 | self.libs = true; | ||
74 | } | ||
75 | |||
76 | pub fn exact(&mut self) { | ||
77 | self.exact = true; | ||
78 | } | ||
79 | |||
80 | pub fn limit(&mut self, limit: usize) { | ||
81 | self.limit = limit | ||
82 | } | ||
83 | } | ||
44 | 84 | ||
45 | #[salsa::query_group(SymbolsDatabaseStorage)] | 85 | #[salsa::query_group(SymbolsDatabaseStorage)] |
46 | pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { | 86 | pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { |