aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2019-02-05 22:05:46 +0000
committerkjeremy <[email protected]>2019-02-05 22:05:46 +0000
commit852b08379473cc3ee06878c5aae809b63d76cbc3 (patch)
tree5634fb37d72d9c627eeea54d6612f6a029349751 /crates
parent569e1e871e737ade80616288241d63e1531dbb8d (diff)
Fill deprecation for LSP
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap70
-rw-r--r--crates/ra_ide_api_light/src/structure.rs24
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs2
-rw-r--r--crates/ra_syntax/src/ast.rs10
-rw-r--r--crates/ra_syntax/src/ast/generated.rs1
-rw-r--r--crates/ra_syntax/src/grammar.ron2
6 files changed, 86 insertions, 23 deletions
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
index 270f75a56..413f4a5ff 100644
--- a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap
+++ b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap
@@ -1,8 +1,8 @@
1--- 1---
2created: "2019-01-26T07:11:02.463391362+00:00" 2created: "2019-02-05T22:03:50.763530100Z"
3creator: [email protected] 3creator: [email protected]
4expression: structure
5source: crates/ra_ide_api_light/src/structure.rs 4source: crates/ra_ide_api_light/src/structure.rs
5expression: structure
6--- 6---
7[ 7[
8 StructureNode { 8 StructureNode {
@@ -11,7 +11,8 @@ source: crates/ra_ide_api_light/src/structure.rs
11 navigation_range: [8; 11), 11 navigation_range: [8; 11),
12 node_range: [1; 26), 12 node_range: [1; 26),
13 kind: STRUCT_DEF, 13 kind: STRUCT_DEF,
14 detail: None 14 detail: None,
15 deprecated: false
15 }, 16 },
16 StructureNode { 17 StructureNode {
17 parent: Some( 18 parent: Some(
@@ -23,7 +24,8 @@ source: crates/ra_ide_api_light/src/structure.rs
23 kind: NAMED_FIELD_DEF, 24 kind: NAMED_FIELD_DEF,
24 detail: Some( 25 detail: Some(
25 "i32" 26 "i32"
26 ) 27 ),
28 deprecated: false
27 }, 29 },
28 StructureNode { 30 StructureNode {
29 parent: None, 31 parent: None,
@@ -31,7 +33,8 @@ source: crates/ra_ide_api_light/src/structure.rs
31 navigation_range: [32; 33), 33 navigation_range: [32; 33),
32 node_range: [28; 158), 34 node_range: [28; 158),
33 kind: MODULE, 35 kind: MODULE,
34 detail: None 36 detail: None,
37 deprecated: false
35 }, 38 },
36 StructureNode { 39 StructureNode {
37 parent: Some( 40 parent: Some(
@@ -43,7 +46,8 @@ source: crates/ra_ide_api_light/src/structure.rs
43 kind: FN_DEF, 46 kind: FN_DEF,
44 detail: Some( 47 detail: Some(
45 "fn()" 48 "fn()"
46 ) 49 ),
50 deprecated: false
47 }, 51 },
48 StructureNode { 52 StructureNode {
49 parent: Some( 53 parent: Some(
@@ -55,7 +59,8 @@ source: crates/ra_ide_api_light/src/structure.rs
55 kind: FN_DEF, 59 kind: FN_DEF,
56 detail: Some( 60 detail: Some(
57 "fn<T>(t: T) -> T" 61 "fn<T>(t: T) -> T"
58 ) 62 ),
63 deprecated: false
59 }, 64 },
60 StructureNode { 65 StructureNode {
61 parent: Some( 66 parent: Some(
@@ -67,7 +72,8 @@ source: crates/ra_ide_api_light/src/structure.rs
67 kind: FN_DEF, 72 kind: FN_DEF,
68 detail: Some( 73 detail: Some(
69 "fn<A, B>(a: A, b: B) -> Vec< u32 >" 74 "fn<A, B>(a: A, b: B) -> Vec< u32 >"
70 ) 75 ),
76 deprecated: false
71 }, 77 },
72 StructureNode { 78 StructureNode {
73 parent: None, 79 parent: None,
@@ -75,7 +81,8 @@ source: crates/ra_ide_api_light/src/structure.rs
75 navigation_range: [165; 166), 81 navigation_range: [165; 166),
76 node_range: [160; 180), 82 node_range: [160; 180),
77 kind: ENUM_DEF, 83 kind: ENUM_DEF,
78 detail: None 84 detail: None,
85 deprecated: false
79 }, 86 },
80 StructureNode { 87 StructureNode {
81 parent: Some( 88 parent: Some(
@@ -85,7 +92,8 @@ source: crates/ra_ide_api_light/src/structure.rs
85 navigation_range: [169; 170), 92 navigation_range: [169; 170),
86 node_range: [169; 170), 93 node_range: [169; 170),
87 kind: ENUM_VARIANT, 94 kind: ENUM_VARIANT,
88 detail: None 95 detail: None,
96 deprecated: false
89 }, 97 },
90 StructureNode { 98 StructureNode {
91 parent: Some( 99 parent: Some(
@@ -95,7 +103,8 @@ source: crates/ra_ide_api_light/src/structure.rs
95 navigation_range: [172; 173), 103 navigation_range: [172; 173),
96 node_range: [172; 178), 104 node_range: [172; 178),
97 kind: ENUM_VARIANT, 105 kind: ENUM_VARIANT,
98 detail: None 106 detail: None,
107 deprecated: false
99 }, 108 },
100 StructureNode { 109 StructureNode {
101 parent: None, 110 parent: None,
@@ -105,7 +114,8 @@ source: crates/ra_ide_api_light/src/structure.rs
105 kind: TYPE_DEF, 114 kind: TYPE_DEF,
106 detail: Some( 115 detail: Some(
107 "()" 116 "()"
108 ) 117 ),
118 deprecated: false
109 }, 119 },
110 StructureNode { 120 StructureNode {
111 parent: None, 121 parent: None,
@@ -115,7 +125,8 @@ source: crates/ra_ide_api_light/src/structure.rs
115 kind: STATIC_DEF, 125 kind: STATIC_DEF,
116 detail: Some( 126 detail: Some(
117 "i32" 127 "i32"
118 ) 128 ),
129 deprecated: false
119 }, 130 },
120 StructureNode { 131 StructureNode {
121 parent: None, 132 parent: None,
@@ -125,7 +136,8 @@ source: crates/ra_ide_api_light/src/structure.rs
125 kind: CONST_DEF, 136 kind: CONST_DEF,
126 detail: Some( 137 detail: Some(
127 "i32" 138 "i32"
128 ) 139 ),
140 deprecated: false
129 }, 141 },
130 StructureNode { 142 StructureNode {
131 parent: None, 143 parent: None,
@@ -133,7 +145,8 @@ source: crates/ra_ide_api_light/src/structure.rs
133 navigation_range: [239; 240), 145 navigation_range: [239; 240),
134 node_range: [234; 243), 146 node_range: [234; 243),
135 kind: IMPL_BLOCK, 147 kind: IMPL_BLOCK,
136 detail: None 148 detail: None,
149 deprecated: false
137 }, 150 },
138 StructureNode { 151 StructureNode {
139 parent: None, 152 parent: None,
@@ -141,6 +154,29 @@ source: crates/ra_ide_api_light/src/structure.rs
141 navigation_range: [265; 266), 154 navigation_range: [265; 266),
142 node_range: [245; 269), 155 node_range: [245; 269),
143 kind: IMPL_BLOCK, 156 kind: IMPL_BLOCK,
144 detail: None 157 detail: None,
158 deprecated: false
159 },
160 StructureNode {
161 parent: None,
162 label: "obsolete",
163 navigation_range: [288; 296),
164 node_range: [271; 301),
165 kind: FN_DEF,
166 detail: Some(
167 "fn()"
168 ),
169 deprecated: true
170 },
171 StructureNode {
172 parent: None,
173 label: "very_obsolete",
174 navigation_range: [341; 354),
175 node_range: [303; 359),
176 kind: FN_DEF,
177 detail: Some(
178 "fn()"
179 ),
180 deprecated: true
145 } 181 }
146] 182]
diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs
index 4e080ed03..dc3534498 100644
--- a/crates/ra_ide_api_light/src/structure.rs
+++ b/crates/ra_ide_api_light/src/structure.rs
@@ -2,7 +2,7 @@ use crate::TextRange;
2 2
3use ra_syntax::{ 3use ra_syntax::{
4 algo::visit::{visitor, Visitor}, 4 algo::visit::{visitor, Visitor},
5 ast::{self, NameOwner, TypeParamsOwner}, 5 ast::{self, AttrsOwner, NameOwner, TypeParamsOwner},
6 AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, 6 AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent,
7}; 7};
8 8
@@ -14,6 +14,7 @@ pub struct StructureNode {
14 pub node_range: TextRange, 14 pub node_range: TextRange,
15 pub kind: SyntaxKind, 15 pub kind: SyntaxKind,
16 pub detail: Option<String>, 16 pub detail: Option<String>,
17 pub deprecated: bool,
17} 18}
18 19
19pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> { 20pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
@@ -40,11 +41,11 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
40} 41}
41 42
42fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { 43fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
43 fn decl<N: NameOwner>(node: &N) -> Option<StructureNode> { 44 fn decl<N: NameOwner + AttrsOwner>(node: &N) -> Option<StructureNode> {
44 decl_with_detail(node, None) 45 decl_with_detail(node, None)
45 } 46 }
46 47
47 fn decl_with_type_ref<N: NameOwner>( 48 fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
48 node: &N, 49 node: &N,
49 type_ref: Option<&ast::TypeRef>, 50 type_ref: Option<&ast::TypeRef>,
50 ) -> Option<StructureNode> { 51 ) -> Option<StructureNode> {
@@ -56,8 +57,12 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
56 decl_with_detail(node, detail) 57 decl_with_detail(node, detail)
57 } 58 }
58 59
59 fn decl_with_detail<N: NameOwner>(node: &N, detail: Option<String>) -> Option<StructureNode> { 60 fn decl_with_detail<N: NameOwner + AttrsOwner>(
61 node: &N,
62 detail: Option<String>,
63 ) -> Option<StructureNode> {
60 let name = node.name()?; 64 let name = node.name()?;
65 dbg!(name.text().to_string());
61 Some(StructureNode { 66 Some(StructureNode {
62 parent: None, 67 parent: None,
63 label: name.text().to_string(), 68 label: name.text().to_string(),
@@ -65,6 +70,10 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
65 node_range: node.syntax().range(), 70 node_range: node.syntax().range(),
66 kind: node.syntax().kind(), 71 kind: node.syntax().kind(),
67 detail, 72 detail,
73 deprecated: node
74 .attrs()
75 .filter_map(|x| x.as_named())
76 .any(|x| x == "deprecated"),
68 }) 77 })
69 } 78 }
70 79
@@ -128,6 +137,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
128 node_range: im.syntax().range(), 137 node_range: im.syntax().range(),
129 kind: im.syntax().kind(), 138 kind: im.syntax().kind(),
130 detail: None, 139 detail: None,
140 deprecated: false,
131 }; 141 };
132 Some(node) 142 Some(node)
133 }) 143 })
@@ -165,6 +175,12 @@ const C: i32 = 92;
165impl E {} 175impl E {}
166 176
167impl fmt::Debug for E {} 177impl fmt::Debug for E {}
178
179#[deprecated]
180fn obsolete() {}
181
182#[deprecated(note = "for awhile")]
183fn very_obsolete() {}
168"#, 184"#,
169 ); 185 );
170 let structure = file_structure(&file); 186 let structure = file_structure(&file);
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 4720a8843..ab2b81bf0 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -140,7 +140,7 @@ pub fn handle_document_symbol(
140 name: symbol.label, 140 name: symbol.label,
141 detail: symbol.detail, 141 detail: symbol.detail,
142 kind: symbol.kind.conv(), 142 kind: symbol.kind.conv(),
143 deprecated: None, 143 deprecated: Some(symbol.deprecated),
144 range: symbol.node_range.conv_with(&line_index), 144 range: symbol.node_range.conv_with(&line_index),
145 selection_range: symbol.navigation_range.conv_with(&line_index), 145 selection_range: symbol.navigation_range.conv_with(&line_index),
146 children: None, 146 children: None,
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 3d22a88f3..d6237532b 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -177,6 +177,16 @@ impl Attr {
177 None 177 None
178 } 178 }
179 } 179 }
180
181 pub fn as_named(&self) -> Option<SmolStr> {
182 let tt = self.value()?;
183 let attr = tt.syntax().children().nth(1)?;
184 if attr.kind() == IDENT {
185 Some(attr.leaf_text().unwrap().clone())
186 } else {
187 None
188 }
189 }
180} 190}
181 191
182impl Comment { 192impl Comment {
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index a8d60e882..60314d245 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -755,6 +755,7 @@ impl ToOwned for EnumVariant {
755 755
756impl ast::NameOwner for EnumVariant {} 756impl ast::NameOwner for EnumVariant {}
757impl ast::DocCommentsOwner for EnumVariant {} 757impl ast::DocCommentsOwner for EnumVariant {}
758impl ast::AttrsOwner for EnumVariant {}
758impl EnumVariant { 759impl EnumVariant {
759 pub fn expr(&self) -> Option<&Expr> { 760 pub fn expr(&self) -> Option<&Expr> {
760 super::child_opt(self) 761 super::child_opt(self)
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 2ed1fd1b8..046db5885 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -281,7 +281,7 @@ Grammar(
281 "DocCommentsOwner" 281 "DocCommentsOwner"
282 ], options: [["variant_list", "EnumVariantList"]] ), 282 ], options: [["variant_list", "EnumVariantList"]] ),
283 "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ), 283 "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ),
284 "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner"], options: ["Expr"] ), 284 "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner", "AttrsOwner"], options: ["Expr"] ),
285 "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ), 285 "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ),
286 "Module": ( 286 "Module": (
287 traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ], 287 traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ],