diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/display.rs | 6 | ||||
-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.rs | 37 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli.rs | 8 |
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 | ||
4 | pub(crate) mod function_signature; | 4 | pub(crate) mod function_signature; |
5 | mod navigation_target; | 5 | mod navigation_target; |
6 | mod structure; | ||
7 | mod short_label; | 6 | mod short_label; |
8 | 7 | ||
9 | use ra_syntax::{ | 8 | use ra_syntax::{ |
@@ -11,12 +10,11 @@ use ra_syntax::{ | |||
11 | SyntaxKind::{ATTR, COMMENT}, | 10 | SyntaxKind::{ATTR, COMMENT}, |
12 | }; | 11 | }; |
13 | 12 | ||
14 | pub use navigation_target::NavigationTarget; | ||
15 | pub use structure::{file_structure, StructureNode}; | ||
16 | |||
17 | pub(crate) use navigation_target::{ToNav, TryToNav}; | 13 | pub(crate) use navigation_target::{ToNav, TryToNav}; |
18 | pub(crate) use short_label::ShortLabel; | 14 | pub(crate) use short_label::ShortLabel; |
19 | 15 | ||
16 | pub use navigation_target::NavigationTarget; | ||
17 | |||
20 | pub(crate) fn function_label(node: &ast::FnDef) -> String { | 18 | pub(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 | ||
20 | mod markup; | 20 | mod markup; |
21 | mod prime_caches; | 21 | mod prime_caches; |
22 | mod status; | 22 | mod display; |
23 | |||
24 | mod call_hierarchy; | ||
25 | mod call_info; | ||
23 | mod completion; | 26 | mod completion; |
24 | mod runnables; | 27 | mod diagnostics; |
28 | mod expand_macro; | ||
29 | mod extend_selection; | ||
30 | mod file_structure; | ||
31 | mod folding_ranges; | ||
25 | mod goto_definition; | 32 | mod goto_definition; |
26 | mod goto_type_definition; | ||
27 | mod goto_implementation; | 33 | mod goto_implementation; |
28 | mod extend_selection; | 34 | mod goto_type_definition; |
29 | mod hover; | 35 | mod hover; |
30 | mod call_hierarchy; | 36 | mod inlay_hints; |
31 | mod call_info; | 37 | mod join_lines; |
32 | mod syntax_highlighting; | 38 | mod matching_brace; |
33 | mod parent_module; | 39 | mod parent_module; |
34 | mod references; | 40 | mod references; |
35 | mod diagnostics; | 41 | mod runnables; |
42 | mod ssr; | ||
43 | mod status; | ||
44 | mod syntax_highlighting; | ||
36 | mod syntax_tree; | 45 | mod syntax_tree; |
37 | mod folding_ranges; | ||
38 | mod join_lines; | ||
39 | mod typing; | 46 | mod typing; |
40 | mod matching_brace; | ||
41 | mod display; | ||
42 | mod inlay_hints; | ||
43 | mod expand_macro; | ||
44 | mod ssr; | ||
45 | 47 | ||
46 | use std::sync::Arc; | 48 | use 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; | |||
10 | use std::io::Read; | 10 | use std::io::Read; |
11 | 11 | ||
12 | use anyhow::Result; | 12 | use anyhow::Result; |
13 | use ra_ide::{file_structure, Analysis}; | 13 | use ra_ide::Analysis; |
14 | use ra_prof::profile; | 14 | use ra_prof::profile; |
15 | use ra_syntax::{AstNode, SourceFile}; | 15 | use ra_syntax::{AstNode, SourceFile}; |
16 | 16 | ||
@@ -48,8 +48,10 @@ pub fn parse(no_dump: bool) -> Result<()> { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | pub fn symbols() -> Result<()> { | 50 | pub 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(()) |