aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-16 17:13:43 +0100
committerAleksey Kladov <[email protected]>2020-07-16 17:13:43 +0100
commita4e9681c79095d6c10a851cfefe64cf1a3570ec5 (patch)
tree7ffe79ebb62ca9aebd3dab258e6cd75987fb9913
parent29832b8c3db509dea8da9164e980ccac4bccf47d (diff)
Better module structure
-rw-r--r--crates/ra_ide/src/display.rs6
-rw-r--r--crates/ra_ide/src/file_structure.rs (renamed from crates/ra_ide/src/display/structure.rs)0
-rw-r--r--crates/ra_ide/src/lib.rs37
-rw-r--r--crates/rust-analyzer/src/cli.rs8
4 files changed, 27 insertions, 24 deletions
diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs
index b59d4bbdf..1ec946369 100644
--- a/crates/ra_ide/src/display.rs
+++ b/crates/ra_ide/src/display.rs
@@ -3,7 +3,6 @@
3 3
4pub(crate) mod function_signature; 4pub(crate) mod function_signature;
5mod navigation_target; 5mod navigation_target;
6mod structure;
7mod short_label; 6mod short_label;
8 7
9use ra_syntax::{ 8use ra_syntax::{
@@ -11,12 +10,11 @@ use ra_syntax::{
11 SyntaxKind::{ATTR, COMMENT}, 10 SyntaxKind::{ATTR, COMMENT},
12}; 11};
13 12
14pub use navigation_target::NavigationTarget;
15pub use structure::{file_structure, StructureNode};
16
17pub(crate) use navigation_target::{ToNav, TryToNav}; 13pub(crate) use navigation_target::{ToNav, TryToNav};
18pub(crate) use short_label::ShortLabel; 14pub(crate) use short_label::ShortLabel;
19 15
16pub use navigation_target::NavigationTarget;
17
20pub(crate) fn function_label(node: &ast::FnDef) -> String { 18pub(crate) fn function_label(node: &ast::FnDef) -> String {
21 function_signature::FunctionSignature::from(node).to_string() 19 function_signature::FunctionSignature::from(node).to_string()
22} 20}
diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/file_structure.rs
index 1f6a3febf..1f6a3febf 100644
--- a/crates/ra_ide/src/display/structure.rs
+++ b/crates/ra_ide/src/file_structure.rs
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 6810c1c6a..d3b20f371 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -19,29 +19,31 @@ pub mod mock_analysis;
19 19
20mod markup; 20mod markup;
21mod prime_caches; 21mod prime_caches;
22mod status; 22mod display;
23
24mod call_hierarchy;
25mod call_info;
23mod completion; 26mod completion;
24mod runnables; 27mod diagnostics;
28mod expand_macro;
29mod extend_selection;
30mod file_structure;
31mod folding_ranges;
25mod goto_definition; 32mod goto_definition;
26mod goto_type_definition;
27mod goto_implementation; 33mod goto_implementation;
28mod extend_selection; 34mod goto_type_definition;
29mod hover; 35mod hover;
30mod call_hierarchy; 36mod inlay_hints;
31mod call_info; 37mod join_lines;
32mod syntax_highlighting; 38mod matching_brace;
33mod parent_module; 39mod parent_module;
34mod references; 40mod references;
35mod diagnostics; 41mod runnables;
42mod ssr;
43mod status;
44mod syntax_highlighting;
36mod syntax_tree; 45mod syntax_tree;
37mod folding_ranges;
38mod join_lines;
39mod typing; 46mod typing;
40mod matching_brace;
41mod display;
42mod inlay_hints;
43mod expand_macro;
44mod ssr;
45 47
46use std::sync::Arc; 48use std::sync::Arc;
47 49
@@ -65,8 +67,9 @@ pub use crate::{
65 CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, 67 CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
66 }, 68 },
67 diagnostics::Severity, 69 diagnostics::Severity,
68 display::{file_structure, NavigationTarget, StructureNode}, 70 display::NavigationTarget,
69 expand_macro::ExpandedMacro, 71 expand_macro::ExpandedMacro,
72 file_structure::StructureNode,
70 folding_ranges::{Fold, FoldKind}, 73 folding_ranges::{Fold, FoldKind},
71 hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult}, 74 hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult},
72 inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, 75 inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
@@ -323,7 +326,7 @@ impl Analysis {
323 /// Returns a tree representation of symbols in the file. Useful to draw a 326 /// Returns a tree representation of symbols in the file. Useful to draw a
324 /// file outline. 327 /// file outline.
325 pub fn file_structure(&self, file_id: FileId) -> Cancelable<Vec<StructureNode>> { 328 pub fn file_structure(&self, file_id: FileId) -> Cancelable<Vec<StructureNode>> {
326 self.with_db(|db| file_structure(&db.parse(file_id).tree())) 329 self.with_db(|db| file_structure::file_structure(&db.parse(file_id).tree()))
327 } 330 }
328 331
329 /// Returns a list of the places in the file where type hints can be displayed. 332 /// Returns a list of the places in the file where type hints can be displayed.
diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs
index 6863f100b..753001949 100644
--- a/crates/rust-analyzer/src/cli.rs
+++ b/crates/rust-analyzer/src/cli.rs
@@ -10,7 +10,7 @@ mod ssr;
10use std::io::Read; 10use std::io::Read;
11 11
12use anyhow::Result; 12use anyhow::Result;
13use ra_ide::{file_structure, Analysis}; 13use ra_ide::Analysis;
14use ra_prof::profile; 14use ra_prof::profile;
15use ra_syntax::{AstNode, SourceFile}; 15use ra_syntax::{AstNode, SourceFile};
16 16
@@ -48,8 +48,10 @@ pub fn parse(no_dump: bool) -> Result<()> {
48} 48}
49 49
50pub fn symbols() -> Result<()> { 50pub fn symbols() -> Result<()> {
51 let file = file()?; 51 let text = read_stdin()?;
52 for s in file_structure(&file) { 52 let (analysis, file_id) = Analysis::from_single_file(text);
53 let structure = analysis.file_structure(file_id).unwrap();
54 for s in structure {
53 println!("{:?}", s); 55 println!("{:?}", s);
54 } 56 }
55 Ok(()) 57 Ok(())