1 use rls_data::config::Config;
2 use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import,
3 MacroRef, Ref, RefKind, Relation};
4 use rls_span::{Column, Row};
18 pub fn new(config: Config) -> Dumper {
20 config: config.clone(),
21 result: Analysis::new(config),
25 pub fn analysis(&self) -> &Analysis {
31 pub fn crate_prelude(&mut self, data: CratePreludeData) {
32 self.result.prelude = Some(data)
35 pub fn compilation_opts(&mut self, data: CompilationOptions) {
36 self.result.compilation = Some(data);
39 pub fn _macro_use(&mut self, data: MacroRef) {
40 if self.config.pub_only || self.config.reachable_only {
43 self.result.macro_refs.push(data);
46 pub fn import(&mut self, access: &Access, import: Import) {
47 if !access.public && self.config.pub_only
48 || !access.reachable && self.config.reachable_only {
51 self.result.imports.push(import);
54 pub fn dump_ref(&mut self, data: Ref) {
55 if self.config.pub_only || self.config.reachable_only {
58 self.result.refs.push(data);
61 pub fn dump_def(&mut self, access: &Access, mut data: Def) {
62 if !access.public && self.config.pub_only
63 || !access.reachable && self.config.reachable_only {
66 if data.kind == DefKind::Mod && data.span.file_name.to_str().unwrap() != data.value {
67 // If the module is an out-of-line definition, then we'll make the
68 // definition the first character in the module's file and turn
69 // the declaration into a reference to it.
75 self.result.refs.push(rf);
76 data.span = rls_data::SpanData {
77 file_name: data.value.clone().into(),
80 line_start: Row::new_one_indexed(1),
81 line_end: Row::new_one_indexed(1),
82 column_start: Column::new_one_indexed(1),
83 column_end: Column::new_one_indexed(1),
86 self.result.defs.push(data);
89 pub fn dump_relation(&mut self, data: Relation) {
90 self.result.relations.push(data);
93 pub fn dump_impl(&mut self, data: Impl) {
94 self.result.impls.push(data);