diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/completion.rs | 5 | ||||
-rw-r--r-- | crates/ra_analysis/src/db.rs | 9 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/imp.rs | 26 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/mod.rs | 83 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/scope.rs | 435 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/mod.rs | 88 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/imp.rs | 19 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/mod.rs | 28 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/scope.rs | 6 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 5 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/syntax_ptr.rs | 1 | ||||
-rw-r--r-- | crates/ra_editor/src/scope/fn_scope.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 198 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 2 |
15 files changed, 712 insertions, 198 deletions
diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_analysis/src/completion.rs index 0141d132e..869ab5afb 100644 --- a/crates/ra_analysis/src/completion.rs +++ b/crates/ra_analysis/src/completion.rs | |||
@@ -1,14 +1,15 @@ | |||
1 | use ra_editor::{CompletionItem, find_node_at_offset}; | 1 | use ra_editor::{CompletionItem, find_node_at_offset}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AtomEdit, File, TextUnit, AstNode, | 3 | AtomEdit, File, TextUnit, AstNode, |
4 | ast::{self, ModuleItemOwner, AstChildren}, | 4 | ast, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | FileId, Cancelable, | 8 | FileId, Cancelable, |
9 | input::FilesDatabase, | 9 | input::FilesDatabase, |
10 | db::{self, SyntaxDatabase}, | 10 | db::{self, SyntaxDatabase}, |
11 | descriptors::module::{ModulesDatabase, ModuleTree, ModuleId, scope::ModuleScope}, | 11 | descriptors::DescriptorDatabase, |
12 | descriptors::module::{ModuleTree, ModuleId}, | ||
12 | }; | 13 | }; |
13 | 14 | ||
14 | pub(crate) fn resolve_based_completion(db: &db::RootDatabase, file_id: FileId, offset: TextUnit) -> Cancelable<Option<Vec<CompletionItem>>> { | 15 | pub(crate) fn resolve_based_completion(db: &db::RootDatabase, file_id: FileId, offset: TextUnit) -> Cancelable<Option<Vec<CompletionItem>>> { |
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index e7a5d5e2f..fe6587f20 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -9,7 +9,10 @@ use salsa; | |||
9 | use crate::{ | 9 | use crate::{ |
10 | db, | 10 | db, |
11 | Cancelable, Canceled, | 11 | Cancelable, Canceled, |
12 | descriptors::module::{SubmodulesQuery, ModuleTreeQuery, ModulesDatabase, ModuleScopeQuery}, | 12 | descriptors::{ |
13 | DescriptorDatabase, SubmodulesQuery, ModuleTreeQuery, ModuleScopeQuery, | ||
14 | FnSyntaxQuery, FnScopesQuery | ||
15 | }, | ||
13 | symbol_index::SymbolIndex, | 16 | symbol_index::SymbolIndex, |
14 | syntax_ptr::{SyntaxPtrDatabase, ResolveSyntaxPtrQuery}, | 17 | syntax_ptr::{SyntaxPtrDatabase, ResolveSyntaxPtrQuery}, |
15 | FileId, | 18 | FileId, |
@@ -63,10 +66,12 @@ salsa::database_storage! { | |||
63 | fn file_lines() for FileLinesQuery; | 66 | fn file_lines() for FileLinesQuery; |
64 | fn file_symbols() for FileSymbolsQuery; | 67 | fn file_symbols() for FileSymbolsQuery; |
65 | } | 68 | } |
66 | impl ModulesDatabase { | 69 | impl DescriptorDatabase { |
67 | fn module_tree() for ModuleTreeQuery; | 70 | fn module_tree() for ModuleTreeQuery; |
68 | fn module_descriptor() for SubmodulesQuery; | 71 | fn module_descriptor() for SubmodulesQuery; |
69 | fn module_scope() for ModuleScopeQuery; | 72 | fn module_scope() for ModuleScopeQuery; |
73 | fn fn_syntax() for FnSyntaxQuery; | ||
74 | fn fn_scopes() for FnScopesQuery; | ||
70 | } | 75 | } |
71 | impl SyntaxPtrDatabase { | 76 | impl SyntaxPtrDatabase { |
72 | fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; | 77 | fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; |
diff --git a/crates/ra_analysis/src/descriptors/function/imp.rs b/crates/ra_analysis/src/descriptors/function/imp.rs new file mode 100644 index 000000000..0a006f733 --- /dev/null +++ b/crates/ra_analysis/src/descriptors/function/imp.rs | |||
@@ -0,0 +1,26 @@ | |||
1 | use std::sync::Arc; | ||
2 | |||
3 | use ra_syntax::{ | ||
4 | ast::{AstNode, FnDef, FnDefNode}, | ||
5 | }; | ||
6 | |||
7 | use crate::{ | ||
8 | descriptors::{ | ||
9 | DescriptorDatabase, | ||
10 | function::{FnId, FnScopes}, | ||
11 | }, | ||
12 | }; | ||
13 | |||
14 | /// Resolve `FnId` to the corresponding `SyntaxNode` | ||
15 | /// TODO: this should return something more type-safe then `SyntaxNode` | ||
16 | pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { | ||
17 | let syntax = db.resolve_syntax_ptr(fn_id.0); | ||
18 | let fn_def = FnDef::cast(syntax.borrowed()).unwrap(); | ||
19 | FnDefNode::new(fn_def) | ||
20 | } | ||
21 | |||
22 | pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> { | ||
23 | let syntax = db.fn_syntax(fn_id); | ||
24 | let res = FnScopes::new(syntax.ast()); | ||
25 | Arc::new(res) | ||
26 | } | ||
diff --git a/crates/ra_analysis/src/descriptors/function/mod.rs b/crates/ra_analysis/src/descriptors/function/mod.rs new file mode 100644 index 000000000..687413ddc --- /dev/null +++ b/crates/ra_analysis/src/descriptors/function/mod.rs | |||
@@ -0,0 +1,83 @@ | |||
1 | pub(super) mod imp; | ||
2 | mod scope; | ||
3 | |||
4 | use ra_syntax::{ | ||
5 | ast::{self, AstNode, NameOwner} | ||
6 | }; | ||
7 | |||
8 | use crate::{ | ||
9 | FileId, | ||
10 | syntax_ptr::SyntaxPtr | ||
11 | }; | ||
12 | |||
13 | pub(crate) use self::scope::FnScopes; | ||
14 | |||
15 | |||
16 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
17 | pub(crate) struct FnId(SyntaxPtr); | ||
18 | |||
19 | impl FnId { | ||
20 | pub(crate) fn new(file_id: FileId, fn_def: ast::FnDef) -> FnId { | ||
21 | let ptr = SyntaxPtr::new(file_id, fn_def.syntax()); | ||
22 | FnId(ptr) | ||
23 | } | ||
24 | } | ||
25 | |||
26 | |||
27 | #[derive(Debug, Clone)] | ||
28 | pub struct FnDescriptor { | ||
29 | pub name: String, | ||
30 | pub label: String, | ||
31 | pub ret_type: Option<String>, | ||
32 | pub params: Vec<String>, | ||
33 | } | ||
34 | |||
35 | impl FnDescriptor { | ||
36 | pub fn new(node: ast::FnDef) -> Option<Self> { | ||
37 | let name = node.name()?.text().to_string(); | ||
38 | |||
39 | // Strip the body out for the label. | ||
40 | let label: String = if let Some(body) = node.body() { | ||
41 | let body_range = body.syntax().range(); | ||
42 | let label: String = node | ||
43 | .syntax() | ||
44 | .children() | ||
45 | .filter(|child| !child.range().is_subrange(&body_range)) | ||
46 | .map(|node| node.text().to_string()) | ||
47 | .collect(); | ||
48 | label | ||
49 | } else { | ||
50 | node.syntax().text().to_string() | ||
51 | }; | ||
52 | |||
53 | let params = FnDescriptor::param_list(node); | ||
54 | let ret_type = node.ret_type().map(|r| r.syntax().text().to_string()); | ||
55 | |||
56 | Some(FnDescriptor { | ||
57 | name, | ||
58 | ret_type, | ||
59 | params, | ||
60 | label, | ||
61 | }) | ||
62 | } | ||
63 | |||
64 | fn param_list(node: ast::FnDef) -> Vec<String> { | ||
65 | let mut res = vec![]; | ||
66 | if let Some(param_list) = node.param_list() { | ||
67 | if let Some(self_param) = param_list.self_param() { | ||
68 | res.push(self_param.syntax().text().to_string()) | ||
69 | } | ||
70 | |||
71 | // Maybe use param.pat here? See if we can just extract the name? | ||
72 | //res.extend(param_list.params().map(|p| p.syntax().text().to_string())); | ||
73 | res.extend( | ||
74 | param_list | ||
75 | .params() | ||
76 | .filter_map(|p| p.pat()) | ||
77 | .map(|pat| pat.syntax().text().to_string()), | ||
78 | ); | ||
79 | } | ||
80 | res | ||
81 | } | ||
82 | } | ||
83 | |||
diff --git a/crates/ra_analysis/src/descriptors/function/scope.rs b/crates/ra_analysis/src/descriptors/function/scope.rs new file mode 100644 index 000000000..5333a0a3b --- /dev/null +++ b/crates/ra_analysis/src/descriptors/function/scope.rs | |||
@@ -0,0 +1,435 @@ | |||
1 | use rustc_hash::FxHashMap; | ||
2 | |||
3 | use ra_syntax::{ | ||
4 | algo::generate, | ||
5 | ast::{self, ArgListOwner, LoopBodyOwner, NameOwner}, | ||
6 | AstNode, SmolStr, SyntaxNodeRef, | ||
7 | }; | ||
8 | |||
9 | use crate::syntax_ptr::LocalSyntaxPtr; | ||
10 | |||
11 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
12 | pub(crate) struct ScopeId(u32); | ||
13 | |||
14 | #[derive(Debug, PartialEq, Eq)] | ||
15 | pub struct FnScopes { | ||
16 | pub(crate) self_param: Option<LocalSyntaxPtr>, | ||
17 | scopes: Vec<ScopeData>, | ||
18 | scope_for: FxHashMap<LocalSyntaxPtr, ScopeId>, | ||
19 | } | ||
20 | |||
21 | #[derive(Debug, PartialEq, Eq)] | ||
22 | pub struct ScopeEntry { | ||
23 | name: SmolStr, | ||
24 | ptr: LocalSyntaxPtr, | ||
25 | } | ||
26 | |||
27 | #[derive(Debug, PartialEq, Eq)] | ||
28 | struct ScopeData { | ||
29 | parent: Option<ScopeId>, | ||
30 | entries: Vec<ScopeEntry>, | ||
31 | } | ||
32 | |||
33 | impl FnScopes { | ||
34 | pub(crate) fn new(fn_def: ast::FnDef) -> FnScopes { | ||
35 | let mut scopes = FnScopes { | ||
36 | self_param: fn_def | ||
37 | .param_list() | ||
38 | .and_then(|it| it.self_param()) | ||
39 | .map(|it| LocalSyntaxPtr::new(it.syntax())), | ||
40 | scopes: Vec::new(), | ||
41 | scope_for: FxHashMap::default(), | ||
42 | }; | ||
43 | let root = scopes.root_scope(); | ||
44 | scopes.add_params_bindings(root, fn_def.param_list()); | ||
45 | if let Some(body) = fn_def.body() { | ||
46 | compute_block_scopes(body, &mut scopes, root) | ||
47 | } | ||
48 | scopes | ||
49 | } | ||
50 | pub(crate) fn entries(&self, scope: ScopeId) -> &[ScopeEntry] { | ||
51 | &self.get(scope).entries | ||
52 | } | ||
53 | pub fn scope_chain<'a>(&'a self, node: SyntaxNodeRef) -> impl Iterator<Item = ScopeId> + 'a { | ||
54 | generate(self.scope_for(node), move |&scope| { | ||
55 | self.get(scope).parent | ||
56 | }) | ||
57 | } | ||
58 | fn root_scope(&mut self) -> ScopeId { | ||
59 | let res = ScopeId(self.scopes.len() as u32); | ||
60 | self.scopes.push(ScopeData { | ||
61 | parent: None, | ||
62 | entries: vec![], | ||
63 | }); | ||
64 | res | ||
65 | } | ||
66 | fn new_scope(&mut self, parent: ScopeId) -> ScopeId { | ||
67 | let res = ScopeId(self.scopes.len() as u32); | ||
68 | self.scopes.push(ScopeData { | ||
69 | parent: Some(parent), | ||
70 | entries: vec![], | ||
71 | }); | ||
72 | res | ||
73 | } | ||
74 | fn add_bindings(&mut self, scope: ScopeId, pat: ast::Pat) { | ||
75 | let entries = pat | ||
76 | .syntax() | ||
77 | .descendants() | ||
78 | .filter_map(ast::BindPat::cast) | ||
79 | .filter_map(ScopeEntry::new); | ||
80 | self.get_mut(scope).entries.extend(entries); | ||
81 | } | ||
82 | fn add_params_bindings(&mut self, scope: ScopeId, params: Option<ast::ParamList>) { | ||
83 | params | ||
84 | .into_iter() | ||
85 | .flat_map(|it| it.params()) | ||
86 | .filter_map(|it| it.pat()) | ||
87 | .for_each(|it| self.add_bindings(scope, it)); | ||
88 | } | ||
89 | fn set_scope(&mut self, node: SyntaxNodeRef, scope: ScopeId) { | ||
90 | self.scope_for.insert(LocalSyntaxPtr::new(node), scope); | ||
91 | } | ||
92 | fn scope_for(&self, node: SyntaxNodeRef) -> Option<ScopeId> { | ||
93 | node.ancestors() | ||
94 | .map(LocalSyntaxPtr::new) | ||
95 | .filter_map(|it| self.scope_for.get(&it).map(|&scope| scope)) | ||
96 | .next() | ||
97 | } | ||
98 | fn get(&self, scope: ScopeId) -> &ScopeData { | ||
99 | &self.scopes[scope.0 as usize] | ||
100 | } | ||
101 | fn get_mut(&mut self, scope: ScopeId) -> &mut ScopeData { | ||
102 | &mut self.scopes[scope.0 as usize] | ||
103 | } | ||
104 | } | ||
105 | |||
106 | impl ScopeEntry { | ||
107 | fn new(pat: ast::BindPat) -> Option<ScopeEntry> { | ||
108 | let name = pat.name()?; | ||
109 | let res = ScopeEntry { | ||
110 | name: name.text(), | ||
111 | ptr: LocalSyntaxPtr::new(pat.syntax()), | ||
112 | }; | ||
113 | Some(res) | ||
114 | } | ||
115 | pub(crate) fn name(&self) -> &SmolStr { | ||
116 | &self.name | ||
117 | } | ||
118 | pub(crate) fn ptr(&self) -> LocalSyntaxPtr { | ||
119 | self.ptr | ||
120 | } | ||
121 | } | ||
122 | |||
123 | fn compute_block_scopes(block: ast::Block, scopes: &mut FnScopes, mut scope: ScopeId) { | ||
124 | for stmt in block.statements() { | ||
125 | match stmt { | ||
126 | ast::Stmt::LetStmt(stmt) => { | ||
127 | if let Some(expr) = stmt.initializer() { | ||
128 | scopes.set_scope(expr.syntax(), scope); | ||
129 | compute_expr_scopes(expr, scopes, scope); | ||
130 | } | ||
131 | scope = scopes.new_scope(scope); | ||
132 | if let Some(pat) = stmt.pat() { | ||
133 | scopes.add_bindings(scope, pat); | ||
134 | } | ||
135 | } | ||
136 | ast::Stmt::ExprStmt(expr_stmt) => { | ||
137 | if let Some(expr) = expr_stmt.expr() { | ||
138 | scopes.set_scope(expr.syntax(), scope); | ||
139 | compute_expr_scopes(expr, scopes, scope); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | if let Some(expr) = block.expr() { | ||
145 | scopes.set_scope(expr.syntax(), scope); | ||
146 | compute_expr_scopes(expr, scopes, scope); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { | ||
151 | match expr { | ||
152 | ast::Expr::IfExpr(e) => { | ||
153 | let cond_scope = e | ||
154 | .condition() | ||
155 | .and_then(|cond| compute_cond_scopes(cond, scopes, scope)); | ||
156 | if let Some(block) = e.then_branch() { | ||
157 | compute_block_scopes(block, scopes, cond_scope.unwrap_or(scope)); | ||
158 | } | ||
159 | if let Some(block) = e.else_branch() { | ||
160 | compute_block_scopes(block, scopes, scope); | ||
161 | } | ||
162 | } | ||
163 | ast::Expr::BlockExpr(e) => { | ||
164 | if let Some(block) = e.block() { | ||
165 | compute_block_scopes(block, scopes, scope); | ||
166 | } | ||
167 | } | ||
168 | ast::Expr::LoopExpr(e) => { | ||
169 | if let Some(block) = e.loop_body() { | ||
170 | compute_block_scopes(block, scopes, scope); | ||
171 | } | ||
172 | } | ||
173 | ast::Expr::WhileExpr(e) => { | ||
174 | let cond_scope = e | ||
175 | .condition() | ||
176 | .and_then(|cond| compute_cond_scopes(cond, scopes, scope)); | ||
177 | if let Some(block) = e.loop_body() { | ||
178 | compute_block_scopes(block, scopes, cond_scope.unwrap_or(scope)); | ||
179 | } | ||
180 | } | ||
181 | ast::Expr::ForExpr(e) => { | ||
182 | if let Some(expr) = e.iterable() { | ||
183 | compute_expr_scopes(expr, scopes, scope); | ||
184 | } | ||
185 | let mut scope = scope; | ||
186 | if let Some(pat) = e.pat() { | ||
187 | scope = scopes.new_scope(scope); | ||
188 | scopes.add_bindings(scope, pat); | ||
189 | } | ||
190 | if let Some(block) = e.loop_body() { | ||
191 | compute_block_scopes(block, scopes, scope); | ||
192 | } | ||
193 | } | ||
194 | ast::Expr::LambdaExpr(e) => { | ||
195 | let scope = scopes.new_scope(scope); | ||
196 | scopes.add_params_bindings(scope, e.param_list()); | ||
197 | if let Some(body) = e.body() { | ||
198 | scopes.set_scope(body.syntax(), scope); | ||
199 | compute_expr_scopes(body, scopes, scope); | ||
200 | } | ||
201 | } | ||
202 | ast::Expr::CallExpr(e) => { | ||
203 | compute_call_scopes(e.expr(), e.arg_list(), scopes, scope); | ||
204 | } | ||
205 | ast::Expr::MethodCallExpr(e) => { | ||
206 | compute_call_scopes(e.expr(), e.arg_list(), scopes, scope); | ||
207 | } | ||
208 | ast::Expr::MatchExpr(e) => { | ||
209 | if let Some(expr) = e.expr() { | ||
210 | compute_expr_scopes(expr, scopes, scope); | ||
211 | } | ||
212 | for arm in e.match_arm_list().into_iter().flat_map(|it| it.arms()) { | ||
213 | let scope = scopes.new_scope(scope); | ||
214 | for pat in arm.pats() { | ||
215 | scopes.add_bindings(scope, pat); | ||
216 | } | ||
217 | if let Some(expr) = arm.expr() { | ||
218 | compute_expr_scopes(expr, scopes, scope); | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | _ => expr | ||
223 | .syntax() | ||
224 | .children() | ||
225 | .filter_map(ast::Expr::cast) | ||
226 | .for_each(|expr| compute_expr_scopes(expr, scopes, scope)), | ||
227 | }; | ||
228 | |||
229 | fn compute_call_scopes( | ||
230 | receiver: Option<ast::Expr>, | ||
231 | arg_list: Option<ast::ArgList>, | ||
232 | scopes: &mut FnScopes, | ||
233 | scope: ScopeId, | ||
234 | ) { | ||
235 | arg_list | ||
236 | .into_iter() | ||
237 | .flat_map(|it| it.args()) | ||
238 | .chain(receiver) | ||
239 | .for_each(|expr| compute_expr_scopes(expr, scopes, scope)); | ||
240 | } | ||
241 | |||
242 | fn compute_cond_scopes( | ||
243 | cond: ast::Condition, | ||
244 | scopes: &mut FnScopes, | ||
245 | scope: ScopeId, | ||
246 | ) -> Option<ScopeId> { | ||
247 | if let Some(expr) = cond.expr() { | ||
248 | compute_expr_scopes(expr, scopes, scope); | ||
249 | } | ||
250 | if let Some(pat) = cond.pat() { | ||
251 | let s = scopes.new_scope(scope); | ||
252 | scopes.add_bindings(s, pat); | ||
253 | Some(s) | ||
254 | } else { | ||
255 | None | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | |||
260 | pub fn resolve_local_name<'a>( | ||
261 | name_ref: ast::NameRef, | ||
262 | scopes: &'a FnScopes, | ||
263 | ) -> Option<&'a ScopeEntry> { | ||
264 | use rustc_hash::FxHashSet; | ||
265 | |||
266 | let mut shadowed = FxHashSet::default(); | ||
267 | let ret = scopes | ||
268 | .scope_chain(name_ref.syntax()) | ||
269 | .flat_map(|scope| scopes.entries(scope).iter()) | ||
270 | .filter(|entry| shadowed.insert(entry.name())) | ||
271 | .filter(|entry| entry.name() == &name_ref.text()) | ||
272 | .nth(0); | ||
273 | ret | ||
274 | } | ||
275 | |||
276 | #[cfg(test)] | ||
277 | mod tests { | ||
278 | use ra_syntax::File; | ||
279 | use test_utils::extract_offset; | ||
280 | use ra_editor::{find_node_at_offset}; | ||
281 | |||
282 | use super::*; | ||
283 | |||
284 | |||
285 | fn do_check(code: &str, expected: &[&str]) { | ||
286 | let (off, code) = extract_offset(code); | ||
287 | let code = { | ||
288 | let mut buf = String::new(); | ||
289 | let off = u32::from(off) as usize; | ||
290 | buf.push_str(&code[..off]); | ||
291 | buf.push_str("marker"); | ||
292 | buf.push_str(&code[off..]); | ||
293 | buf | ||
294 | }; | ||
295 | let file = File::parse(&code); | ||
296 | let marker: ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); | ||
297 | let fn_def: ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | ||
298 | let scopes = FnScopes::new(fn_def); | ||
299 | let actual = scopes | ||
300 | .scope_chain(marker.syntax()) | ||
301 | .flat_map(|scope| scopes.entries(scope)) | ||
302 | .map(|it| it.name()) | ||
303 | .collect::<Vec<_>>(); | ||
304 | assert_eq!(actual.as_slice(), expected); | ||
305 | } | ||
306 | |||
307 | #[test] | ||
308 | fn test_lambda_scope() { | ||
309 | do_check( | ||
310 | r" | ||
311 | fn quux(foo: i32) { | ||
312 | let f = |bar, baz: i32| { | ||
313 | <|> | ||
314 | }; | ||
315 | }", | ||
316 | &["bar", "baz", "foo"], | ||
317 | ); | ||
318 | } | ||
319 | |||
320 | #[test] | ||
321 | fn test_call_scope() { | ||
322 | do_check( | ||
323 | r" | ||
324 | fn quux() { | ||
325 | f(|x| <|> ); | ||
326 | }", | ||
327 | &["x"], | ||
328 | ); | ||
329 | } | ||
330 | |||
331 | #[test] | ||
332 | fn test_metod_call_scope() { | ||
333 | do_check( | ||
334 | r" | ||
335 | fn quux() { | ||
336 | z.f(|x| <|> ); | ||
337 | }", | ||
338 | &["x"], | ||
339 | ); | ||
340 | } | ||
341 | |||
342 | #[test] | ||
343 | fn test_loop_scope() { | ||
344 | do_check( | ||
345 | r" | ||
346 | fn quux() { | ||
347 | loop { | ||
348 | let x = (); | ||
349 | <|> | ||
350 | }; | ||
351 | }", | ||
352 | &["x"], | ||
353 | ); | ||
354 | } | ||
355 | |||
356 | #[test] | ||
357 | fn test_match() { | ||
358 | do_check( | ||
359 | r" | ||
360 | fn quux() { | ||
361 | match () { | ||
362 | Some(x) => { | ||
363 | <|> | ||
364 | } | ||
365 | }; | ||
366 | }", | ||
367 | &["x"], | ||
368 | ); | ||
369 | } | ||
370 | |||
371 | #[test] | ||
372 | fn test_shadow_variable() { | ||
373 | do_check( | ||
374 | r" | ||
375 | fn foo(x: String) { | ||
376 | let x : &str = &x<|>; | ||
377 | }", | ||
378 | &["x"], | ||
379 | ); | ||
380 | } | ||
381 | |||
382 | fn do_check_local_name(code: &str, expected_offset: u32) { | ||
383 | let (off, code) = extract_offset(code); | ||
384 | let file = File::parse(&code); | ||
385 | let fn_def: ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | ||
386 | let name_ref: ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); | ||
387 | |||
388 | let scopes = FnScopes::new(fn_def); | ||
389 | |||
390 | let local_name_entry = resolve_local_name(name_ref, &scopes).unwrap(); | ||
391 | let local_name = local_name_entry.ptr().resolve(&file); | ||
392 | let expected_name = | ||
393 | find_node_at_offset::<ast::Name>(file.syntax(), expected_offset.into()).unwrap(); | ||
394 | assert_eq!(local_name.range(), expected_name.syntax().range()); | ||
395 | } | ||
396 | |||
397 | #[test] | ||
398 | fn test_resolve_local_name() { | ||
399 | do_check_local_name( | ||
400 | r#" | ||
401 | fn foo(x: i32, y: u32) { | ||
402 | { | ||
403 | let z = x * 2; | ||
404 | } | ||
405 | { | ||
406 | let t = x<|> * 3; | ||
407 | } | ||
408 | }"#, | ||
409 | 21, | ||
410 | ); | ||
411 | } | ||
412 | |||
413 | #[test] | ||
414 | fn test_resolve_local_name_declaration() { | ||
415 | do_check_local_name( | ||
416 | r#" | ||
417 | fn foo(x: String) { | ||
418 | let x : &str = &x<|>; | ||
419 | }"#, | ||
420 | 21, | ||
421 | ); | ||
422 | } | ||
423 | |||
424 | #[test] | ||
425 | fn test_resolve_local_name_shadow() { | ||
426 | do_check_local_name( | ||
427 | r" | ||
428 | fn foo(x: String) { | ||
429 | let x : &str = &x; | ||
430 | x<|> | ||
431 | }", | ||
432 | 46, | ||
433 | ); | ||
434 | } | ||
435 | } | ||
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs index 0220f7d5d..0c4991757 100644 --- a/crates/ra_analysis/src/descriptors/mod.rs +++ b/crates/ra_analysis/src/descriptors/mod.rs | |||
@@ -1,62 +1,46 @@ | |||
1 | pub(crate) mod module; | 1 | pub(crate) mod module; |
2 | pub(crate) mod function; | ||
3 | |||
4 | use std::sync::Arc; | ||
2 | 5 | ||
3 | use ra_syntax::{ | 6 | use ra_syntax::{ |
4 | ast::{self, AstNode, NameOwner}, | 7 | SmolStr, |
8 | ast::{FnDefNode}, | ||
5 | }; | 9 | }; |
6 | 10 | ||
7 | #[derive(Debug, Clone)] | 11 | use crate::{ |
8 | pub struct FnDescriptor { | 12 | FileId, Cancelable, |
9 | pub name: String, | 13 | db::SyntaxDatabase, |
10 | pub label: String, | 14 | descriptors::module::{ModuleTree, ModuleId, ModuleScope}, |
11 | pub ret_type: Option<String>, | 15 | descriptors::function::{FnId, FnScopes}, |
12 | pub params: Vec<String>, | 16 | input::SourceRootId, |
13 | } | 17 | syntax_ptr::SyntaxPtrDatabase, |
14 | 18 | }; | |
15 | impl FnDescriptor { | ||
16 | pub fn new(node: ast::FnDef) -> Option<Self> { | ||
17 | let name = node.name()?.text().to_string(); | ||
18 | |||
19 | // Strip the body out for the label. | ||
20 | let label: String = if let Some(body) = node.body() { | ||
21 | let body_range = body.syntax().range(); | ||
22 | let label: String = node | ||
23 | .syntax() | ||
24 | .children() | ||
25 | .filter(|child| !child.range().is_subrange(&body_range)) | ||
26 | .map(|node| node.text().to_string()) | ||
27 | .collect(); | ||
28 | label | ||
29 | } else { | ||
30 | node.syntax().text().to_string() | ||
31 | }; | ||
32 | |||
33 | let params = FnDescriptor::param_list(node); | ||
34 | let ret_type = node.ret_type().map(|r| r.syntax().text().to_string()); | ||
35 | |||
36 | Some(FnDescriptor { | ||
37 | name, | ||
38 | ret_type, | ||
39 | params, | ||
40 | label, | ||
41 | }) | ||
42 | } | ||
43 | 19 | ||
44 | fn param_list(node: ast::FnDef) -> Vec<String> { | ||
45 | let mut res = vec![]; | ||
46 | if let Some(param_list) = node.param_list() { | ||
47 | if let Some(self_param) = param_list.self_param() { | ||
48 | res.push(self_param.syntax().text().to_string()) | ||
49 | } | ||
50 | 20 | ||
51 | // Maybe use param.pat here? See if we can just extract the name? | 21 | salsa::query_group! { |
52 | //res.extend(param_list.params().map(|p| p.syntax().text().to_string())); | 22 | pub(crate) trait DescriptorDatabase: SyntaxDatabase + SyntaxPtrDatabase { |
53 | res.extend( | 23 | fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> { |
54 | param_list | 24 | type ModuleTreeQuery; |
55 | .params() | 25 | use fn module::imp::module_tree; |
56 | .filter_map(|p| p.pat()) | 26 | } |
57 | .map(|pat| pat.syntax().text().to_string()), | 27 | fn submodules(file_id: FileId) -> Cancelable<Arc<Vec<SmolStr>>> { |
58 | ); | 28 | type SubmodulesQuery; |
29 | use fn module::imp::submodules; | ||
30 | } | ||
31 | fn module_scope(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleScope>> { | ||
32 | type ModuleScopeQuery; | ||
33 | use fn module::imp::module_scope; | ||
34 | } | ||
35 | fn fn_syntax(fn_id: FnId) -> FnDefNode { | ||
36 | type FnSyntaxQuery; | ||
37 | // Don't retain syntax trees in memory | ||
38 | storage volatile; | ||
39 | use fn function::imp::fn_syntax; | ||
40 | } | ||
41 | fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> { | ||
42 | type FnScopesQuery; | ||
43 | use fn function::imp::fn_scopes; | ||
59 | } | 44 | } |
60 | res | ||
61 | } | 45 | } |
62 | } | 46 | } |
diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs index 5fdaad137..dae3a356d 100644 --- a/crates/ra_analysis/src/descriptors/module/imp.rs +++ b/crates/ra_analysis/src/descriptors/module/imp.rs | |||
@@ -10,14 +10,15 @@ use ra_syntax::{ | |||
10 | use crate::{ | 10 | use crate::{ |
11 | FileId, Cancelable, FileResolverImp, db, | 11 | FileId, Cancelable, FileResolverImp, db, |
12 | input::{SourceRoot, SourceRootId}, | 12 | input::{SourceRoot, SourceRootId}, |
13 | descriptors::DescriptorDatabase, | ||
13 | }; | 14 | }; |
14 | 15 | ||
15 | use super::{ | 16 | use super::{ |
16 | ModuleData, ModuleTree, ModuleId, LinkId, LinkData, Problem, ModulesDatabase, ModuleScope | 17 | ModuleData, ModuleTree, ModuleId, LinkId, LinkData, Problem, ModuleScope |
17 | }; | 18 | }; |
18 | 19 | ||
19 | 20 | ||
20 | pub(super) fn submodules(db: &impl ModulesDatabase, file_id: FileId) -> Cancelable<Arc<Vec<SmolStr>>> { | 21 | pub(crate) fn submodules(db: &impl DescriptorDatabase, file_id: FileId) -> Cancelable<Arc<Vec<SmolStr>>> { |
21 | db::check_canceled(db)?; | 22 | db::check_canceled(db)?; |
22 | let file = db.file_syntax(file_id); | 23 | let file = db.file_syntax(file_id); |
23 | let root = file.ast(); | 24 | let root = file.ast(); |
@@ -25,7 +26,7 @@ pub(super) fn submodules(db: &impl ModulesDatabase, file_id: FileId) -> Cancelab | |||
25 | Ok(Arc::new(submodules)) | 26 | Ok(Arc::new(submodules)) |
26 | } | 27 | } |
27 | 28 | ||
28 | pub(super) fn modules(root: ast::Root<'_>) -> impl Iterator<Item = (SmolStr, ast::Module<'_>)> { | 29 | pub(crate) fn modules(root: ast::Root<'_>) -> impl Iterator<Item = (SmolStr, ast::Module<'_>)> { |
29 | root.modules().filter_map(|module| { | 30 | root.modules().filter_map(|module| { |
30 | let name = module.name()?.text(); | 31 | let name = module.name()?.text(); |
31 | if !module.has_semi() { | 32 | if !module.has_semi() { |
@@ -35,8 +36,8 @@ pub(super) fn modules(root: ast::Root<'_>) -> impl Iterator<Item = (SmolStr, ast | |||
35 | }) | 36 | }) |
36 | } | 37 | } |
37 | 38 | ||
38 | pub(super) fn module_scope( | 39 | pub(crate) fn module_scope( |
39 | db: &impl ModulesDatabase, | 40 | db: &impl DescriptorDatabase, |
40 | source_root_id: SourceRootId, | 41 | source_root_id: SourceRootId, |
41 | module_id: ModuleId, | 42 | module_id: ModuleId, |
42 | ) -> Cancelable<Arc<ModuleScope>> { | 43 | ) -> Cancelable<Arc<ModuleScope>> { |
@@ -47,8 +48,8 @@ pub(super) fn module_scope( | |||
47 | Ok(Arc::new(res)) | 48 | Ok(Arc::new(res)) |
48 | } | 49 | } |
49 | 50 | ||
50 | pub(super) fn module_tree( | 51 | pub(crate) fn module_tree( |
51 | db: &impl ModulesDatabase, | 52 | db: &impl DescriptorDatabase, |
52 | source_root: SourceRootId, | 53 | source_root: SourceRootId, |
53 | ) -> Cancelable<Arc<ModuleTree>> { | 54 | ) -> Cancelable<Arc<ModuleTree>> { |
54 | db::check_canceled(db)?; | 55 | db::check_canceled(db)?; |
@@ -64,7 +65,7 @@ pub struct Submodule { | |||
64 | 65 | ||
65 | 66 | ||
66 | fn create_module_tree<'a>( | 67 | fn create_module_tree<'a>( |
67 | db: &impl ModulesDatabase, | 68 | db: &impl DescriptorDatabase, |
68 | source_root: SourceRootId, | 69 | source_root: SourceRootId, |
69 | ) -> Cancelable<ModuleTree> { | 70 | ) -> Cancelable<ModuleTree> { |
70 | let mut tree = ModuleTree { | 71 | let mut tree = ModuleTree { |
@@ -88,7 +89,7 @@ fn create_module_tree<'a>( | |||
88 | } | 89 | } |
89 | 90 | ||
90 | fn build_subtree( | 91 | fn build_subtree( |
91 | db: &impl ModulesDatabase, | 92 | db: &impl DescriptorDatabase, |
92 | source_root: &SourceRoot, | 93 | source_root: &SourceRoot, |
93 | tree: &mut ModuleTree, | 94 | tree: &mut ModuleTree, |
94 | visited: &mut FxHashSet<FileId>, | 95 | visited: &mut FxHashSet<FileId>, |
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index 9e5d73f94..667553f74 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs | |||
@@ -1,37 +1,13 @@ | |||
1 | mod imp; | 1 | pub(super) mod imp; |
2 | pub(crate) mod scope; | 2 | pub(crate) mod scope; |
3 | 3 | ||
4 | use std::sync::Arc; | ||
5 | |||
6 | use relative_path::RelativePathBuf; | 4 | use relative_path::RelativePathBuf; |
7 | use ra_syntax::{ast::{self, NameOwner, AstNode}, SmolStr, SyntaxNode}; | 5 | use ra_syntax::{ast::{self, NameOwner, AstNode}, SmolStr, SyntaxNode}; |
8 | 6 | ||
9 | use crate::{ | 7 | use crate::FileId; |
10 | FileId, Cancelable, | ||
11 | db::SyntaxDatabase, | ||
12 | input::SourceRootId, | ||
13 | }; | ||
14 | 8 | ||
15 | pub(crate) use self::scope::ModuleScope; | 9 | pub(crate) use self::scope::ModuleScope; |
16 | 10 | ||
17 | salsa::query_group! { | ||
18 | pub(crate) trait ModulesDatabase: SyntaxDatabase { | ||
19 | fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> { | ||
20 | type ModuleTreeQuery; | ||
21 | use fn imp::module_tree; | ||
22 | } | ||
23 | fn submodules(file_id: FileId) -> Cancelable<Arc<Vec<SmolStr>>> { | ||
24 | type SubmodulesQuery; | ||
25 | use fn imp::submodules; | ||
26 | } | ||
27 | fn module_scope(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleScope>> { | ||
28 | type ModuleScopeQuery; | ||
29 | use fn imp::module_scope; | ||
30 | } | ||
31 | } | ||
32 | } | ||
33 | |||
34 | |||
35 | #[derive(Debug, PartialEq, Eq, Hash)] | 11 | #[derive(Debug, PartialEq, Eq, Hash)] |
36 | pub(crate) struct ModuleTree { | 12 | pub(crate) struct ModuleTree { |
37 | mods: Vec<ModuleData>, | 13 | mods: Vec<ModuleData>, |
diff --git a/crates/ra_analysis/src/descriptors/module/scope.rs b/crates/ra_analysis/src/descriptors/module/scope.rs index da58ddce0..0f8f325ab 100644 --- a/crates/ra_analysis/src/descriptors/module/scope.rs +++ b/crates/ra_analysis/src/descriptors/module/scope.rs | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | 3 | ||
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | ast::{self, AstChildren, ModuleItemOwner}, | 5 | ast::{self, ModuleItemOwner}, |
6 | File, AstNode, SmolStr, SyntaxNode, SyntaxNodeRef, | 6 | File, AstNode, SmolStr, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::syntax_ptr::LocalSyntaxPtr; | 9 | use crate::syntax_ptr::LocalSyntaxPtr; |
@@ -99,7 +99,7 @@ fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) { | |||
99 | #[cfg(test)] | 99 | #[cfg(test)] |
100 | mod tests { | 100 | mod tests { |
101 | use super::*; | 101 | use super::*; |
102 | use ra_syntax::{ast::ModuleItemOwner, File}; | 102 | use ra_syntax::{File}; |
103 | 103 | ||
104 | fn do_check(code: &str, expected: &[&str]) { | 104 | fn do_check(code: &str, expected: &[&str]) { |
105 | let file = File::parse(&code); | 105 | let file = File::parse(&code); |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index efb3182a6..49b693ae8 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -21,8 +21,9 @@ use crate::{ | |||
21 | self, SyntaxDatabase, FileSyntaxQuery, | 21 | self, SyntaxDatabase, FileSyntaxQuery, |
22 | }, | 22 | }, |
23 | input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE}, | 23 | input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE}, |
24 | descriptors::module::{ModulesDatabase, ModuleTree, Problem}, | 24 | descriptors::DescriptorDatabase, |
25 | descriptors::{FnDescriptor}, | 25 | descriptors::module::{ModuleTree, Problem}, |
26 | descriptors::function::{FnDescriptor}, | ||
26 | symbol_index::SymbolIndex, | 27 | symbol_index::SymbolIndex, |
27 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, | 28 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, |
28 | Query, SourceChange, SourceFileEdit, Cancelable, | 29 | Query, SourceChange, SourceFileEdit, Cancelable, |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 363c72c0b..a77c9a5fa 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -29,7 +29,7 @@ use crate::{ | |||
29 | }; | 29 | }; |
30 | 30 | ||
31 | pub use crate::{ | 31 | pub use crate::{ |
32 | descriptors::FnDescriptor, | 32 | descriptors::function::FnDescriptor, |
33 | input::{FileId, FileResolver, CrateGraph, CrateId} | 33 | input::{FileId, FileResolver, CrateGraph, CrateId} |
34 | }; | 34 | }; |
35 | pub use ra_editor::{ | 35 | pub use ra_editor::{ |
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs index adbff4806..aee214318 100644 --- a/crates/ra_analysis/src/syntax_ptr.rs +++ b/crates/ra_analysis/src/syntax_ptr.rs | |||
@@ -12,6 +12,7 @@ salsa::query_group! { | |||
12 | pub(crate) trait SyntaxPtrDatabase: SyntaxDatabase { | 12 | pub(crate) trait SyntaxPtrDatabase: SyntaxDatabase { |
13 | fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode { | 13 | fn resolve_syntax_ptr(ptr: SyntaxPtr) -> SyntaxNode { |
14 | type ResolveSyntaxPtrQuery; | 14 | type ResolveSyntaxPtrQuery; |
15 | // Don't retain syntax trees in memory | ||
15 | storage volatile; | 16 | storage volatile; |
16 | } | 17 | } |
17 | } | 18 | } |
diff --git a/crates/ra_editor/src/scope/fn_scope.rs b/crates/ra_editor/src/scope/fn_scope.rs index f10bdf657..f5c113fd9 100644 --- a/crates/ra_editor/src/scope/fn_scope.rs +++ b/crates/ra_editor/src/scope/fn_scope.rs | |||
@@ -83,6 +83,7 @@ impl FnScopes { | |||
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | #[derive(PartialEq, Eq)] | ||
86 | pub struct ScopeEntry { | 87 | pub struct ScopeEntry { |
87 | syntax: SyntaxNode, | 88 | syntax: SyntaxNode, |
88 | } | 89 | } |
@@ -251,7 +252,7 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { | |||
251 | } | 252 | } |
252 | } | 253 | } |
253 | 254 | ||
254 | #[derive(Debug)] | 255 | #[derive(Debug, PartialEq, Eq)] |
255 | struct ScopeData { | 256 | struct ScopeData { |
256 | parent: Option<ScopeId>, | 257 | parent: Option<ScopeId>, |
257 | entries: Vec<ScopeEntry>, | 258 | entries: Vec<ScopeEntry>, |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 9ba775e1c..d0cd060d3 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -15,7 +15,7 @@ use crate::{ | |||
15 | pub struct ArgListNode(SyntaxNode); | 15 | pub struct ArgListNode(SyntaxNode); |
16 | 16 | ||
17 | impl ArgListNode { | 17 | impl ArgListNode { |
18 | pub fn new(&self, ast: ArgList) -> ArgListNode { | 18 | pub fn new(ast: ArgList) -> ArgListNode { |
19 | let syntax = ast.syntax().owned(); | 19 | let syntax = ast.syntax().owned(); |
20 | ArgListNode(syntax) | 20 | ArgListNode(syntax) |
21 | } | 21 | } |
@@ -50,7 +50,7 @@ impl<'a> ArgList<'a> { | |||
50 | pub struct ArrayExprNode(SyntaxNode); | 50 | pub struct ArrayExprNode(SyntaxNode); |
51 | 51 | ||
52 | impl ArrayExprNode { | 52 | impl ArrayExprNode { |
53 | pub fn new(&self, ast: ArrayExpr) -> ArrayExprNode { | 53 | pub fn new(ast: ArrayExpr) -> ArrayExprNode { |
54 | let syntax = ast.syntax().owned(); | 54 | let syntax = ast.syntax().owned(); |
55 | ArrayExprNode(syntax) | 55 | ArrayExprNode(syntax) |
56 | } | 56 | } |
@@ -81,7 +81,7 @@ impl<'a> ArrayExpr<'a> {} | |||
81 | pub struct ArrayTypeNode(SyntaxNode); | 81 | pub struct ArrayTypeNode(SyntaxNode); |
82 | 82 | ||
83 | impl ArrayTypeNode { | 83 | impl ArrayTypeNode { |
84 | pub fn new(&self, ast: ArrayType) -> ArrayTypeNode { | 84 | pub fn new(ast: ArrayType) -> ArrayTypeNode { |
85 | let syntax = ast.syntax().owned(); | 85 | let syntax = ast.syntax().owned(); |
86 | ArrayTypeNode(syntax) | 86 | ArrayTypeNode(syntax) |
87 | } | 87 | } |
@@ -112,7 +112,7 @@ impl<'a> ArrayType<'a> {} | |||
112 | pub struct AttrNode(SyntaxNode); | 112 | pub struct AttrNode(SyntaxNode); |
113 | 113 | ||
114 | impl AttrNode { | 114 | impl AttrNode { |
115 | pub fn new(&self, ast: Attr) -> AttrNode { | 115 | pub fn new(ast: Attr) -> AttrNode { |
116 | let syntax = ast.syntax().owned(); | 116 | let syntax = ast.syntax().owned(); |
117 | AttrNode(syntax) | 117 | AttrNode(syntax) |
118 | } | 118 | } |
@@ -147,7 +147,7 @@ impl<'a> Attr<'a> { | |||
147 | pub struct BinExprNode(SyntaxNode); | 147 | pub struct BinExprNode(SyntaxNode); |
148 | 148 | ||
149 | impl BinExprNode { | 149 | impl BinExprNode { |
150 | pub fn new(&self, ast: BinExpr) -> BinExprNode { | 150 | pub fn new(ast: BinExpr) -> BinExprNode { |
151 | let syntax = ast.syntax().owned(); | 151 | let syntax = ast.syntax().owned(); |
152 | BinExprNode(syntax) | 152 | BinExprNode(syntax) |
153 | } | 153 | } |
@@ -178,7 +178,7 @@ impl<'a> BinExpr<'a> {} | |||
178 | pub struct BindPatNode(SyntaxNode); | 178 | pub struct BindPatNode(SyntaxNode); |
179 | 179 | ||
180 | impl BindPatNode { | 180 | impl BindPatNode { |
181 | pub fn new(&self, ast: BindPat) -> BindPatNode { | 181 | pub fn new(ast: BindPat) -> BindPatNode { |
182 | let syntax = ast.syntax().owned(); | 182 | let syntax = ast.syntax().owned(); |
183 | BindPatNode(syntax) | 183 | BindPatNode(syntax) |
184 | } | 184 | } |
@@ -210,7 +210,7 @@ impl<'a> BindPat<'a> {} | |||
210 | pub struct BlockNode(SyntaxNode); | 210 | pub struct BlockNode(SyntaxNode); |
211 | 211 | ||
212 | impl BlockNode { | 212 | impl BlockNode { |
213 | pub fn new(&self, ast: Block) -> BlockNode { | 213 | pub fn new(ast: Block) -> BlockNode { |
214 | let syntax = ast.syntax().owned(); | 214 | let syntax = ast.syntax().owned(); |
215 | BlockNode(syntax) | 215 | BlockNode(syntax) |
216 | } | 216 | } |
@@ -249,7 +249,7 @@ impl<'a> Block<'a> { | |||
249 | pub struct BlockExprNode(SyntaxNode); | 249 | pub struct BlockExprNode(SyntaxNode); |
250 | 250 | ||
251 | impl BlockExprNode { | 251 | impl BlockExprNode { |
252 | pub fn new(&self, ast: BlockExpr) -> BlockExprNode { | 252 | pub fn new(ast: BlockExpr) -> BlockExprNode { |
253 | let syntax = ast.syntax().owned(); | 253 | let syntax = ast.syntax().owned(); |
254 | BlockExprNode(syntax) | 254 | BlockExprNode(syntax) |
255 | } | 255 | } |
@@ -284,7 +284,7 @@ impl<'a> BlockExpr<'a> { | |||
284 | pub struct BreakExprNode(SyntaxNode); | 284 | pub struct BreakExprNode(SyntaxNode); |
285 | 285 | ||
286 | impl BreakExprNode { | 286 | impl BreakExprNode { |
287 | pub fn new(&self, ast: BreakExpr) -> BreakExprNode { | 287 | pub fn new(ast: BreakExpr) -> BreakExprNode { |
288 | let syntax = ast.syntax().owned(); | 288 | let syntax = ast.syntax().owned(); |
289 | BreakExprNode(syntax) | 289 | BreakExprNode(syntax) |
290 | } | 290 | } |
@@ -315,7 +315,7 @@ impl<'a> BreakExpr<'a> {} | |||
315 | pub struct CallExprNode(SyntaxNode); | 315 | pub struct CallExprNode(SyntaxNode); |
316 | 316 | ||
317 | impl CallExprNode { | 317 | impl CallExprNode { |
318 | pub fn new(&self, ast: CallExpr) -> CallExprNode { | 318 | pub fn new(ast: CallExpr) -> CallExprNode { |
319 | let syntax = ast.syntax().owned(); | 319 | let syntax = ast.syntax().owned(); |
320 | CallExprNode(syntax) | 320 | CallExprNode(syntax) |
321 | } | 321 | } |
@@ -351,7 +351,7 @@ impl<'a> CallExpr<'a> { | |||
351 | pub struct CastExprNode(SyntaxNode); | 351 | pub struct CastExprNode(SyntaxNode); |
352 | 352 | ||
353 | impl CastExprNode { | 353 | impl CastExprNode { |
354 | pub fn new(&self, ast: CastExpr) -> CastExprNode { | 354 | pub fn new(ast: CastExpr) -> CastExprNode { |
355 | let syntax = ast.syntax().owned(); | 355 | let syntax = ast.syntax().owned(); |
356 | CastExprNode(syntax) | 356 | CastExprNode(syntax) |
357 | } | 357 | } |
@@ -382,7 +382,7 @@ impl<'a> CastExpr<'a> {} | |||
382 | pub struct CommentNode(SyntaxNode); | 382 | pub struct CommentNode(SyntaxNode); |
383 | 383 | ||
384 | impl CommentNode { | 384 | impl CommentNode { |
385 | pub fn new(&self, ast: Comment) -> CommentNode { | 385 | pub fn new(ast: Comment) -> CommentNode { |
386 | let syntax = ast.syntax().owned(); | 386 | let syntax = ast.syntax().owned(); |
387 | CommentNode(syntax) | 387 | CommentNode(syntax) |
388 | } | 388 | } |
@@ -413,7 +413,7 @@ impl<'a> Comment<'a> {} | |||
413 | pub struct ConditionNode(SyntaxNode); | 413 | pub struct ConditionNode(SyntaxNode); |
414 | 414 | ||
415 | impl ConditionNode { | 415 | impl ConditionNode { |
416 | pub fn new(&self, ast: Condition) -> ConditionNode { | 416 | pub fn new(ast: Condition) -> ConditionNode { |
417 | let syntax = ast.syntax().owned(); | 417 | let syntax = ast.syntax().owned(); |
418 | ConditionNode(syntax) | 418 | ConditionNode(syntax) |
419 | } | 419 | } |
@@ -452,7 +452,7 @@ impl<'a> Condition<'a> { | |||
452 | pub struct ConstDefNode(SyntaxNode); | 452 | pub struct ConstDefNode(SyntaxNode); |
453 | 453 | ||
454 | impl ConstDefNode { | 454 | impl ConstDefNode { |
455 | pub fn new(&self, ast: ConstDef) -> ConstDefNode { | 455 | pub fn new(ast: ConstDef) -> ConstDefNode { |
456 | let syntax = ast.syntax().owned(); | 456 | let syntax = ast.syntax().owned(); |
457 | ConstDefNode(syntax) | 457 | ConstDefNode(syntax) |
458 | } | 458 | } |
@@ -486,7 +486,7 @@ impl<'a> ConstDef<'a> {} | |||
486 | pub struct ContinueExprNode(SyntaxNode); | 486 | pub struct ContinueExprNode(SyntaxNode); |
487 | 487 | ||
488 | impl ContinueExprNode { | 488 | impl ContinueExprNode { |
489 | pub fn new(&self, ast: ContinueExpr) -> ContinueExprNode { | 489 | pub fn new(ast: ContinueExpr) -> ContinueExprNode { |
490 | let syntax = ast.syntax().owned(); | 490 | let syntax = ast.syntax().owned(); |
491 | ContinueExprNode(syntax) | 491 | ContinueExprNode(syntax) |
492 | } | 492 | } |
@@ -517,7 +517,7 @@ impl<'a> ContinueExpr<'a> {} | |||
517 | pub struct DynTraitTypeNode(SyntaxNode); | 517 | pub struct DynTraitTypeNode(SyntaxNode); |
518 | 518 | ||
519 | impl DynTraitTypeNode { | 519 | impl DynTraitTypeNode { |
520 | pub fn new(&self, ast: DynTraitType) -> DynTraitTypeNode { | 520 | pub fn new(ast: DynTraitType) -> DynTraitTypeNode { |
521 | let syntax = ast.syntax().owned(); | 521 | let syntax = ast.syntax().owned(); |
522 | DynTraitTypeNode(syntax) | 522 | DynTraitTypeNode(syntax) |
523 | } | 523 | } |
@@ -548,7 +548,7 @@ impl<'a> DynTraitType<'a> {} | |||
548 | pub struct EnumDefNode(SyntaxNode); | 548 | pub struct EnumDefNode(SyntaxNode); |
549 | 549 | ||
550 | impl EnumDefNode { | 550 | impl EnumDefNode { |
551 | pub fn new(&self, ast: EnumDef) -> EnumDefNode { | 551 | pub fn new(ast: EnumDef) -> EnumDefNode { |
552 | let syntax = ast.syntax().owned(); | 552 | let syntax = ast.syntax().owned(); |
553 | EnumDefNode(syntax) | 553 | EnumDefNode(syntax) |
554 | } | 554 | } |
@@ -582,7 +582,7 @@ impl<'a> EnumDef<'a> {} | |||
582 | pub struct ExprNode(SyntaxNode); | 582 | pub struct ExprNode(SyntaxNode); |
583 | 583 | ||
584 | impl ExprNode { | 584 | impl ExprNode { |
585 | pub fn new(&self, ast: Expr) -> ExprNode { | 585 | pub fn new(ast: Expr) -> ExprNode { |
586 | let syntax = ast.syntax().owned(); | 586 | let syntax = ast.syntax().owned(); |
587 | ExprNode(syntax) | 587 | ExprNode(syntax) |
588 | } | 588 | } |
@@ -710,7 +710,7 @@ impl<'a> Expr<'a> {} | |||
710 | pub struct ExprStmtNode(SyntaxNode); | 710 | pub struct ExprStmtNode(SyntaxNode); |
711 | 711 | ||
712 | impl ExprStmtNode { | 712 | impl ExprStmtNode { |
713 | pub fn new(&self, ast: ExprStmt) -> ExprStmtNode { | 713 | pub fn new(ast: ExprStmt) -> ExprStmtNode { |
714 | let syntax = ast.syntax().owned(); | 714 | let syntax = ast.syntax().owned(); |
715 | ExprStmtNode(syntax) | 715 | ExprStmtNode(syntax) |
716 | } | 716 | } |
@@ -745,7 +745,7 @@ impl<'a> ExprStmt<'a> { | |||
745 | pub struct ExternCrateItemNode(SyntaxNode); | 745 | pub struct ExternCrateItemNode(SyntaxNode); |
746 | 746 | ||
747 | impl ExternCrateItemNode { | 747 | impl ExternCrateItemNode { |
748 | pub fn new(&self, ast: ExternCrateItem) -> ExternCrateItemNode { | 748 | pub fn new(ast: ExternCrateItem) -> ExternCrateItemNode { |
749 | let syntax = ast.syntax().owned(); | 749 | let syntax = ast.syntax().owned(); |
750 | ExternCrateItemNode(syntax) | 750 | ExternCrateItemNode(syntax) |
751 | } | 751 | } |
@@ -776,7 +776,7 @@ impl<'a> ExternCrateItem<'a> {} | |||
776 | pub struct FieldExprNode(SyntaxNode); | 776 | pub struct FieldExprNode(SyntaxNode); |
777 | 777 | ||
778 | impl FieldExprNode { | 778 | impl FieldExprNode { |
779 | pub fn new(&self, ast: FieldExpr) -> FieldExprNode { | 779 | pub fn new(ast: FieldExpr) -> FieldExprNode { |
780 | let syntax = ast.syntax().owned(); | 780 | let syntax = ast.syntax().owned(); |
781 | FieldExprNode(syntax) | 781 | FieldExprNode(syntax) |
782 | } | 782 | } |
@@ -807,7 +807,7 @@ impl<'a> FieldExpr<'a> {} | |||
807 | pub struct FieldPatListNode(SyntaxNode); | 807 | pub struct FieldPatListNode(SyntaxNode); |
808 | 808 | ||
809 | impl FieldPatListNode { | 809 | impl FieldPatListNode { |
810 | pub fn new(&self, ast: FieldPatList) -> FieldPatListNode { | 810 | pub fn new(ast: FieldPatList) -> FieldPatListNode { |
811 | let syntax = ast.syntax().owned(); | 811 | let syntax = ast.syntax().owned(); |
812 | FieldPatListNode(syntax) | 812 | FieldPatListNode(syntax) |
813 | } | 813 | } |
@@ -838,7 +838,7 @@ impl<'a> FieldPatList<'a> {} | |||
838 | pub struct FnDefNode(SyntaxNode); | 838 | pub struct FnDefNode(SyntaxNode); |
839 | 839 | ||
840 | impl FnDefNode { | 840 | impl FnDefNode { |
841 | pub fn new(&self, ast: FnDef) -> FnDefNode { | 841 | pub fn new(ast: FnDef) -> FnDefNode { |
842 | let syntax = ast.syntax().owned(); | 842 | let syntax = ast.syntax().owned(); |
843 | FnDefNode(syntax) | 843 | FnDefNode(syntax) |
844 | } | 844 | } |
@@ -884,7 +884,7 @@ impl<'a> FnDef<'a> { | |||
884 | pub struct FnPointerTypeNode(SyntaxNode); | 884 | pub struct FnPointerTypeNode(SyntaxNode); |
885 | 885 | ||
886 | impl FnPointerTypeNode { | 886 | impl FnPointerTypeNode { |
887 | pub fn new(&self, ast: FnPointerType) -> FnPointerTypeNode { | 887 | pub fn new(ast: FnPointerType) -> FnPointerTypeNode { |
888 | let syntax = ast.syntax().owned(); | 888 | let syntax = ast.syntax().owned(); |
889 | FnPointerTypeNode(syntax) | 889 | FnPointerTypeNode(syntax) |
890 | } | 890 | } |
@@ -915,7 +915,7 @@ impl<'a> FnPointerType<'a> {} | |||
915 | pub struct ForExprNode(SyntaxNode); | 915 | pub struct ForExprNode(SyntaxNode); |
916 | 916 | ||
917 | impl ForExprNode { | 917 | impl ForExprNode { |
918 | pub fn new(&self, ast: ForExpr) -> ForExprNode { | 918 | pub fn new(ast: ForExpr) -> ForExprNode { |
919 | let syntax = ast.syntax().owned(); | 919 | let syntax = ast.syntax().owned(); |
920 | ForExprNode(syntax) | 920 | ForExprNode(syntax) |
921 | } | 921 | } |
@@ -955,7 +955,7 @@ impl<'a> ForExpr<'a> { | |||
955 | pub struct ForTypeNode(SyntaxNode); | 955 | pub struct ForTypeNode(SyntaxNode); |
956 | 956 | ||
957 | impl ForTypeNode { | 957 | impl ForTypeNode { |
958 | pub fn new(&self, ast: ForType) -> ForTypeNode { | 958 | pub fn new(ast: ForType) -> ForTypeNode { |
959 | let syntax = ast.syntax().owned(); | 959 | let syntax = ast.syntax().owned(); |
960 | ForTypeNode(syntax) | 960 | ForTypeNode(syntax) |
961 | } | 961 | } |
@@ -986,7 +986,7 @@ impl<'a> ForType<'a> {} | |||
986 | pub struct IfExprNode(SyntaxNode); | 986 | pub struct IfExprNode(SyntaxNode); |
987 | 987 | ||
988 | impl IfExprNode { | 988 | impl IfExprNode { |
989 | pub fn new(&self, ast: IfExpr) -> IfExprNode { | 989 | pub fn new(ast: IfExpr) -> IfExprNode { |
990 | let syntax = ast.syntax().owned(); | 990 | let syntax = ast.syntax().owned(); |
991 | IfExprNode(syntax) | 991 | IfExprNode(syntax) |
992 | } | 992 | } |
@@ -1021,7 +1021,7 @@ impl<'a> IfExpr<'a> { | |||
1021 | pub struct ImplItemNode(SyntaxNode); | 1021 | pub struct ImplItemNode(SyntaxNode); |
1022 | 1022 | ||
1023 | impl ImplItemNode { | 1023 | impl ImplItemNode { |
1024 | pub fn new(&self, ast: ImplItem) -> ImplItemNode { | 1024 | pub fn new(ast: ImplItem) -> ImplItemNode { |
1025 | let syntax = ast.syntax().owned(); | 1025 | let syntax = ast.syntax().owned(); |
1026 | ImplItemNode(syntax) | 1026 | ImplItemNode(syntax) |
1027 | } | 1027 | } |
@@ -1052,7 +1052,7 @@ impl<'a> ImplItem<'a> {} | |||
1052 | pub struct ImplTraitTypeNode(SyntaxNode); | 1052 | pub struct ImplTraitTypeNode(SyntaxNode); |
1053 | 1053 | ||
1054 | impl ImplTraitTypeNode { | 1054 | impl ImplTraitTypeNode { |
1055 | pub fn new(&self, ast: ImplTraitType) -> ImplTraitTypeNode { | 1055 | pub fn new(ast: ImplTraitType) -> ImplTraitTypeNode { |
1056 | let syntax = ast.syntax().owned(); | 1056 | let syntax = ast.syntax().owned(); |
1057 | ImplTraitTypeNode(syntax) | 1057 | ImplTraitTypeNode(syntax) |
1058 | } | 1058 | } |
@@ -1083,7 +1083,7 @@ impl<'a> ImplTraitType<'a> {} | |||
1083 | pub struct IndexExprNode(SyntaxNode); | 1083 | pub struct IndexExprNode(SyntaxNode); |
1084 | 1084 | ||
1085 | impl IndexExprNode { | 1085 | impl IndexExprNode { |
1086 | pub fn new(&self, ast: IndexExpr) -> IndexExprNode { | 1086 | pub fn new(ast: IndexExpr) -> IndexExprNode { |
1087 | let syntax = ast.syntax().owned(); | 1087 | let syntax = ast.syntax().owned(); |
1088 | IndexExprNode(syntax) | 1088 | IndexExprNode(syntax) |
1089 | } | 1089 | } |
@@ -1114,7 +1114,7 @@ impl<'a> IndexExpr<'a> {} | |||
1114 | pub struct ItemListNode(SyntaxNode); | 1114 | pub struct ItemListNode(SyntaxNode); |
1115 | 1115 | ||
1116 | impl ItemListNode { | 1116 | impl ItemListNode { |
1117 | pub fn new(&self, ast: ItemList) -> ItemListNode { | 1117 | pub fn new(ast: ItemList) -> ItemListNode { |
1118 | let syntax = ast.syntax().owned(); | 1118 | let syntax = ast.syntax().owned(); |
1119 | ItemListNode(syntax) | 1119 | ItemListNode(syntax) |
1120 | } | 1120 | } |
@@ -1147,7 +1147,7 @@ impl<'a> ItemList<'a> {} | |||
1147 | pub struct LabelNode(SyntaxNode); | 1147 | pub struct LabelNode(SyntaxNode); |
1148 | 1148 | ||
1149 | impl LabelNode { | 1149 | impl LabelNode { |
1150 | pub fn new(&self, ast: Label) -> LabelNode { | 1150 | pub fn new(ast: Label) -> LabelNode { |
1151 | let syntax = ast.syntax().owned(); | 1151 | let syntax = ast.syntax().owned(); |
1152 | LabelNode(syntax) | 1152 | LabelNode(syntax) |
1153 | } | 1153 | } |
@@ -1178,7 +1178,7 @@ impl<'a> Label<'a> {} | |||
1178 | pub struct LambdaExprNode(SyntaxNode); | 1178 | pub struct LambdaExprNode(SyntaxNode); |
1179 | 1179 | ||
1180 | impl LambdaExprNode { | 1180 | impl LambdaExprNode { |
1181 | pub fn new(&self, ast: LambdaExpr) -> LambdaExprNode { | 1181 | pub fn new(ast: LambdaExpr) -> LambdaExprNode { |
1182 | let syntax = ast.syntax().owned(); | 1182 | let syntax = ast.syntax().owned(); |
1183 | LambdaExprNode(syntax) | 1183 | LambdaExprNode(syntax) |
1184 | } | 1184 | } |
@@ -1217,7 +1217,7 @@ impl<'a> LambdaExpr<'a> { | |||
1217 | pub struct LetStmtNode(SyntaxNode); | 1217 | pub struct LetStmtNode(SyntaxNode); |
1218 | 1218 | ||
1219 | impl LetStmtNode { | 1219 | impl LetStmtNode { |
1220 | pub fn new(&self, ast: LetStmt) -> LetStmtNode { | 1220 | pub fn new(ast: LetStmt) -> LetStmtNode { |
1221 | let syntax = ast.syntax().owned(); | 1221 | let syntax = ast.syntax().owned(); |
1222 | LetStmtNode(syntax) | 1222 | LetStmtNode(syntax) |
1223 | } | 1223 | } |
@@ -1256,7 +1256,7 @@ impl<'a> LetStmt<'a> { | |||
1256 | pub struct LifetimeNode(SyntaxNode); | 1256 | pub struct LifetimeNode(SyntaxNode); |
1257 | 1257 | ||
1258 | impl LifetimeNode { | 1258 | impl LifetimeNode { |
1259 | pub fn new(&self, ast: Lifetime) -> LifetimeNode { | 1259 | pub fn new(ast: Lifetime) -> LifetimeNode { |
1260 | let syntax = ast.syntax().owned(); | 1260 | let syntax = ast.syntax().owned(); |
1261 | LifetimeNode(syntax) | 1261 | LifetimeNode(syntax) |
1262 | } | 1262 | } |
@@ -1287,7 +1287,7 @@ impl<'a> Lifetime<'a> {} | |||
1287 | pub struct LifetimeParamNode(SyntaxNode); | 1287 | pub struct LifetimeParamNode(SyntaxNode); |
1288 | 1288 | ||
1289 | impl LifetimeParamNode { | 1289 | impl LifetimeParamNode { |
1290 | pub fn new(&self, ast: LifetimeParam) -> LifetimeParamNode { | 1290 | pub fn new(ast: LifetimeParam) -> LifetimeParamNode { |
1291 | let syntax = ast.syntax().owned(); | 1291 | let syntax = ast.syntax().owned(); |
1292 | LifetimeParamNode(syntax) | 1292 | LifetimeParamNode(syntax) |
1293 | } | 1293 | } |
@@ -1322,7 +1322,7 @@ impl<'a> LifetimeParam<'a> { | |||
1322 | pub struct LiteralNode(SyntaxNode); | 1322 | pub struct LiteralNode(SyntaxNode); |
1323 | 1323 | ||
1324 | impl LiteralNode { | 1324 | impl LiteralNode { |
1325 | pub fn new(&self, ast: Literal) -> LiteralNode { | 1325 | pub fn new(ast: Literal) -> LiteralNode { |
1326 | let syntax = ast.syntax().owned(); | 1326 | let syntax = ast.syntax().owned(); |
1327 | LiteralNode(syntax) | 1327 | LiteralNode(syntax) |
1328 | } | 1328 | } |
@@ -1353,7 +1353,7 @@ impl<'a> Literal<'a> {} | |||
1353 | pub struct LoopExprNode(SyntaxNode); | 1353 | pub struct LoopExprNode(SyntaxNode); |
1354 | 1354 | ||
1355 | impl LoopExprNode { | 1355 | impl LoopExprNode { |
1356 | pub fn new(&self, ast: LoopExpr) -> LoopExprNode { | 1356 | pub fn new(ast: LoopExpr) -> LoopExprNode { |
1357 | let syntax = ast.syntax().owned(); | 1357 | let syntax = ast.syntax().owned(); |
1358 | LoopExprNode(syntax) | 1358 | LoopExprNode(syntax) |
1359 | } | 1359 | } |
@@ -1385,7 +1385,7 @@ impl<'a> LoopExpr<'a> {} | |||
1385 | pub struct MatchArmNode(SyntaxNode); | 1385 | pub struct MatchArmNode(SyntaxNode); |
1386 | 1386 | ||
1387 | impl MatchArmNode { | 1387 | impl MatchArmNode { |
1388 | pub fn new(&self, ast: MatchArm) -> MatchArmNode { | 1388 | pub fn new(ast: MatchArm) -> MatchArmNode { |
1389 | let syntax = ast.syntax().owned(); | 1389 | let syntax = ast.syntax().owned(); |
1390 | MatchArmNode(syntax) | 1390 | MatchArmNode(syntax) |
1391 | } | 1391 | } |
@@ -1428,7 +1428,7 @@ impl<'a> MatchArm<'a> { | |||
1428 | pub struct MatchArmListNode(SyntaxNode); | 1428 | pub struct MatchArmListNode(SyntaxNode); |
1429 | 1429 | ||
1430 | impl MatchArmListNode { | 1430 | impl MatchArmListNode { |
1431 | pub fn new(&self, ast: MatchArmList) -> MatchArmListNode { | 1431 | pub fn new(ast: MatchArmList) -> MatchArmListNode { |
1432 | let syntax = ast.syntax().owned(); | 1432 | let syntax = ast.syntax().owned(); |
1433 | MatchArmListNode(syntax) | 1433 | MatchArmListNode(syntax) |
1434 | } | 1434 | } |
@@ -1463,7 +1463,7 @@ impl<'a> MatchArmList<'a> { | |||
1463 | pub struct MatchExprNode(SyntaxNode); | 1463 | pub struct MatchExprNode(SyntaxNode); |
1464 | 1464 | ||
1465 | impl MatchExprNode { | 1465 | impl MatchExprNode { |
1466 | pub fn new(&self, ast: MatchExpr) -> MatchExprNode { | 1466 | pub fn new(ast: MatchExpr) -> MatchExprNode { |
1467 | let syntax = ast.syntax().owned(); | 1467 | let syntax = ast.syntax().owned(); |
1468 | MatchExprNode(syntax) | 1468 | MatchExprNode(syntax) |
1469 | } | 1469 | } |
@@ -1502,7 +1502,7 @@ impl<'a> MatchExpr<'a> { | |||
1502 | pub struct MatchGuardNode(SyntaxNode); | 1502 | pub struct MatchGuardNode(SyntaxNode); |
1503 | 1503 | ||
1504 | impl MatchGuardNode { | 1504 | impl MatchGuardNode { |
1505 | pub fn new(&self, ast: MatchGuard) -> MatchGuardNode { | 1505 | pub fn new(ast: MatchGuard) -> MatchGuardNode { |
1506 | let syntax = ast.syntax().owned(); | 1506 | let syntax = ast.syntax().owned(); |
1507 | MatchGuardNode(syntax) | 1507 | MatchGuardNode(syntax) |
1508 | } | 1508 | } |
@@ -1533,7 +1533,7 @@ impl<'a> MatchGuard<'a> {} | |||
1533 | pub struct MethodCallExprNode(SyntaxNode); | 1533 | pub struct MethodCallExprNode(SyntaxNode); |
1534 | 1534 | ||
1535 | impl MethodCallExprNode { | 1535 | impl MethodCallExprNode { |
1536 | pub fn new(&self, ast: MethodCallExpr) -> MethodCallExprNode { | 1536 | pub fn new(ast: MethodCallExpr) -> MethodCallExprNode { |
1537 | let syntax = ast.syntax().owned(); | 1537 | let syntax = ast.syntax().owned(); |
1538 | MethodCallExprNode(syntax) | 1538 | MethodCallExprNode(syntax) |
1539 | } | 1539 | } |
@@ -1569,7 +1569,7 @@ impl<'a> MethodCallExpr<'a> { | |||
1569 | pub struct ModuleNode(SyntaxNode); | 1569 | pub struct ModuleNode(SyntaxNode); |
1570 | 1570 | ||
1571 | impl ModuleNode { | 1571 | impl ModuleNode { |
1572 | pub fn new(&self, ast: Module) -> ModuleNode { | 1572 | pub fn new(ast: Module) -> ModuleNode { |
1573 | let syntax = ast.syntax().owned(); | 1573 | let syntax = ast.syntax().owned(); |
1574 | ModuleNode(syntax) | 1574 | ModuleNode(syntax) |
1575 | } | 1575 | } |
@@ -1606,7 +1606,7 @@ impl<'a> Module<'a> { | |||
1606 | pub struct ModuleItemNode(SyntaxNode); | 1606 | pub struct ModuleItemNode(SyntaxNode); |
1607 | 1607 | ||
1608 | impl ModuleItemNode { | 1608 | impl ModuleItemNode { |
1609 | pub fn new(&self, ast: ModuleItem) -> ModuleItemNode { | 1609 | pub fn new(ast: ModuleItem) -> ModuleItemNode { |
1610 | let syntax = ast.syntax().owned(); | 1610 | let syntax = ast.syntax().owned(); |
1611 | ModuleItemNode(syntax) | 1611 | ModuleItemNode(syntax) |
1612 | } | 1612 | } |
@@ -1671,7 +1671,7 @@ impl<'a> ModuleItem<'a> {} | |||
1671 | pub struct NameNode(SyntaxNode); | 1671 | pub struct NameNode(SyntaxNode); |
1672 | 1672 | ||
1673 | impl NameNode { | 1673 | impl NameNode { |
1674 | pub fn new(&self, ast: Name) -> NameNode { | 1674 | pub fn new(ast: Name) -> NameNode { |
1675 | let syntax = ast.syntax().owned(); | 1675 | let syntax = ast.syntax().owned(); |
1676 | NameNode(syntax) | 1676 | NameNode(syntax) |
1677 | } | 1677 | } |
@@ -1702,7 +1702,7 @@ impl<'a> Name<'a> {} | |||
1702 | pub struct NameRefNode(SyntaxNode); | 1702 | pub struct NameRefNode(SyntaxNode); |
1703 | 1703 | ||
1704 | impl NameRefNode { | 1704 | impl NameRefNode { |
1705 | pub fn new(&self, ast: NameRef) -> NameRefNode { | 1705 | pub fn new(ast: NameRef) -> NameRefNode { |
1706 | let syntax = ast.syntax().owned(); | 1706 | let syntax = ast.syntax().owned(); |
1707 | NameRefNode(syntax) | 1707 | NameRefNode(syntax) |
1708 | } | 1708 | } |
@@ -1733,7 +1733,7 @@ impl<'a> NameRef<'a> {} | |||
1733 | pub struct NamedFieldNode(SyntaxNode); | 1733 | pub struct NamedFieldNode(SyntaxNode); |
1734 | 1734 | ||
1735 | impl NamedFieldNode { | 1735 | impl NamedFieldNode { |
1736 | pub fn new(&self, ast: NamedField) -> NamedFieldNode { | 1736 | pub fn new(ast: NamedField) -> NamedFieldNode { |
1737 | let syntax = ast.syntax().owned(); | 1737 | let syntax = ast.syntax().owned(); |
1738 | NamedFieldNode(syntax) | 1738 | NamedFieldNode(syntax) |
1739 | } | 1739 | } |
@@ -1764,7 +1764,7 @@ impl<'a> NamedField<'a> {} | |||
1764 | pub struct NamedFieldDefNode(SyntaxNode); | 1764 | pub struct NamedFieldDefNode(SyntaxNode); |
1765 | 1765 | ||
1766 | impl NamedFieldDefNode { | 1766 | impl NamedFieldDefNode { |
1767 | pub fn new(&self, ast: NamedFieldDef) -> NamedFieldDefNode { | 1767 | pub fn new(ast: NamedFieldDef) -> NamedFieldDefNode { |
1768 | let syntax = ast.syntax().owned(); | 1768 | let syntax = ast.syntax().owned(); |
1769 | NamedFieldDefNode(syntax) | 1769 | NamedFieldDefNode(syntax) |
1770 | } | 1770 | } |
@@ -1797,7 +1797,7 @@ impl<'a> NamedFieldDef<'a> {} | |||
1797 | pub struct NamedFieldListNode(SyntaxNode); | 1797 | pub struct NamedFieldListNode(SyntaxNode); |
1798 | 1798 | ||
1799 | impl NamedFieldListNode { | 1799 | impl NamedFieldListNode { |
1800 | pub fn new(&self, ast: NamedFieldList) -> NamedFieldListNode { | 1800 | pub fn new(ast: NamedFieldList) -> NamedFieldListNode { |
1801 | let syntax = ast.syntax().owned(); | 1801 | let syntax = ast.syntax().owned(); |
1802 | NamedFieldListNode(syntax) | 1802 | NamedFieldListNode(syntax) |
1803 | } | 1803 | } |
@@ -1828,7 +1828,7 @@ impl<'a> NamedFieldList<'a> {} | |||
1828 | pub struct NeverTypeNode(SyntaxNode); | 1828 | pub struct NeverTypeNode(SyntaxNode); |
1829 | 1829 | ||
1830 | impl NeverTypeNode { | 1830 | impl NeverTypeNode { |
1831 | pub fn new(&self, ast: NeverType) -> NeverTypeNode { | 1831 | pub fn new(ast: NeverType) -> NeverTypeNode { |
1832 | let syntax = ast.syntax().owned(); | 1832 | let syntax = ast.syntax().owned(); |
1833 | NeverTypeNode(syntax) | 1833 | NeverTypeNode(syntax) |
1834 | } | 1834 | } |
@@ -1859,7 +1859,7 @@ impl<'a> NeverType<'a> {} | |||
1859 | pub struct NominalDefNode(SyntaxNode); | 1859 | pub struct NominalDefNode(SyntaxNode); |
1860 | 1860 | ||
1861 | impl NominalDefNode { | 1861 | impl NominalDefNode { |
1862 | pub fn new(&self, ast: NominalDef) -> NominalDefNode { | 1862 | pub fn new(ast: NominalDef) -> NominalDefNode { |
1863 | let syntax = ast.syntax().owned(); | 1863 | let syntax = ast.syntax().owned(); |
1864 | NominalDefNode(syntax) | 1864 | NominalDefNode(syntax) |
1865 | } | 1865 | } |
@@ -1900,7 +1900,7 @@ impl<'a> NominalDef<'a> {} | |||
1900 | pub struct ParamNode(SyntaxNode); | 1900 | pub struct ParamNode(SyntaxNode); |
1901 | 1901 | ||
1902 | impl ParamNode { | 1902 | impl ParamNode { |
1903 | pub fn new(&self, ast: Param) -> ParamNode { | 1903 | pub fn new(ast: Param) -> ParamNode { |
1904 | let syntax = ast.syntax().owned(); | 1904 | let syntax = ast.syntax().owned(); |
1905 | ParamNode(syntax) | 1905 | ParamNode(syntax) |
1906 | } | 1906 | } |
@@ -1935,7 +1935,7 @@ impl<'a> Param<'a> { | |||
1935 | pub struct ParamListNode(SyntaxNode); | 1935 | pub struct ParamListNode(SyntaxNode); |
1936 | 1936 | ||
1937 | impl ParamListNode { | 1937 | impl ParamListNode { |
1938 | pub fn new(&self, ast: ParamList) -> ParamListNode { | 1938 | pub fn new(ast: ParamList) -> ParamListNode { |
1939 | let syntax = ast.syntax().owned(); | 1939 | let syntax = ast.syntax().owned(); |
1940 | ParamListNode(syntax) | 1940 | ParamListNode(syntax) |
1941 | } | 1941 | } |
@@ -1974,7 +1974,7 @@ impl<'a> ParamList<'a> { | |||
1974 | pub struct ParenExprNode(SyntaxNode); | 1974 | pub struct ParenExprNode(SyntaxNode); |
1975 | 1975 | ||
1976 | impl ParenExprNode { | 1976 | impl ParenExprNode { |
1977 | pub fn new(&self, ast: ParenExpr) -> ParenExprNode { | 1977 | pub fn new(ast: ParenExpr) -> ParenExprNode { |
1978 | let syntax = ast.syntax().owned(); | 1978 | let syntax = ast.syntax().owned(); |
1979 | ParenExprNode(syntax) | 1979 | ParenExprNode(syntax) |
1980 | } | 1980 | } |
@@ -2005,7 +2005,7 @@ impl<'a> ParenExpr<'a> {} | |||
2005 | pub struct ParenTypeNode(SyntaxNode); | 2005 | pub struct ParenTypeNode(SyntaxNode); |
2006 | 2006 | ||
2007 | impl ParenTypeNode { | 2007 | impl ParenTypeNode { |
2008 | pub fn new(&self, ast: ParenType) -> ParenTypeNode { | 2008 | pub fn new(ast: ParenType) -> ParenTypeNode { |
2009 | let syntax = ast.syntax().owned(); | 2009 | let syntax = ast.syntax().owned(); |
2010 | ParenTypeNode(syntax) | 2010 | ParenTypeNode(syntax) |
2011 | } | 2011 | } |
@@ -2036,7 +2036,7 @@ impl<'a> ParenType<'a> {} | |||
2036 | pub struct PatNode(SyntaxNode); | 2036 | pub struct PatNode(SyntaxNode); |
2037 | 2037 | ||
2038 | impl PatNode { | 2038 | impl PatNode { |
2039 | pub fn new(&self, ast: Pat) -> PatNode { | 2039 | pub fn new(ast: Pat) -> PatNode { |
2040 | let syntax = ast.syntax().owned(); | 2040 | let syntax = ast.syntax().owned(); |
2041 | PatNode(syntax) | 2041 | PatNode(syntax) |
2042 | } | 2042 | } |
@@ -2098,7 +2098,7 @@ impl<'a> Pat<'a> {} | |||
2098 | pub struct PathNode(SyntaxNode); | 2098 | pub struct PathNode(SyntaxNode); |
2099 | 2099 | ||
2100 | impl PathNode { | 2100 | impl PathNode { |
2101 | pub fn new(&self, ast: Path) -> PathNode { | 2101 | pub fn new(ast: Path) -> PathNode { |
2102 | let syntax = ast.syntax().owned(); | 2102 | let syntax = ast.syntax().owned(); |
2103 | PathNode(syntax) | 2103 | PathNode(syntax) |
2104 | } | 2104 | } |
@@ -2137,7 +2137,7 @@ impl<'a> Path<'a> { | |||
2137 | pub struct PathExprNode(SyntaxNode); | 2137 | pub struct PathExprNode(SyntaxNode); |
2138 | 2138 | ||
2139 | impl PathExprNode { | 2139 | impl PathExprNode { |
2140 | pub fn new(&self, ast: PathExpr) -> PathExprNode { | 2140 | pub fn new(ast: PathExpr) -> PathExprNode { |
2141 | let syntax = ast.syntax().owned(); | 2141 | let syntax = ast.syntax().owned(); |
2142 | PathExprNode(syntax) | 2142 | PathExprNode(syntax) |
2143 | } | 2143 | } |
@@ -2172,7 +2172,7 @@ impl<'a> PathExpr<'a> { | |||
2172 | pub struct PathPatNode(SyntaxNode); | 2172 | pub struct PathPatNode(SyntaxNode); |
2173 | 2173 | ||
2174 | impl PathPatNode { | 2174 | impl PathPatNode { |
2175 | pub fn new(&self, ast: PathPat) -> PathPatNode { | 2175 | pub fn new(ast: PathPat) -> PathPatNode { |
2176 | let syntax = ast.syntax().owned(); | 2176 | let syntax = ast.syntax().owned(); |
2177 | PathPatNode(syntax) | 2177 | PathPatNode(syntax) |
2178 | } | 2178 | } |
@@ -2203,7 +2203,7 @@ impl<'a> PathPat<'a> {} | |||
2203 | pub struct PathSegmentNode(SyntaxNode); | 2203 | pub struct PathSegmentNode(SyntaxNode); |
2204 | 2204 | ||
2205 | impl PathSegmentNode { | 2205 | impl PathSegmentNode { |
2206 | pub fn new(&self, ast: PathSegment) -> PathSegmentNode { | 2206 | pub fn new(ast: PathSegment) -> PathSegmentNode { |
2207 | let syntax = ast.syntax().owned(); | 2207 | let syntax = ast.syntax().owned(); |
2208 | PathSegmentNode(syntax) | 2208 | PathSegmentNode(syntax) |
2209 | } | 2209 | } |
@@ -2238,7 +2238,7 @@ impl<'a> PathSegment<'a> { | |||
2238 | pub struct PathTypeNode(SyntaxNode); | 2238 | pub struct PathTypeNode(SyntaxNode); |
2239 | 2239 | ||
2240 | impl PathTypeNode { | 2240 | impl PathTypeNode { |
2241 | pub fn new(&self, ast: PathType) -> PathTypeNode { | 2241 | pub fn new(ast: PathType) -> PathTypeNode { |
2242 | let syntax = ast.syntax().owned(); | 2242 | let syntax = ast.syntax().owned(); |
2243 | PathTypeNode(syntax) | 2243 | PathTypeNode(syntax) |
2244 | } | 2244 | } |
@@ -2269,7 +2269,7 @@ impl<'a> PathType<'a> {} | |||
2269 | pub struct PlaceholderPatNode(SyntaxNode); | 2269 | pub struct PlaceholderPatNode(SyntaxNode); |
2270 | 2270 | ||
2271 | impl PlaceholderPatNode { | 2271 | impl PlaceholderPatNode { |
2272 | pub fn new(&self, ast: PlaceholderPat) -> PlaceholderPatNode { | 2272 | pub fn new(ast: PlaceholderPat) -> PlaceholderPatNode { |
2273 | let syntax = ast.syntax().owned(); | 2273 | let syntax = ast.syntax().owned(); |
2274 | PlaceholderPatNode(syntax) | 2274 | PlaceholderPatNode(syntax) |
2275 | } | 2275 | } |
@@ -2300,7 +2300,7 @@ impl<'a> PlaceholderPat<'a> {} | |||
2300 | pub struct PlaceholderTypeNode(SyntaxNode); | 2300 | pub struct PlaceholderTypeNode(SyntaxNode); |
2301 | 2301 | ||
2302 | impl PlaceholderTypeNode { | 2302 | impl PlaceholderTypeNode { |
2303 | pub fn new(&self, ast: PlaceholderType) -> PlaceholderTypeNode { | 2303 | pub fn new(ast: PlaceholderType) -> PlaceholderTypeNode { |
2304 | let syntax = ast.syntax().owned(); | 2304 | let syntax = ast.syntax().owned(); |
2305 | PlaceholderTypeNode(syntax) | 2305 | PlaceholderTypeNode(syntax) |
2306 | } | 2306 | } |
@@ -2331,7 +2331,7 @@ impl<'a> PlaceholderType<'a> {} | |||
2331 | pub struct PointerTypeNode(SyntaxNode); | 2331 | pub struct PointerTypeNode(SyntaxNode); |
2332 | 2332 | ||
2333 | impl PointerTypeNode { | 2333 | impl PointerTypeNode { |
2334 | pub fn new(&self, ast: PointerType) -> PointerTypeNode { | 2334 | pub fn new(ast: PointerType) -> PointerTypeNode { |
2335 | let syntax = ast.syntax().owned(); | 2335 | let syntax = ast.syntax().owned(); |
2336 | PointerTypeNode(syntax) | 2336 | PointerTypeNode(syntax) |
2337 | } | 2337 | } |
@@ -2362,7 +2362,7 @@ impl<'a> PointerType<'a> {} | |||
2362 | pub struct PrefixExprNode(SyntaxNode); | 2362 | pub struct PrefixExprNode(SyntaxNode); |
2363 | 2363 | ||
2364 | impl PrefixExprNode { | 2364 | impl PrefixExprNode { |
2365 | pub fn new(&self, ast: PrefixExpr) -> PrefixExprNode { | 2365 | pub fn new(ast: PrefixExpr) -> PrefixExprNode { |
2366 | let syntax = ast.syntax().owned(); | 2366 | let syntax = ast.syntax().owned(); |
2367 | PrefixExprNode(syntax) | 2367 | PrefixExprNode(syntax) |
2368 | } | 2368 | } |
@@ -2393,7 +2393,7 @@ impl<'a> PrefixExpr<'a> {} | |||
2393 | pub struct RangeExprNode(SyntaxNode); | 2393 | pub struct RangeExprNode(SyntaxNode); |
2394 | 2394 | ||
2395 | impl RangeExprNode { | 2395 | impl RangeExprNode { |
2396 | pub fn new(&self, ast: RangeExpr) -> RangeExprNode { | 2396 | pub fn new(ast: RangeExpr) -> RangeExprNode { |
2397 | let syntax = ast.syntax().owned(); | 2397 | let syntax = ast.syntax().owned(); |
2398 | RangeExprNode(syntax) | 2398 | RangeExprNode(syntax) |
2399 | } | 2399 | } |
@@ -2424,7 +2424,7 @@ impl<'a> RangeExpr<'a> {} | |||
2424 | pub struct RangePatNode(SyntaxNode); | 2424 | pub struct RangePatNode(SyntaxNode); |
2425 | 2425 | ||
2426 | impl RangePatNode { | 2426 | impl RangePatNode { |
2427 | pub fn new(&self, ast: RangePat) -> RangePatNode { | 2427 | pub fn new(ast: RangePat) -> RangePatNode { |
2428 | let syntax = ast.syntax().owned(); | 2428 | let syntax = ast.syntax().owned(); |
2429 | RangePatNode(syntax) | 2429 | RangePatNode(syntax) |
2430 | } | 2430 | } |
@@ -2455,7 +2455,7 @@ impl<'a> RangePat<'a> {} | |||
2455 | pub struct RefExprNode(SyntaxNode); | 2455 | pub struct RefExprNode(SyntaxNode); |
2456 | 2456 | ||
2457 | impl RefExprNode { | 2457 | impl RefExprNode { |
2458 | pub fn new(&self, ast: RefExpr) -> RefExprNode { | 2458 | pub fn new(ast: RefExpr) -> RefExprNode { |
2459 | let syntax = ast.syntax().owned(); | 2459 | let syntax = ast.syntax().owned(); |
2460 | RefExprNode(syntax) | 2460 | RefExprNode(syntax) |
2461 | } | 2461 | } |
@@ -2486,7 +2486,7 @@ impl<'a> RefExpr<'a> {} | |||
2486 | pub struct RefPatNode(SyntaxNode); | 2486 | pub struct RefPatNode(SyntaxNode); |
2487 | 2487 | ||
2488 | impl RefPatNode { | 2488 | impl RefPatNode { |
2489 | pub fn new(&self, ast: RefPat) -> RefPatNode { | 2489 | pub fn new(ast: RefPat) -> RefPatNode { |
2490 | let syntax = ast.syntax().owned(); | 2490 | let syntax = ast.syntax().owned(); |
2491 | RefPatNode(syntax) | 2491 | RefPatNode(syntax) |
2492 | } | 2492 | } |
@@ -2517,7 +2517,7 @@ impl<'a> RefPat<'a> {} | |||
2517 | pub struct ReferenceTypeNode(SyntaxNode); | 2517 | pub struct ReferenceTypeNode(SyntaxNode); |
2518 | 2518 | ||
2519 | impl ReferenceTypeNode { | 2519 | impl ReferenceTypeNode { |
2520 | pub fn new(&self, ast: ReferenceType) -> ReferenceTypeNode { | 2520 | pub fn new(ast: ReferenceType) -> ReferenceTypeNode { |
2521 | let syntax = ast.syntax().owned(); | 2521 | let syntax = ast.syntax().owned(); |
2522 | ReferenceTypeNode(syntax) | 2522 | ReferenceTypeNode(syntax) |
2523 | } | 2523 | } |
@@ -2548,7 +2548,7 @@ impl<'a> ReferenceType<'a> {} | |||
2548 | pub struct RetTypeNode(SyntaxNode); | 2548 | pub struct RetTypeNode(SyntaxNode); |
2549 | 2549 | ||
2550 | impl RetTypeNode { | 2550 | impl RetTypeNode { |
2551 | pub fn new(&self, ast: RetType) -> RetTypeNode { | 2551 | pub fn new(ast: RetType) -> RetTypeNode { |
2552 | let syntax = ast.syntax().owned(); | 2552 | let syntax = ast.syntax().owned(); |
2553 | RetTypeNode(syntax) | 2553 | RetTypeNode(syntax) |
2554 | } | 2554 | } |
@@ -2579,7 +2579,7 @@ impl<'a> RetType<'a> {} | |||
2579 | pub struct ReturnExprNode(SyntaxNode); | 2579 | pub struct ReturnExprNode(SyntaxNode); |
2580 | 2580 | ||
2581 | impl ReturnExprNode { | 2581 | impl ReturnExprNode { |
2582 | pub fn new(&self, ast: ReturnExpr) -> ReturnExprNode { | 2582 | pub fn new(ast: ReturnExpr) -> ReturnExprNode { |
2583 | let syntax = ast.syntax().owned(); | 2583 | let syntax = ast.syntax().owned(); |
2584 | ReturnExprNode(syntax) | 2584 | ReturnExprNode(syntax) |
2585 | } | 2585 | } |
@@ -2610,7 +2610,7 @@ impl<'a> ReturnExpr<'a> {} | |||
2610 | pub struct RootNode(SyntaxNode); | 2610 | pub struct RootNode(SyntaxNode); |
2611 | 2611 | ||
2612 | impl RootNode { | 2612 | impl RootNode { |
2613 | pub fn new(&self, ast: Root) -> RootNode { | 2613 | pub fn new(ast: Root) -> RootNode { |
2614 | let syntax = ast.syntax().owned(); | 2614 | let syntax = ast.syntax().owned(); |
2615 | RootNode(syntax) | 2615 | RootNode(syntax) |
2616 | } | 2616 | } |
@@ -2647,7 +2647,7 @@ impl<'a> Root<'a> { | |||
2647 | pub struct SelfParamNode(SyntaxNode); | 2647 | pub struct SelfParamNode(SyntaxNode); |
2648 | 2648 | ||
2649 | impl SelfParamNode { | 2649 | impl SelfParamNode { |
2650 | pub fn new(&self, ast: SelfParam) -> SelfParamNode { | 2650 | pub fn new(ast: SelfParam) -> SelfParamNode { |
2651 | let syntax = ast.syntax().owned(); | 2651 | let syntax = ast.syntax().owned(); |
2652 | SelfParamNode(syntax) | 2652 | SelfParamNode(syntax) |
2653 | } | 2653 | } |
@@ -2678,7 +2678,7 @@ impl<'a> SelfParam<'a> {} | |||
2678 | pub struct SlicePatNode(SyntaxNode); | 2678 | pub struct SlicePatNode(SyntaxNode); |
2679 | 2679 | ||
2680 | impl SlicePatNode { | 2680 | impl SlicePatNode { |
2681 | pub fn new(&self, ast: SlicePat) -> SlicePatNode { | 2681 | pub fn new(ast: SlicePat) -> SlicePatNode { |
2682 | let syntax = ast.syntax().owned(); | 2682 | let syntax = ast.syntax().owned(); |
2683 | SlicePatNode(syntax) | 2683 | SlicePatNode(syntax) |
2684 | } | 2684 | } |
@@ -2709,7 +2709,7 @@ impl<'a> SlicePat<'a> {} | |||
2709 | pub struct SliceTypeNode(SyntaxNode); | 2709 | pub struct SliceTypeNode(SyntaxNode); |
2710 | 2710 | ||
2711 | impl SliceTypeNode { | 2711 | impl SliceTypeNode { |
2712 | pub fn new(&self, ast: SliceType) -> SliceTypeNode { | 2712 | pub fn new(ast: SliceType) -> SliceTypeNode { |
2713 | let syntax = ast.syntax().owned(); | 2713 | let syntax = ast.syntax().owned(); |
2714 | SliceTypeNode(syntax) | 2714 | SliceTypeNode(syntax) |
2715 | } | 2715 | } |
@@ -2740,7 +2740,7 @@ impl<'a> SliceType<'a> {} | |||
2740 | pub struct StaticDefNode(SyntaxNode); | 2740 | pub struct StaticDefNode(SyntaxNode); |
2741 | 2741 | ||
2742 | impl StaticDefNode { | 2742 | impl StaticDefNode { |
2743 | pub fn new(&self, ast: StaticDef) -> StaticDefNode { | 2743 | pub fn new(ast: StaticDef) -> StaticDefNode { |
2744 | let syntax = ast.syntax().owned(); | 2744 | let syntax = ast.syntax().owned(); |
2745 | StaticDefNode(syntax) | 2745 | StaticDefNode(syntax) |
2746 | } | 2746 | } |
@@ -2774,7 +2774,7 @@ impl<'a> StaticDef<'a> {} | |||
2774 | pub struct StmtNode(SyntaxNode); | 2774 | pub struct StmtNode(SyntaxNode); |
2775 | 2775 | ||
2776 | impl StmtNode { | 2776 | impl StmtNode { |
2777 | pub fn new(&self, ast: Stmt) -> StmtNode { | 2777 | pub fn new(ast: Stmt) -> StmtNode { |
2778 | let syntax = ast.syntax().owned(); | 2778 | let syntax = ast.syntax().owned(); |
2779 | StmtNode(syntax) | 2779 | StmtNode(syntax) |
2780 | } | 2780 | } |
@@ -2812,7 +2812,7 @@ impl<'a> Stmt<'a> {} | |||
2812 | pub struct StructDefNode(SyntaxNode); | 2812 | pub struct StructDefNode(SyntaxNode); |
2813 | 2813 | ||
2814 | impl StructDefNode { | 2814 | impl StructDefNode { |
2815 | pub fn new(&self, ast: StructDef) -> StructDefNode { | 2815 | pub fn new(ast: StructDef) -> StructDefNode { |
2816 | let syntax = ast.syntax().owned(); | 2816 | let syntax = ast.syntax().owned(); |
2817 | StructDefNode(syntax) | 2817 | StructDefNode(syntax) |
2818 | } | 2818 | } |
@@ -2850,7 +2850,7 @@ impl<'a> StructDef<'a> { | |||
2850 | pub struct StructLitNode(SyntaxNode); | 2850 | pub struct StructLitNode(SyntaxNode); |
2851 | 2851 | ||
2852 | impl StructLitNode { | 2852 | impl StructLitNode { |
2853 | pub fn new(&self, ast: StructLit) -> StructLitNode { | 2853 | pub fn new(ast: StructLit) -> StructLitNode { |
2854 | let syntax = ast.syntax().owned(); | 2854 | let syntax = ast.syntax().owned(); |
2855 | StructLitNode(syntax) | 2855 | StructLitNode(syntax) |
2856 | } | 2856 | } |
@@ -2881,7 +2881,7 @@ impl<'a> StructLit<'a> {} | |||
2881 | pub struct StructPatNode(SyntaxNode); | 2881 | pub struct StructPatNode(SyntaxNode); |
2882 | 2882 | ||
2883 | impl StructPatNode { | 2883 | impl StructPatNode { |
2884 | pub fn new(&self, ast: StructPat) -> StructPatNode { | 2884 | pub fn new(ast: StructPat) -> StructPatNode { |
2885 | let syntax = ast.syntax().owned(); | 2885 | let syntax = ast.syntax().owned(); |
2886 | StructPatNode(syntax) | 2886 | StructPatNode(syntax) |
2887 | } | 2887 | } |
@@ -2912,7 +2912,7 @@ impl<'a> StructPat<'a> {} | |||
2912 | pub struct TokenTreeNode(SyntaxNode); | 2912 | pub struct TokenTreeNode(SyntaxNode); |
2913 | 2913 | ||
2914 | impl TokenTreeNode { | 2914 | impl TokenTreeNode { |
2915 | pub fn new(&self, ast: TokenTree) -> TokenTreeNode { | 2915 | pub fn new(ast: TokenTree) -> TokenTreeNode { |
2916 | let syntax = ast.syntax().owned(); | 2916 | let syntax = ast.syntax().owned(); |
2917 | TokenTreeNode(syntax) | 2917 | TokenTreeNode(syntax) |
2918 | } | 2918 | } |
@@ -2943,7 +2943,7 @@ impl<'a> TokenTree<'a> {} | |||
2943 | pub struct TraitDefNode(SyntaxNode); | 2943 | pub struct TraitDefNode(SyntaxNode); |
2944 | 2944 | ||
2945 | impl TraitDefNode { | 2945 | impl TraitDefNode { |
2946 | pub fn new(&self, ast: TraitDef) -> TraitDefNode { | 2946 | pub fn new(ast: TraitDef) -> TraitDefNode { |
2947 | let syntax = ast.syntax().owned(); | 2947 | let syntax = ast.syntax().owned(); |
2948 | TraitDefNode(syntax) | 2948 | TraitDefNode(syntax) |
2949 | } | 2949 | } |
@@ -2976,7 +2976,7 @@ impl<'a> TraitDef<'a> {} | |||
2976 | pub struct TryExprNode(SyntaxNode); | 2976 | pub struct TryExprNode(SyntaxNode); |
2977 | 2977 | ||
2978 | impl TryExprNode { | 2978 | impl TryExprNode { |
2979 | pub fn new(&self, ast: TryExpr) -> TryExprNode { | 2979 | pub fn new(ast: TryExpr) -> TryExprNode { |
2980 | let syntax = ast.syntax().owned(); | 2980 | let syntax = ast.syntax().owned(); |
2981 | TryExprNode(syntax) | 2981 | TryExprNode(syntax) |
2982 | } | 2982 | } |
@@ -3007,7 +3007,7 @@ impl<'a> TryExpr<'a> {} | |||
3007 | pub struct TupleExprNode(SyntaxNode); | 3007 | pub struct TupleExprNode(SyntaxNode); |
3008 | 3008 | ||
3009 | impl TupleExprNode { | 3009 | impl TupleExprNode { |
3010 | pub fn new(&self, ast: TupleExpr) -> TupleExprNode { | 3010 | pub fn new(ast: TupleExpr) -> TupleExprNode { |
3011 | let syntax = ast.syntax().owned(); | 3011 | let syntax = ast.syntax().owned(); |
3012 | TupleExprNode(syntax) | 3012 | TupleExprNode(syntax) |
3013 | } | 3013 | } |
@@ -3038,7 +3038,7 @@ impl<'a> TupleExpr<'a> {} | |||
3038 | pub struct TuplePatNode(SyntaxNode); | 3038 | pub struct TuplePatNode(SyntaxNode); |
3039 | 3039 | ||
3040 | impl TuplePatNode { | 3040 | impl TuplePatNode { |
3041 | pub fn new(&self, ast: TuplePat) -> TuplePatNode { | 3041 | pub fn new(ast: TuplePat) -> TuplePatNode { |
3042 | let syntax = ast.syntax().owned(); | 3042 | let syntax = ast.syntax().owned(); |
3043 | TuplePatNode(syntax) | 3043 | TuplePatNode(syntax) |
3044 | } | 3044 | } |
@@ -3069,7 +3069,7 @@ impl<'a> TuplePat<'a> {} | |||
3069 | pub struct TupleStructPatNode(SyntaxNode); | 3069 | pub struct TupleStructPatNode(SyntaxNode); |
3070 | 3070 | ||
3071 | impl TupleStructPatNode { | 3071 | impl TupleStructPatNode { |
3072 | pub fn new(&self, ast: TupleStructPat) -> TupleStructPatNode { | 3072 | pub fn new(ast: TupleStructPat) -> TupleStructPatNode { |
3073 | let syntax = ast.syntax().owned(); | 3073 | let syntax = ast.syntax().owned(); |
3074 | TupleStructPatNode(syntax) | 3074 | TupleStructPatNode(syntax) |
3075 | } | 3075 | } |
@@ -3100,7 +3100,7 @@ impl<'a> TupleStructPat<'a> {} | |||
3100 | pub struct TupleTypeNode(SyntaxNode); | 3100 | pub struct TupleTypeNode(SyntaxNode); |
3101 | 3101 | ||
3102 | impl TupleTypeNode { | 3102 | impl TupleTypeNode { |
3103 | pub fn new(&self, ast: TupleType) -> TupleTypeNode { | 3103 | pub fn new(ast: TupleType) -> TupleTypeNode { |
3104 | let syntax = ast.syntax().owned(); | 3104 | let syntax = ast.syntax().owned(); |
3105 | TupleTypeNode(syntax) | 3105 | TupleTypeNode(syntax) |
3106 | } | 3106 | } |
@@ -3131,7 +3131,7 @@ impl<'a> TupleType<'a> {} | |||
3131 | pub struct TypeDefNode(SyntaxNode); | 3131 | pub struct TypeDefNode(SyntaxNode); |
3132 | 3132 | ||
3133 | impl TypeDefNode { | 3133 | impl TypeDefNode { |
3134 | pub fn new(&self, ast: TypeDef) -> TypeDefNode { | 3134 | pub fn new(ast: TypeDef) -> TypeDefNode { |
3135 | let syntax = ast.syntax().owned(); | 3135 | let syntax = ast.syntax().owned(); |
3136 | TypeDefNode(syntax) | 3136 | TypeDefNode(syntax) |
3137 | } | 3137 | } |
@@ -3165,7 +3165,7 @@ impl<'a> TypeDef<'a> {} | |||
3165 | pub struct TypeParamNode(SyntaxNode); | 3165 | pub struct TypeParamNode(SyntaxNode); |
3166 | 3166 | ||
3167 | impl TypeParamNode { | 3167 | impl TypeParamNode { |
3168 | pub fn new(&self, ast: TypeParam) -> TypeParamNode { | 3168 | pub fn new(ast: TypeParam) -> TypeParamNode { |
3169 | let syntax = ast.syntax().owned(); | 3169 | let syntax = ast.syntax().owned(); |
3170 | TypeParamNode(syntax) | 3170 | TypeParamNode(syntax) |
3171 | } | 3171 | } |
@@ -3197,7 +3197,7 @@ impl<'a> TypeParam<'a> {} | |||
3197 | pub struct TypeParamListNode(SyntaxNode); | 3197 | pub struct TypeParamListNode(SyntaxNode); |
3198 | 3198 | ||
3199 | impl TypeParamListNode { | 3199 | impl TypeParamListNode { |
3200 | pub fn new(&self, ast: TypeParamList) -> TypeParamListNode { | 3200 | pub fn new(ast: TypeParamList) -> TypeParamListNode { |
3201 | let syntax = ast.syntax().owned(); | 3201 | let syntax = ast.syntax().owned(); |
3202 | TypeParamListNode(syntax) | 3202 | TypeParamListNode(syntax) |
3203 | } | 3203 | } |
@@ -3236,7 +3236,7 @@ impl<'a> TypeParamList<'a> { | |||
3236 | pub struct TypeRefNode(SyntaxNode); | 3236 | pub struct TypeRefNode(SyntaxNode); |
3237 | 3237 | ||
3238 | impl TypeRefNode { | 3238 | impl TypeRefNode { |
3239 | pub fn new(&self, ast: TypeRef) -> TypeRefNode { | 3239 | pub fn new(ast: TypeRef) -> TypeRefNode { |
3240 | let syntax = ast.syntax().owned(); | 3240 | let syntax = ast.syntax().owned(); |
3241 | TypeRefNode(syntax) | 3241 | TypeRefNode(syntax) |
3242 | } | 3242 | } |
@@ -3307,7 +3307,7 @@ impl<'a> TypeRef<'a> {} | |||
3307 | pub struct UseItemNode(SyntaxNode); | 3307 | pub struct UseItemNode(SyntaxNode); |
3308 | 3308 | ||
3309 | impl UseItemNode { | 3309 | impl UseItemNode { |
3310 | pub fn new(&self, ast: UseItem) -> UseItemNode { | 3310 | pub fn new(ast: UseItem) -> UseItemNode { |
3311 | let syntax = ast.syntax().owned(); | 3311 | let syntax = ast.syntax().owned(); |
3312 | UseItemNode(syntax) | 3312 | UseItemNode(syntax) |
3313 | } | 3313 | } |
@@ -3342,7 +3342,7 @@ impl<'a> UseItem<'a> { | |||
3342 | pub struct UseTreeNode(SyntaxNode); | 3342 | pub struct UseTreeNode(SyntaxNode); |
3343 | 3343 | ||
3344 | impl UseTreeNode { | 3344 | impl UseTreeNode { |
3345 | pub fn new(&self, ast: UseTree) -> UseTreeNode { | 3345 | pub fn new(ast: UseTree) -> UseTreeNode { |
3346 | let syntax = ast.syntax().owned(); | 3346 | let syntax = ast.syntax().owned(); |
3347 | UseTreeNode(syntax) | 3347 | UseTreeNode(syntax) |
3348 | } | 3348 | } |
@@ -3381,7 +3381,7 @@ impl<'a> UseTree<'a> { | |||
3381 | pub struct UseTreeListNode(SyntaxNode); | 3381 | pub struct UseTreeListNode(SyntaxNode); |
3382 | 3382 | ||
3383 | impl UseTreeListNode { | 3383 | impl UseTreeListNode { |
3384 | pub fn new(&self, ast: UseTreeList) -> UseTreeListNode { | 3384 | pub fn new(ast: UseTreeList) -> UseTreeListNode { |
3385 | let syntax = ast.syntax().owned(); | 3385 | let syntax = ast.syntax().owned(); |
3386 | UseTreeListNode(syntax) | 3386 | UseTreeListNode(syntax) |
3387 | } | 3387 | } |
@@ -3416,7 +3416,7 @@ impl<'a> UseTreeList<'a> { | |||
3416 | pub struct WhereClauseNode(SyntaxNode); | 3416 | pub struct WhereClauseNode(SyntaxNode); |
3417 | 3417 | ||
3418 | impl WhereClauseNode { | 3418 | impl WhereClauseNode { |
3419 | pub fn new(&self, ast: WhereClause) -> WhereClauseNode { | 3419 | pub fn new(ast: WhereClause) -> WhereClauseNode { |
3420 | let syntax = ast.syntax().owned(); | 3420 | let syntax = ast.syntax().owned(); |
3421 | WhereClauseNode(syntax) | 3421 | WhereClauseNode(syntax) |
3422 | } | 3422 | } |
@@ -3447,7 +3447,7 @@ impl<'a> WhereClause<'a> {} | |||
3447 | pub struct WhileExprNode(SyntaxNode); | 3447 | pub struct WhileExprNode(SyntaxNode); |
3448 | 3448 | ||
3449 | impl WhileExprNode { | 3449 | impl WhileExprNode { |
3450 | pub fn new(&self, ast: WhileExpr) -> WhileExprNode { | 3450 | pub fn new(ast: WhileExpr) -> WhileExprNode { |
3451 | let syntax = ast.syntax().owned(); | 3451 | let syntax = ast.syntax().owned(); |
3452 | WhileExprNode(syntax) | 3452 | WhileExprNode(syntax) |
3453 | } | 3453 | } |
@@ -3483,7 +3483,7 @@ impl<'a> WhileExpr<'a> { | |||
3483 | pub struct WhitespaceNode(SyntaxNode); | 3483 | pub struct WhitespaceNode(SyntaxNode); |
3484 | 3484 | ||
3485 | impl WhitespaceNode { | 3485 | impl WhitespaceNode { |
3486 | pub fn new(&self, ast: Whitespace) -> WhitespaceNode { | 3486 | pub fn new(ast: Whitespace) -> WhitespaceNode { |
3487 | let syntax = ast.syntax().owned(); | 3487 | let syntax = ast.syntax().owned(); |
3488 | WhitespaceNode(syntax) | 3488 | WhitespaceNode(syntax) |
3489 | } | 3489 | } |
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index c61c3e80b..d30038cba 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | pub struct {{ node }}Node(SyntaxNode); | 17 | pub struct {{ node }}Node(SyntaxNode); |
18 | 18 | ||
19 | impl {{ node }}Node { | 19 | impl {{ node }}Node { |
20 | pub fn new(&self, ast: {{ node }}) -> {{ node }}Node { | 20 | pub fn new(ast: {{ node }}) -> {{ node }}Node { |
21 | let syntax = ast.syntax().owned(); | 21 | let syntax = ast.syntax().owned(); |
22 | {{ node }}Node(syntax) | 22 | {{ node }}Node(syntax) |
23 | } | 23 | } |