aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-06 11:24:13 +0000
committerAleksey Kladov <[email protected]>2020-02-06 11:24:13 +0000
commit0509a0a34e9b171d7ed7ea3e2a706c85c9b69433 (patch)
treea1ae6c63bd2d849a18069981115b7b6f5305747a /crates/ra_ide
parentad247aa67061f4dcba85e20b82ca47e9a86eff56 (diff)
Move Query
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/ide_db/symbol_index.rs42
-rw-r--r--crates/ra_ide/src/lib.rs41
2 files changed, 42 insertions, 41 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"))]
41use rayon::prelude::*; 41use rayon::prelude::*;
42 42
43use crate::{ide_db::RootDatabase, Query}; 43use crate::ide_db::RootDatabase;
44
45#[derive(Debug)]
46pub struct Query {
47 query: String,
48 lowercased: String,
49 only_types: bool,
50 libs: bool,
51 exact: bool,
52 limit: usize,
53}
54
55impl 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)]
46pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { 86pub(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::{
78 feature_flags::FeatureFlags, 78 feature_flags::FeatureFlags,
79 line_index::{LineCol, LineIndex}, 79 line_index::{LineCol, LineIndex},
80 line_index_utils::translate_offset_with_edit, 80 line_index_utils::translate_offset_with_edit,
81 symbol_index::Query,
81 }, 82 },
82 inlay_hints::{InlayHint, InlayKind}, 83 inlay_hints::{InlayHint, InlayKind},
83 references::{ 84 references::{
@@ -103,46 +104,6 @@ pub struct Diagnostic {
103 pub severity: Severity, 104 pub severity: Severity,
104} 105}
105 106
106#[derive(Debug)]
107pub struct Query {
108 query: String,
109 lowercased: String,
110 only_types: bool,
111 libs: bool,
112 exact: bool,
113 limit: usize,
114}
115
116impl Query {
117 pub fn new(query: String) -> Query {
118 let lowercased = query.to_lowercase();
119 Query {
120 query,
121 lowercased,
122 only_types: false,
123 libs: false,
124 exact: false,
125 limit: usize::max_value(),
126 }
127 }
128
129 pub fn only_types(&mut self) {
130 self.only_types = true;
131 }
132
133 pub fn libs(&mut self) {
134 self.libs = true;
135 }
136
137 pub fn exact(&mut self) {
138 self.exact = true;
139 }
140
141 pub fn limit(&mut self, limit: usize) {
142 self.limit = limit
143 }
144}
145
146/// Info associated with a text range. 107/// Info associated with a text range.
147#[derive(Debug)] 108#[derive(Debug)]
148pub struct RangeInfo<T> { 109pub struct RangeInfo<T> {