Skip to content

Commit db51b1b

Browse files
committed
add some useless code
1 parent 83599ed commit db51b1b

File tree

14 files changed

+129
-2
lines changed

14 files changed

+129
-2
lines changed

crates/code_analysis/src/db_index/declaration/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,9 @@ impl LuaIndex for LuaDeclIndex {
125125
!v.is_empty()
126126
});
127127
}
128+
129+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
130+
info.insert("decl.decl_trees".to_string(), self.decl_trees.len().to_string());
131+
info.insert("decl.global_decl".to_string(), self.global_decl.len().to_string());
132+
}
128133
}

crates/code_analysis/src/db_index/diagnostic/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,20 @@ impl LuaIndex for DiagnosticIndex {
108108
self.file_diagnostic_disabled.remove(&file_id);
109109
self.file_diagnostic_enabled.remove(&file_id);
110110
}
111+
112+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
113+
info.insert(
114+
"diagnostic_actions".to_string(),
115+
self.diagnostic_actions.len().to_string(),
116+
);
117+
info.insert("diagnostics".to_string(), self.diagnostics.len().to_string());
118+
info.insert(
119+
"file_diagnostic_disabled".to_string(),
120+
self.file_diagnostic_disabled.len().to_string(),
121+
);
122+
info.insert(
123+
"file_diagnostic_enabled".to_string(),
124+
self.file_diagnostic_enabled.len().to_string(),
125+
);
126+
}
111127
}

crates/code_analysis/src/db_index/flow/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ impl LuaIndex for LuaFlowIndex {
4848
fn remove(&mut self, file_id: crate::FileId) {
4949
self.chains_map.remove(&file_id);
5050
}
51+
52+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
53+
info.insert("flow_chain_count".to_string(), self.chains_map.len().to_string());
54+
}
5155
}

crates/code_analysis/src/db_index/member/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,10 @@ impl LuaIndex for LuaMemberIndex {
8888
}
8989
}
9090
}
91+
92+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
93+
info.insert("member.members".to_string(), self.members.len().to_string());
94+
info.insert("member.in_field_members".to_string(), self.in_field_members.len().to_string());
95+
info.insert("member.owner_members".to_string(), self.owner_members.len().to_string());
96+
}
9197
}

crates/code_analysis/src/db_index/meta/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ impl LuaIndex for MetaFile {
3030
fn remove(&mut self, file_id: FileId) {
3131
self.meta_files.remove(&file_id);
3232
}
33+
34+
fn fill_snapshot_info(&self, info: &mut std::collections::HashMap<String, String>) {
35+
info.insert("meta_file_count".to_string(), self.meta_files.len().to_string());
36+
}
3337
}

crates/code_analysis/src/db_index/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod signature;
1111
mod traits;
1212
mod r#type;
1313

14-
use std::sync::Arc;
14+
use std::{collections::HashMap, sync::Arc};
1515

1616
use crate::{Emmyrc, FileId, Vfs};
1717
pub use declaration::*;
@@ -169,6 +169,12 @@ impl DbIndex {
169169
self.vfs.update_config(config.clone());
170170
self.modules_index.update_config(config.clone());
171171
}
172+
173+
pub fn get_snapshot_info(&self) -> HashMap<String, String> {
174+
let mut info = HashMap::new();
175+
self.fill_snapshot_info(&mut info);
176+
info
177+
}
172178
}
173179

174180
impl LuaIndex for DbIndex {
@@ -185,4 +191,18 @@ impl LuaIndex for DbIndex {
185191
self.operator_index.remove(file_id);
186192
self.flow_index.remove(file_id);
187193
}
194+
195+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
196+
self.decl_index.fill_snapshot_info(info);
197+
self.references_index.fill_snapshot_info(info);
198+
self.types_index.fill_snapshot_info(info);
199+
self.modules_index.fill_snapshot_info(info);
200+
self.meta_files_index.fill_snapshot_info(info);
201+
self.members_index.fill_snapshot_info(info);
202+
self.property_index.fill_snapshot_info(info);
203+
self.signature_index.fill_snapshot_info(info);
204+
self.diagnostic_index.fill_snapshot_info(info);
205+
self.operator_index.fill_snapshot_info(info);
206+
self.flow_index.fill_snapshot_info(info);
207+
}
188208
}

crates/code_analysis/src/db_index/module/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,13 @@ impl LuaIndex for LuaModuleIndex {
383383
}
384384
}
385385
}
386+
387+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
388+
info.insert("module_nodes".to_string(), self.module_nodes.len().to_string());
389+
info.insert("file_module_map".to_string(), self.file_module_map.len().to_string());
390+
info.insert(
391+
"module_name_to_file_ids".to_string(),
392+
self.module_name_to_file_ids.len().to_string(),
393+
);
394+
}
386395
}

crates/code_analysis/src/db_index/operators/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ impl LuaIndex for LuaOperatorIndex {
7474
}
7575
}
7676
}
77+
78+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
79+
info.insert("operator_count".to_string(), self.operators.len().to_string());
80+
}
7781
}

crates/code_analysis/src/db_index/property/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,8 @@ impl LuaIndex for LuaPropertyIndex {
169169
}
170170
}
171171
}
172+
173+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
174+
info.insert("property_count".to_string(), self.properties.len().to_string());
175+
}
172176
}

crates/code_analysis/src/db_index/reference/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,23 @@ impl LuaIndex for LuaReferenceIndex {
211211
self.global_references.remove(&key);
212212
}
213213
}
214+
215+
fn fill_snapshot_info(&self, info: &mut HashMap<String, String>) {
216+
info.insert(
217+
"reference.local_references".to_string(),
218+
self.local_references.len().to_string(),
219+
);
220+
info.insert(
221+
"reference.index_reference".to_string(),
222+
self.index_reference.len().to_string(),
223+
);
224+
info.insert(
225+
"reference.global_references".to_string(),
226+
self.global_references.len().to_string(),
227+
);
228+
info.insert(
229+
"reference.string_references".to_string(),
230+
self.string_references.len().to_string(),
231+
);
232+
}
214233
}

0 commit comments

Comments
 (0)