From 36cb58f76d702d87f445ee7eefe26a0bc1ee3811 Mon Sep 17 00:00:00 2001 From: Sergey Parilin Date: Fri, 22 Mar 2019 15:54:26 +0300 Subject: structure moved to ra_ide_api ra_ide_api_light removed completely --- Cargo.lock | 18 -- crates/ra_cli/Cargo.toml | 1 - crates/ra_cli/src/main.rs | 2 +- crates/ra_ide_api/Cargo.toml | 1 - crates/ra_ide_api/src/lib.rs | 11 +- .../src/snapshots/tests__file_structure.snap | 182 ++++++++++++++++++++ crates/ra_ide_api/src/structure.rs | 190 +++++++++++++++++++++ crates/ra_ide_api_light/Cargo.toml | 26 --- crates/ra_ide_api_light/src/lib.rs | 12 -- .../src/snapshots/tests__file_structure.snap | 182 -------------------- crates/ra_ide_api_light/src/structure.rs | 190 --------------------- docs/dev/architecture.md | 13 -- 12 files changed, 378 insertions(+), 450 deletions(-) create mode 100644 crates/ra_ide_api/src/snapshots/tests__file_structure.snap create mode 100644 crates/ra_ide_api/src/structure.rs delete mode 100644 crates/ra_ide_api_light/Cargo.toml delete mode 100644 crates/ra_ide_api_light/src/lib.rs delete mode 100644 crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap delete mode 100644 crates/ra_ide_api_light/src/structure.rs diff --git a/Cargo.lock b/Cargo.lock index 1b5de271e..653eaa6c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -929,7 +929,6 @@ dependencies = [ "ra_db 0.1.0", "ra_hir 0.1.0", "ra_ide_api 0.1.0", - "ra_ide_api_light 0.1.0", "ra_syntax 0.1.0", "tools 0.1.0", ] @@ -993,7 +992,6 @@ dependencies = [ "ra_db 0.1.0", "ra_fmt 0.1.0", "ra_hir 0.1.0", - "ra_ide_api_light 0.1.0", "ra_syntax 0.1.0", "ra_text_edit 0.1.0", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1004,22 +1002,6 @@ dependencies = [ "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ra_ide_api_light" -version = "0.1.0" -dependencies = [ - "insta 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ra_fmt 0.1.0", - "ra_syntax 0.1.0", - "ra_text_edit 0.1.0", - "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "test_utils 0.1.0", -] - [[package]] name = "ra_lsp_server" version = "0.1.0" diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 4c666f556..467628236 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -14,7 +14,6 @@ indicatif = "0.11.0" ra_syntax = { path = "../ra_syntax" } ra_ide_api = { path = "../ra_ide_api" } -ra_ide_api_light = { path = "../ra_ide_api_light" } tools = { path = "../tools" } ra_batch = { path = "../ra_batch" } ra_hir = { path = "../ra_hir" } diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 5285f1f28..11f5541eb 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -5,7 +5,7 @@ use std::{fs, io::Read, path::Path, time::Instant}; use clap::{App, Arg, SubCommand}; use join_to_string::join; use ra_ide_api::{Analysis, FileRange}; -use ra_ide_api_light::file_structure; +use ra_ide_api::file_structure; use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode}; use tools::collect_tests; use flexi_logger::Logger; diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index c64226801..45bab4e28 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml @@ -20,7 +20,6 @@ jemallocator = { version = "0.1.9", optional = true } jemalloc-ctl = { version = "0.2.0", optional = true } ra_syntax = { path = "../ra_syntax" } -ra_ide_api_light = { path = "../ra_ide_api_light" } ra_text_edit = { path = "../ra_text_edit" } ra_db = { path = "../ra_db" } ra_fmt = { path = "../ra_fmt" } diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 8aa3eb088..9063f78a9 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -6,9 +6,6 @@ //! database, and the `ra_hir` crate, where majority of the analysis happens. //! However, IDE specific bits of the analysis (most notably completion) happen //! in this crate. -//! -//! The sibling `ra_ide_api_light` handles those bits of IDE functionality -//! which are restricted to a single file and need only syntax. // For proving that RootDatabase is RefUnwindSafe. #![recursion_limit = "128"] @@ -33,10 +30,11 @@ mod impls; mod assists; mod diagnostics; mod syntax_tree; -mod line_index; mod folding_ranges; +mod line_index; mod line_index_utils; mod join_lines; +mod structure; mod typing; mod matching_brace; @@ -72,9 +70,10 @@ pub use crate::{ line_index_utils::translate_offset_with_edit, folding_ranges::{Fold, FoldKind}, syntax_highlighting::HighlightedRange, + structure::{StructureNode, file_structure}, diagnostics::Severity, }; -pub use ra_ide_api_light::StructureNode; + pub use ra_db::{ Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId, Edition @@ -388,7 +387,7 @@ impl Analysis { /// file outline. pub fn file_structure(&self, file_id: FileId) -> Vec { let file = self.db.parse(file_id); - ra_ide_api_light::file_structure(&file) + structure::file_structure(&file) } /// Returns the set of folding ranges. diff --git a/crates/ra_ide_api/src/snapshots/tests__file_structure.snap b/crates/ra_ide_api/src/snapshots/tests__file_structure.snap new file mode 100644 index 000000000..2efa8e22c --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__file_structure.snap @@ -0,0 +1,182 @@ +--- +created: "2019-02-05T22:03:50.763530100Z" +creator: insta@0.6.1 +source: crates/ra_ide_api/src/structure.rs +expression: structure +--- +[ + StructureNode { + parent: None, + label: "Foo", + navigation_range: [8; 11), + node_range: [1; 26), + kind: STRUCT_DEF, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 0 + ), + label: "x", + navigation_range: [18; 19), + node_range: [18; 24), + kind: NAMED_FIELD_DEF, + detail: Some( + "i32" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "m", + navigation_range: [32; 33), + node_range: [28; 158), + kind: MODULE, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 2 + ), + label: "bar1", + navigation_range: [43; 47), + node_range: [40; 52), + kind: FN_DEF, + detail: Some( + "fn()" + ), + deprecated: false + }, + StructureNode { + parent: Some( + 2 + ), + label: "bar2", + navigation_range: [60; 64), + node_range: [57; 81), + kind: FN_DEF, + detail: Some( + "fn(t: T) -> T" + ), + deprecated: false + }, + StructureNode { + parent: Some( + 2 + ), + label: "bar3", + navigation_range: [89; 93), + node_range: [86; 156), + kind: FN_DEF, + detail: Some( + "fn(a: A, b: B) -> Vec< u32 >" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "E", + navigation_range: [165; 166), + node_range: [160; 180), + kind: ENUM_DEF, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 6 + ), + label: "X", + navigation_range: [169; 170), + node_range: [169; 170), + kind: ENUM_VARIANT, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 6 + ), + label: "Y", + navigation_range: [172; 173), + node_range: [172; 178), + kind: ENUM_VARIANT, + detail: None, + deprecated: false + }, + StructureNode { + parent: None, + label: "T", + navigation_range: [186; 187), + node_range: [181; 193), + kind: TYPE_ALIAS_DEF, + detail: Some( + "()" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "S", + navigation_range: [201; 202), + node_range: [194; 213), + kind: STATIC_DEF, + detail: Some( + "i32" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "C", + navigation_range: [220; 221), + node_range: [214; 232), + kind: CONST_DEF, + detail: Some( + "i32" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "impl E", + navigation_range: [239; 240), + node_range: [234; 243), + kind: IMPL_BLOCK, + detail: None, + deprecated: false + }, + StructureNode { + parent: None, + label: "impl fmt::Debug for E", + navigation_range: [265; 266), + node_range: [245; 269), + kind: IMPL_BLOCK, + detail: None, + deprecated: false + }, + StructureNode { + parent: None, + label: "obsolete", + navigation_range: [288; 296), + node_range: [271; 301), + kind: FN_DEF, + detail: Some( + "fn()" + ), + deprecated: true + }, + StructureNode { + parent: None, + label: "very_obsolete", + navigation_range: [341; 354), + node_range: [303; 359), + kind: FN_DEF, + detail: Some( + "fn()" + ), + deprecated: true + } +] diff --git a/crates/ra_ide_api/src/structure.rs b/crates/ra_ide_api/src/structure.rs new file mode 100644 index 000000000..ec2c9bbc6 --- /dev/null +++ b/crates/ra_ide_api/src/structure.rs @@ -0,0 +1,190 @@ +use crate::TextRange; + +use ra_syntax::{ + algo::visit::{visitor, Visitor}, + ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, + AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, +}; + +#[derive(Debug, Clone)] +pub struct StructureNode { + pub parent: Option, + pub label: String, + pub navigation_range: TextRange, + pub node_range: TextRange, + pub kind: SyntaxKind, + pub detail: Option, + pub deprecated: bool, +} + +pub fn file_structure(file: &SourceFile) -> Vec { + let mut res = Vec::new(); + let mut stack = Vec::new(); + + for event in file.syntax().preorder() { + match event { + WalkEvent::Enter(node) => { + if let Some(mut symbol) = structure_node(node) { + symbol.parent = stack.last().map(|&n| n); + stack.push(res.len()); + res.push(symbol); + } + } + WalkEvent::Leave(node) => { + if structure_node(node).is_some() { + stack.pop().unwrap(); + } + } + } + } + res +} + +fn structure_node(node: &SyntaxNode) -> Option { + fn decl(node: &N) -> Option { + decl_with_detail(node, None) + } + + fn decl_with_ascription( + node: &N, + ) -> Option { + decl_with_type_ref(node, node.ascribed_type()) + } + + fn decl_with_type_ref( + node: &N, + type_ref: Option<&ast::TypeRef>, + ) -> Option { + let detail = type_ref.map(|type_ref| { + let mut detail = String::new(); + collapse_ws(type_ref.syntax(), &mut detail); + detail + }); + decl_with_detail(node, detail) + } + + fn decl_with_detail( + node: &N, + detail: Option, + ) -> Option { + let name = node.name()?; + + Some(StructureNode { + parent: None, + label: name.text().to_string(), + navigation_range: name.syntax().range(), + node_range: node.syntax().range(), + kind: node.syntax().kind(), + detail, + deprecated: node.attrs().filter_map(|x| x.as_named()).any(|x| x == "deprecated"), + }) + } + + fn collapse_ws(node: &SyntaxNode, output: &mut String) { + let mut can_insert_ws = false; + for line in node.text().chunks().flat_map(|chunk| chunk.lines()) { + let line = line.trim(); + if line.is_empty() { + if can_insert_ws { + output.push_str(" "); + can_insert_ws = false; + } + } else { + output.push_str(line); + can_insert_ws = true; + } + } + } + + visitor() + .visit(|fn_def: &ast::FnDef| { + let mut detail = String::from("fn"); + if let Some(type_param_list) = fn_def.type_param_list() { + collapse_ws(type_param_list.syntax(), &mut detail); + } + if let Some(param_list) = fn_def.param_list() { + collapse_ws(param_list.syntax(), &mut detail); + } + if let Some(ret_type) = fn_def.ret_type() { + detail.push_str(" "); + collapse_ws(ret_type.syntax(), &mut detail); + } + + decl_with_detail(fn_def, Some(detail)) + }) + .visit(decl::) + .visit(decl::) + .visit(decl::) + .visit(decl::) + .visit(decl::) + .visit(|td: &ast::TypeAliasDef| decl_with_type_ref(td, td.type_ref())) + .visit(decl_with_ascription::) + .visit(decl_with_ascription::) + .visit(decl_with_ascription::) + .visit(|im: &ast::ImplBlock| { + let target_type = im.target_type()?; + let target_trait = im.target_trait(); + let label = match target_trait { + None => format!("impl {}", target_type.syntax().text()), + Some(t) => { + format!("impl {} for {}", t.syntax().text(), target_type.syntax().text(),) + } + }; + + let node = StructureNode { + parent: None, + label, + navigation_range: target_type.syntax().range(), + node_range: im.syntax().range(), + kind: im.syntax().kind(), + detail: None, + deprecated: false, + }; + Some(node) + }) + .accept(node)? +} + +#[cfg(test)] +mod tests { + use super::*; + use insta::assert_debug_snapshot_matches; + + #[test] + fn test_file_structure() { + let file = SourceFile::parse( + r#" +struct Foo { + x: i32 +} + +mod m { + fn bar1() {} + fn bar2(t: T) -> T {} + fn bar3(a: A, + b: B) -> Vec< + u32 + > {} +} + +enum E { X, Y(i32) } +type T = (); +static S: i32 = 92; +const C: i32 = 92; + +impl E {} + +impl fmt::Debug for E {} + +#[deprecated] +fn obsolete() {} + +#[deprecated(note = "for awhile")] +fn very_obsolete() {} +"#, + ); + let structure = file_structure(&file); + assert_debug_snapshot_matches!("file_structure", structure); + } +} diff --git a/crates/ra_ide_api_light/Cargo.toml b/crates/ra_ide_api_light/Cargo.toml deleted file mode 100644 index 4e69f5325..000000000 --- a/crates/ra_ide_api_light/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -edition = "2018" -name = "ra_ide_api_light" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false - -[dependencies] -itertools = "0.8.0" -superslice = "1.0.0" -join_to_string = "0.1.1" -rustc-hash = "1.0" - -ra_syntax = { path = "../ra_syntax" } -ra_text_edit = { path = "../ra_text_edit" } -ra_fmt = { path = "../ra_fmt" } - -[dev-dependencies] -test_utils = { path = "../test_utils" } -insta = "0.7.0" - -[dev-dependencies.proptest] -version = "0.9.0" -# Disable `fork` feature to allow compiling on webassembly -default-features = false -features = ["std", "bit-set", "break-dead-code"] diff --git a/crates/ra_ide_api_light/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs deleted file mode 100644 index df7f144b6..000000000 --- a/crates/ra_ide_api_light/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! This crate provides those IDE features which use only a single file. -//! -//! This usually means functions which take syntax tree as an input and produce -//! an edit or some auxiliary info. - -mod structure; - -use ra_syntax::TextRange; - -pub use crate::{ - structure::{file_structure, StructureNode}, -}; diff --git a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap deleted file mode 100644 index 8e4184b31..000000000 --- a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap +++ /dev/null @@ -1,182 +0,0 @@ ---- -created: "2019-02-05T22:03:50.763530100Z" -creator: insta@0.6.1 -source: crates/ra_ide_api_light/src/structure.rs -expression: structure ---- -[ - StructureNode { - parent: None, - label: "Foo", - navigation_range: [8; 11), - node_range: [1; 26), - kind: STRUCT_DEF, - detail: None, - deprecated: false - }, - StructureNode { - parent: Some( - 0 - ), - label: "x", - navigation_range: [18; 19), - node_range: [18; 24), - kind: NAMED_FIELD_DEF, - detail: Some( - "i32" - ), - deprecated: false - }, - StructureNode { - parent: None, - label: "m", - navigation_range: [32; 33), - node_range: [28; 158), - kind: MODULE, - detail: None, - deprecated: false - }, - StructureNode { - parent: Some( - 2 - ), - label: "bar1", - navigation_range: [43; 47), - node_range: [40; 52), - kind: FN_DEF, - detail: Some( - "fn()" - ), - deprecated: false - }, - StructureNode { - parent: Some( - 2 - ), - label: "bar2", - navigation_range: [60; 64), - node_range: [57; 81), - kind: FN_DEF, - detail: Some( - "fn(t: T) -> T" - ), - deprecated: false - }, - StructureNode { - parent: Some( - 2 - ), - label: "bar3", - navigation_range: [89; 93), - node_range: [86; 156), - kind: FN_DEF, - detail: Some( - "fn(a: A, b: B) -> Vec< u32 >" - ), - deprecated: false - }, - StructureNode { - parent: None, - label: "E", - navigation_range: [165; 166), - node_range: [160; 180), - kind: ENUM_DEF, - detail: None, - deprecated: false - }, - StructureNode { - parent: Some( - 6 - ), - label: "X", - navigation_range: [169; 170), - node_range: [169; 170), - kind: ENUM_VARIANT, - detail: None, - deprecated: false - }, - StructureNode { - parent: Some( - 6 - ), - label: "Y", - navigation_range: [172; 173), - node_range: [172; 178), - kind: ENUM_VARIANT, - detail: None, - deprecated: false - }, - StructureNode { - parent: None, - label: "T", - navigation_range: [186; 187), - node_range: [181; 193), - kind: TYPE_ALIAS_DEF, - detail: Some( - "()" - ), - deprecated: false - }, - StructureNode { - parent: None, - label: "S", - navigation_range: [201; 202), - node_range: [194; 213), - kind: STATIC_DEF, - detail: Some( - "i32" - ), - deprecated: false - }, - StructureNode { - parent: None, - label: "C", - navigation_range: [220; 221), - node_range: [214; 232), - kind: CONST_DEF, - detail: Some( - "i32" - ), - deprecated: false - }, - StructureNode { - parent: None, - label: "impl E", - navigation_range: [239; 240), - node_range: [234; 243), - kind: IMPL_BLOCK, - detail: None, - deprecated: false - }, - StructureNode { - parent: None, - label: "impl fmt::Debug for E", - navigation_range: [265; 266), - node_range: [245; 269), - kind: IMPL_BLOCK, - detail: None, - deprecated: false - }, - StructureNode { - parent: None, - label: "obsolete", - navigation_range: [288; 296), - node_range: [271; 301), - kind: FN_DEF, - detail: Some( - "fn()" - ), - deprecated: true - }, - StructureNode { - parent: None, - label: "very_obsolete", - navigation_range: [341; 354), - node_range: [303; 359), - kind: FN_DEF, - detail: Some( - "fn()" - ), - deprecated: true - } -] diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs deleted file mode 100644 index ec2c9bbc6..000000000 --- a/crates/ra_ide_api_light/src/structure.rs +++ /dev/null @@ -1,190 +0,0 @@ -use crate::TextRange; - -use ra_syntax::{ - algo::visit::{visitor, Visitor}, - ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, - AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, -}; - -#[derive(Debug, Clone)] -pub struct StructureNode { - pub parent: Option, - pub label: String, - pub navigation_range: TextRange, - pub node_range: TextRange, - pub kind: SyntaxKind, - pub detail: Option, - pub deprecated: bool, -} - -pub fn file_structure(file: &SourceFile) -> Vec { - let mut res = Vec::new(); - let mut stack = Vec::new(); - - for event in file.syntax().preorder() { - match event { - WalkEvent::Enter(node) => { - if let Some(mut symbol) = structure_node(node) { - symbol.parent = stack.last().map(|&n| n); - stack.push(res.len()); - res.push(symbol); - } - } - WalkEvent::Leave(node) => { - if structure_node(node).is_some() { - stack.pop().unwrap(); - } - } - } - } - res -} - -fn structure_node(node: &SyntaxNode) -> Option { - fn decl(node: &N) -> Option { - decl_with_detail(node, None) - } - - fn decl_with_ascription( - node: &N, - ) -> Option { - decl_with_type_ref(node, node.ascribed_type()) - } - - fn decl_with_type_ref( - node: &N, - type_ref: Option<&ast::TypeRef>, - ) -> Option { - let detail = type_ref.map(|type_ref| { - let mut detail = String::new(); - collapse_ws(type_ref.syntax(), &mut detail); - detail - }); - decl_with_detail(node, detail) - } - - fn decl_with_detail( - node: &N, - detail: Option, - ) -> Option { - let name = node.name()?; - - Some(StructureNode { - parent: None, - label: name.text().to_string(), - navigation_range: name.syntax().range(), - node_range: node.syntax().range(), - kind: node.syntax().kind(), - detail, - deprecated: node.attrs().filter_map(|x| x.as_named()).any(|x| x == "deprecated"), - }) - } - - fn collapse_ws(node: &SyntaxNode, output: &mut String) { - let mut can_insert_ws = false; - for line in node.text().chunks().flat_map(|chunk| chunk.lines()) { - let line = line.trim(); - if line.is_empty() { - if can_insert_ws { - output.push_str(" "); - can_insert_ws = false; - } - } else { - output.push_str(line); - can_insert_ws = true; - } - } - } - - visitor() - .visit(|fn_def: &ast::FnDef| { - let mut detail = String::from("fn"); - if let Some(type_param_list) = fn_def.type_param_list() { - collapse_ws(type_param_list.syntax(), &mut detail); - } - if let Some(param_list) = fn_def.param_list() { - collapse_ws(param_list.syntax(), &mut detail); - } - if let Some(ret_type) = fn_def.ret_type() { - detail.push_str(" "); - collapse_ws(ret_type.syntax(), &mut detail); - } - - decl_with_detail(fn_def, Some(detail)) - }) - .visit(decl::) - .visit(decl::) - .visit(decl::) - .visit(decl::) - .visit(decl::) - .visit(|td: &ast::TypeAliasDef| decl_with_type_ref(td, td.type_ref())) - .visit(decl_with_ascription::) - .visit(decl_with_ascription::) - .visit(decl_with_ascription::) - .visit(|im: &ast::ImplBlock| { - let target_type = im.target_type()?; - let target_trait = im.target_trait(); - let label = match target_trait { - None => format!("impl {}", target_type.syntax().text()), - Some(t) => { - format!("impl {} for {}", t.syntax().text(), target_type.syntax().text(),) - } - }; - - let node = StructureNode { - parent: None, - label, - navigation_range: target_type.syntax().range(), - node_range: im.syntax().range(), - kind: im.syntax().kind(), - detail: None, - deprecated: false, - }; - Some(node) - }) - .accept(node)? -} - -#[cfg(test)] -mod tests { - use super::*; - use insta::assert_debug_snapshot_matches; - - #[test] - fn test_file_structure() { - let file = SourceFile::parse( - r#" -struct Foo { - x: i32 -} - -mod m { - fn bar1() {} - fn bar2(t: T) -> T {} - fn bar3(a: A, - b: B) -> Vec< - u32 - > {} -} - -enum E { X, Y(i32) } -type T = (); -static S: i32 = 92; -const C: i32 = 92; - -impl E {} - -impl fmt::Debug for E {} - -#[deprecated] -fn obsolete() {} - -#[deprecated(note = "for awhile")] -fn very_obsolete() {} -"#, - ); - let structure = file_structure(&file); - assert_debug_snapshot_matches!("file_structure", structure); - } -} diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index f990d5bf0..890b18fcd 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -130,19 +130,6 @@ APIs in this crate are IDE centric: they take text offsets as input and produce offsets and strings as output. This works on top of rich code model powered by `hir`. -### `crates/ra_ide_api_light` - -All IDE features which can be implemented if you only have access to a single -file. `ra_ide_api_light` could be used to enhance editing of Rust code without -the need to fiddle with build-systems, file synchronization and such. - -In a sense, `ra_ide_api_light` is just a bunch of pure functions which take a -syntax tree as input. - -The tests for `ra_ide_api_light` are `#[cfg(test)] mod tests` unit-tests spread -throughout its modules. - - ### `crates/ra_lsp_server` An LSP implementation which wraps `ra_ide_api` into a langauge server protocol. -- cgit v1.2.3