1 use rls_data::config::Config;
3 self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import, MacroRef,
4 Ref, RefKind, Relation,
6 use rls_span::{Column, Row};
20 pub fn new(config: Config) -> Dumper {
21 Dumper { config: config.clone(), result: Analysis::new(config) }
24 pub fn analysis(&self) -> &Analysis {
30 pub fn crate_prelude(&mut self, data: CratePreludeData) {
31 self.result.prelude = Some(data)
34 pub fn compilation_opts(&mut self, data: CompilationOptions) {
35 self.result.compilation = Some(data);
38 pub fn _macro_use(&mut self, data: MacroRef) {
39 if self.config.pub_only || self.config.reachable_only {
42 self.result.macro_refs.push(data);
45 pub fn import(&mut self, access: &Access, import: Import) {
46 if !access.public && self.config.pub_only || !access.reachable && self.config.reachable_only
50 self.result.imports.push(import);
53 pub fn dump_ref(&mut self, data: Ref) {
54 if self.config.pub_only || self.config.reachable_only {
57 self.result.refs.push(data);
60 pub fn dump_def(&mut self, access: &Access, mut data: Def) {
61 if !access.public && self.config.pub_only || !access.reachable && self.config.reachable_only
65 if data.kind == DefKind::Mod && data.span.file_name.to_str().unwrap() != data.value {
66 // If the module is an out-of-line definition, then we'll make the
67 // definition the first character in the module's file and turn
68 // the declaration into a reference to it.
69 let rf = Ref { kind: RefKind::Mod, span: data.span, ref_id: data.id };
70 self.result.refs.push(rf);
71 data.span = rls_data::SpanData {
72 file_name: data.value.clone().into(),
75 line_start: Row::new_one_indexed(1),
76 line_end: Row::new_one_indexed(1),
77 column_start: Column::new_one_indexed(1),
78 column_end: Column::new_one_indexed(1),
81 self.result.defs.push(data);
84 pub fn dump_relation(&mut self, data: Relation) {
85 self.result.relations.push(data);
88 pub fn dump_impl(&mut self, data: Impl) {
89 self.result.impls.push(data);