mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Better module structure
This commit is contained in:
parent
29832b8c3d
commit
a4e9681c79
4 changed files with 30 additions and 27 deletions
|
@ -3,7 +3,6 @@
|
|||
|
||||
pub(crate) mod function_signature;
|
||||
mod navigation_target;
|
||||
mod structure;
|
||||
mod short_label;
|
||||
|
||||
use ra_syntax::{
|
||||
|
@ -11,12 +10,11 @@ use ra_syntax::{
|
|||
SyntaxKind::{ATTR, COMMENT},
|
||||
};
|
||||
|
||||
pub use navigation_target::NavigationTarget;
|
||||
pub use structure::{file_structure, StructureNode};
|
||||
|
||||
pub(crate) use navigation_target::{ToNav, TryToNav};
|
||||
pub(crate) use short_label::ShortLabel;
|
||||
|
||||
pub use navigation_target::NavigationTarget;
|
||||
|
||||
pub(crate) fn function_label(node: &ast::FnDef) -> String {
|
||||
function_signature::FunctionSignature::from(node).to_string()
|
||||
}
|
||||
|
|
|
@ -19,29 +19,31 @@ pub mod mock_analysis;
|
|||
|
||||
mod markup;
|
||||
mod prime_caches;
|
||||
mod status;
|
||||
mod completion;
|
||||
mod runnables;
|
||||
mod goto_definition;
|
||||
mod goto_type_definition;
|
||||
mod goto_implementation;
|
||||
mod extend_selection;
|
||||
mod hover;
|
||||
mod display;
|
||||
|
||||
mod call_hierarchy;
|
||||
mod call_info;
|
||||
mod syntax_highlighting;
|
||||
mod completion;
|
||||
mod diagnostics;
|
||||
mod expand_macro;
|
||||
mod extend_selection;
|
||||
mod file_structure;
|
||||
mod folding_ranges;
|
||||
mod goto_definition;
|
||||
mod goto_implementation;
|
||||
mod goto_type_definition;
|
||||
mod hover;
|
||||
mod inlay_hints;
|
||||
mod join_lines;
|
||||
mod matching_brace;
|
||||
mod parent_module;
|
||||
mod references;
|
||||
mod diagnostics;
|
||||
mod syntax_tree;
|
||||
mod folding_ranges;
|
||||
mod join_lines;
|
||||
mod typing;
|
||||
mod matching_brace;
|
||||
mod display;
|
||||
mod inlay_hints;
|
||||
mod expand_macro;
|
||||
mod runnables;
|
||||
mod ssr;
|
||||
mod status;
|
||||
mod syntax_highlighting;
|
||||
mod syntax_tree;
|
||||
mod typing;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -65,8 +67,9 @@ pub use crate::{
|
|||
CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
|
||||
},
|
||||
diagnostics::Severity,
|
||||
display::{file_structure, NavigationTarget, StructureNode},
|
||||
display::NavigationTarget,
|
||||
expand_macro::ExpandedMacro,
|
||||
file_structure::StructureNode,
|
||||
folding_ranges::{Fold, FoldKind},
|
||||
hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult},
|
||||
inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
|
||||
|
@ -323,7 +326,7 @@ impl Analysis {
|
|||
/// Returns a tree representation of symbols in the file. Useful to draw a
|
||||
/// file outline.
|
||||
pub fn file_structure(&self, file_id: FileId) -> Cancelable<Vec<StructureNode>> {
|
||||
self.with_db(|db| file_structure(&db.parse(file_id).tree()))
|
||||
self.with_db(|db| file_structure::file_structure(&db.parse(file_id).tree()))
|
||||
}
|
||||
|
||||
/// Returns a list of the places in the file where type hints can be displayed.
|
||||
|
|
|
@ -10,7 +10,7 @@ mod ssr;
|
|||
use std::io::Read;
|
||||
|
||||
use anyhow::Result;
|
||||
use ra_ide::{file_structure, Analysis};
|
||||
use ra_ide::Analysis;
|
||||
use ra_prof::profile;
|
||||
use ra_syntax::{AstNode, SourceFile};
|
||||
|
||||
|
@ -48,8 +48,10 @@ pub fn parse(no_dump: bool) -> Result<()> {
|
|||
}
|
||||
|
||||
pub fn symbols() -> Result<()> {
|
||||
let file = file()?;
|
||||
for s in file_structure(&file) {
|
||||
let text = read_stdin()?;
|
||||
let (analysis, file_id) = Analysis::from_single_file(text);
|
||||
let structure = analysis.file_structure(file_id).unwrap();
|
||||
for s in structure {
|
||||
println!("{:?}", s);
|
||||
}
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue