diff options
author | Florian Diebold <[email protected]> | 2018-12-25 20:14:13 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2018-12-25 20:14:13 +0000 |
commit | cdca39706121b2d1734a94938a2372da881e10c6 (patch) | |
tree | d3f9687371eb1a7004c4694c59445af388eb1876 /crates/ra_syntax/src | |
parent | 2870effd5c69941bbf32a44c0ee6d9d42e0b038d (diff) |
Add a hir::TypeRef as an intermediate between ast::TypeRef and ty::Ty
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 38 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 10 |
2 files changed, 38 insertions, 10 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 535dcc975..c22e026cf 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -131,7 +131,15 @@ impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> { | |||
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | impl<'a> ArrayType<'a> {} | 134 | impl<'a> ArrayType<'a> { |
135 | pub fn type_ref(self) -> Option<TypeRef<'a>> { | ||
136 | super::child_opt(self) | ||
137 | } | ||
138 | |||
139 | pub fn expr(self) -> Option<Expr<'a>> { | ||
140 | super::child_opt(self) | ||
141 | } | ||
142 | } | ||
135 | 143 | ||
136 | // Attr | 144 | // Attr |
137 | #[derive(Debug, Clone, Copy,)] | 145 | #[derive(Debug, Clone, Copy,)] |
@@ -1258,7 +1266,15 @@ impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> { | |||
1258 | } | 1266 | } |
1259 | 1267 | ||
1260 | 1268 | ||
1261 | impl<'a> FnPointerType<'a> {} | 1269 | impl<'a> FnPointerType<'a> { |
1270 | pub fn param_list(self) -> Option<ParamList<'a>> { | ||
1271 | super::child_opt(self) | ||
1272 | } | ||
1273 | |||
1274 | pub fn ret_type(self) -> Option<RetType<'a>> { | ||
1275 | super::child_opt(self) | ||
1276 | } | ||
1277 | } | ||
1262 | 1278 | ||
1263 | // ForExpr | 1279 | // ForExpr |
1264 | #[derive(Debug, Clone, Copy,)] | 1280 | #[derive(Debug, Clone, Copy,)] |
@@ -1341,7 +1357,11 @@ impl<R: TreeRoot<RaTypes>> ForTypeNode<R> { | |||
1341 | } | 1357 | } |
1342 | 1358 | ||
1343 | 1359 | ||
1344 | impl<'a> ForType<'a> {} | 1360 | impl<'a> ForType<'a> { |
1361 | pub fn type_ref(self) -> Option<TypeRef<'a>> { | ||
1362 | super::child_opt(self) | ||
1363 | } | ||
1364 | } | ||
1345 | 1365 | ||
1346 | // IfExpr | 1366 | // IfExpr |
1347 | #[derive(Debug, Clone, Copy,)] | 1367 | #[derive(Debug, Clone, Copy,)] |
@@ -3490,7 +3510,11 @@ impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> { | |||
3490 | } | 3510 | } |
3491 | 3511 | ||
3492 | 3512 | ||
3493 | impl<'a> SliceType<'a> {} | 3513 | impl<'a> SliceType<'a> { |
3514 | pub fn type_ref(self) -> Option<TypeRef<'a>> { | ||
3515 | super::child_opt(self) | ||
3516 | } | ||
3517 | } | ||
3494 | 3518 | ||
3495 | // SourceFile | 3519 | // SourceFile |
3496 | #[derive(Debug, Clone, Copy,)] | 3520 | #[derive(Debug, Clone, Copy,)] |
@@ -4025,7 +4049,11 @@ impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> { | |||
4025 | } | 4049 | } |
4026 | 4050 | ||
4027 | 4051 | ||
4028 | impl<'a> TupleType<'a> {} | 4052 | impl<'a> TupleType<'a> { |
4053 | pub fn fields(self) -> impl Iterator<Item = TypeRef<'a>> + 'a { | ||
4054 | super::children(self) | ||
4055 | } | ||
4056 | } | ||
4029 | 4057 | ||
4030 | // TypeDef | 4058 | // TypeDef |
4031 | #[derive(Debug, Clone, Copy,)] | 4059 | #[derive(Debug, Clone, Copy,)] |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 8b1bd6d1c..4bcff4e14 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -304,16 +304,16 @@ Grammar( | |||
304 | "ImplItem": (), | 304 | "ImplItem": (), |
305 | 305 | ||
306 | "ParenType": (options: ["TypeRef"]), | 306 | "ParenType": (options: ["TypeRef"]), |
307 | "TupleType": (), | 307 | "TupleType": ( collections: [["fields", "TypeRef"]] ), |
308 | "NeverType": (), | 308 | "NeverType": (), |
309 | "PathType": (options: ["Path"]), | 309 | "PathType": (options: ["Path"]), |
310 | "PointerType": (options: ["TypeRef"]), | 310 | "PointerType": (options: ["TypeRef"]), |
311 | "ArrayType": (), | 311 | "ArrayType": ( options: ["TypeRef", "Expr"] ), |
312 | "SliceType": (), | 312 | "SliceType": ( options: ["TypeRef"] ), |
313 | "ReferenceType": (options: ["TypeRef"]), | 313 | "ReferenceType": (options: ["TypeRef"]), |
314 | "PlaceholderType": (), | 314 | "PlaceholderType": (), |
315 | "FnPointerType": (), | 315 | "FnPointerType": (options: ["ParamList", "RetType"]), |
316 | "ForType": (), | 316 | "ForType": (options: ["TypeRef"]), |
317 | "ImplTraitType": (), | 317 | "ImplTraitType": (), |
318 | "DynTraitType": (), | 318 | "DynTraitType": (), |
319 | 319 | ||