diff options
author | Aleksey Kladov <[email protected]> | 2018-08-26 10:09:28 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-26 10:09:28 +0100 |
commit | ac226021cfd26a9332b5971f3e05118d77822af5 (patch) | |
tree | 04e9d19956b74d551f798bf26f420fa978b8f30f /crates/libsyntax2/src/ast | |
parent | 4c121bfa2f2a7a06f01143e3203c650156e2fb4e (diff) |
scope based comletion
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 308 |
1 files changed, 306 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 7d746a85b..6926c0535 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -80,6 +80,25 @@ impl<'a> AstNode<'a> for BinExpr<'a> { | |||
80 | 80 | ||
81 | impl<'a> BinExpr<'a> {} | 81 | impl<'a> BinExpr<'a> {} |
82 | 82 | ||
83 | // BindPat | ||
84 | #[derive(Debug, Clone, Copy)] | ||
85 | pub struct BindPat<'a> { | ||
86 | syntax: SyntaxNodeRef<'a>, | ||
87 | } | ||
88 | |||
89 | impl<'a> AstNode<'a> for BindPat<'a> { | ||
90 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
91 | match syntax.kind() { | ||
92 | BIND_PAT => Some(BindPat { syntax }), | ||
93 | _ => None, | ||
94 | } | ||
95 | } | ||
96 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
97 | } | ||
98 | |||
99 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} | ||
100 | impl<'a> BindPat<'a> {} | ||
101 | |||
83 | // Block | 102 | // Block |
84 | #[derive(Debug, Clone, Copy)] | 103 | #[derive(Debug, Clone, Copy)] |
85 | pub struct Block<'a> { | 104 | pub struct Block<'a> { |
@@ -96,7 +115,11 @@ impl<'a> AstNode<'a> for Block<'a> { | |||
96 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 115 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
97 | } | 116 | } |
98 | 117 | ||
99 | impl<'a> Block<'a> {} | 118 | impl<'a> Block<'a> { |
119 | pub fn let_stmts(self) -> impl Iterator<Item = LetStmt<'a>> + 'a { | ||
120 | super::children(self) | ||
121 | } | ||
122 | } | ||
100 | 123 | ||
101 | // BlockExpr | 124 | // BlockExpr |
102 | #[derive(Debug, Clone, Copy)] | 125 | #[derive(Debug, Clone, Copy)] |
@@ -378,6 +401,24 @@ impl<'a> AstNode<'a> for FieldExpr<'a> { | |||
378 | 401 | ||
379 | impl<'a> FieldExpr<'a> {} | 402 | impl<'a> FieldExpr<'a> {} |
380 | 403 | ||
404 | // FieldPatList | ||
405 | #[derive(Debug, Clone, Copy)] | ||
406 | pub struct FieldPatList<'a> { | ||
407 | syntax: SyntaxNodeRef<'a>, | ||
408 | } | ||
409 | |||
410 | impl<'a> AstNode<'a> for FieldPatList<'a> { | ||
411 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
412 | match syntax.kind() { | ||
413 | FIELD_PAT_LIST => Some(FieldPatList { syntax }), | ||
414 | _ => None, | ||
415 | } | ||
416 | } | ||
417 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
418 | } | ||
419 | |||
420 | impl<'a> FieldPatList<'a> {} | ||
421 | |||
381 | // FnDef | 422 | // FnDef |
382 | #[derive(Debug, Clone, Copy)] | 423 | #[derive(Debug, Clone, Copy)] |
383 | pub struct FnDef<'a> { | 424 | pub struct FnDef<'a> { |
@@ -397,7 +438,11 @@ impl<'a> AstNode<'a> for FnDef<'a> { | |||
397 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} | 438 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} |
398 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} | 439 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} |
399 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} | 440 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} |
400 | impl<'a> FnDef<'a> {} | 441 | impl<'a> FnDef<'a> { |
442 | pub fn param_list(self) -> Option<ParamList<'a>> { | ||
443 | super::child_opt(self) | ||
444 | } | ||
445 | } | ||
401 | 446 | ||
402 | // FnPointerType | 447 | // FnPointerType |
403 | #[derive(Debug, Clone, Copy)] | 448 | #[derive(Debug, Clone, Copy)] |
@@ -561,6 +606,28 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> { | |||
561 | 606 | ||
562 | impl<'a> LambdaExpr<'a> {} | 607 | impl<'a> LambdaExpr<'a> {} |
563 | 608 | ||
609 | // LetStmt | ||
610 | #[derive(Debug, Clone, Copy)] | ||
611 | pub struct LetStmt<'a> { | ||
612 | syntax: SyntaxNodeRef<'a>, | ||
613 | } | ||
614 | |||
615 | impl<'a> AstNode<'a> for LetStmt<'a> { | ||
616 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
617 | match syntax.kind() { | ||
618 | LET_STMT => Some(LetStmt { syntax }), | ||
619 | _ => None, | ||
620 | } | ||
621 | } | ||
622 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
623 | } | ||
624 | |||
625 | impl<'a> LetStmt<'a> { | ||
626 | pub fn pat(self) -> Option<Pat<'a>> { | ||
627 | super::child_opt(self) | ||
628 | } | ||
629 | } | ||
630 | |||
564 | // LoopExpr | 631 | // LoopExpr |
565 | #[derive(Debug, Clone, Copy)] | 632 | #[derive(Debug, Clone, Copy)] |
566 | pub struct LoopExpr<'a> { | 633 | pub struct LoopExpr<'a> { |
@@ -831,6 +898,50 @@ impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {} | |||
831 | impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} | 898 | impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} |
832 | impl<'a> NominalDef<'a> {} | 899 | impl<'a> NominalDef<'a> {} |
833 | 900 | ||
901 | // Param | ||
902 | #[derive(Debug, Clone, Copy)] | ||
903 | pub struct Param<'a> { | ||
904 | syntax: SyntaxNodeRef<'a>, | ||
905 | } | ||
906 | |||
907 | impl<'a> AstNode<'a> for Param<'a> { | ||
908 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
909 | match syntax.kind() { | ||
910 | PARAM => Some(Param { syntax }), | ||
911 | _ => None, | ||
912 | } | ||
913 | } | ||
914 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
915 | } | ||
916 | |||
917 | impl<'a> Param<'a> { | ||
918 | pub fn pat(self) -> Option<Pat<'a>> { | ||
919 | super::child_opt(self) | ||
920 | } | ||
921 | } | ||
922 | |||
923 | // ParamList | ||
924 | #[derive(Debug, Clone, Copy)] | ||
925 | pub struct ParamList<'a> { | ||
926 | syntax: SyntaxNodeRef<'a>, | ||
927 | } | ||
928 | |||
929 | impl<'a> AstNode<'a> for ParamList<'a> { | ||
930 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
931 | match syntax.kind() { | ||
932 | PARAM_LIST => Some(ParamList { syntax }), | ||
933 | _ => None, | ||
934 | } | ||
935 | } | ||
936 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
937 | } | ||
938 | |||
939 | impl<'a> ParamList<'a> { | ||
940 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { | ||
941 | super::children(self) | ||
942 | } | ||
943 | } | ||
944 | |||
834 | // ParenExpr | 945 | // ParenExpr |
835 | #[derive(Debug, Clone, Copy)] | 946 | #[derive(Debug, Clone, Copy)] |
836 | pub struct ParenExpr<'a> { | 947 | pub struct ParenExpr<'a> { |
@@ -867,6 +978,55 @@ impl<'a> AstNode<'a> for ParenType<'a> { | |||
867 | 978 | ||
868 | impl<'a> ParenType<'a> {} | 979 | impl<'a> ParenType<'a> {} |
869 | 980 | ||
981 | // Pat | ||
982 | #[derive(Debug, Clone, Copy)] | ||
983 | pub enum Pat<'a> { | ||
984 | RefPat(RefPat<'a>), | ||
985 | BindPat(BindPat<'a>), | ||
986 | PlaceholderPat(PlaceholderPat<'a>), | ||
987 | PathPat(PathPat<'a>), | ||
988 | StructPat(StructPat<'a>), | ||
989 | FieldPatList(FieldPatList<'a>), | ||
990 | TupleStructPat(TupleStructPat<'a>), | ||
991 | TuplePat(TuplePat<'a>), | ||
992 | SlicePat(SlicePat<'a>), | ||
993 | RangePat(RangePat<'a>), | ||
994 | } | ||
995 | |||
996 | impl<'a> AstNode<'a> for Pat<'a> { | ||
997 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
998 | match syntax.kind() { | ||
999 | REF_PAT => Some(Pat::RefPat(RefPat { syntax })), | ||
1000 | BIND_PAT => Some(Pat::BindPat(BindPat { syntax })), | ||
1001 | PLACEHOLDER_PAT => Some(Pat::PlaceholderPat(PlaceholderPat { syntax })), | ||
1002 | PATH_PAT => Some(Pat::PathPat(PathPat { syntax })), | ||
1003 | STRUCT_PAT => Some(Pat::StructPat(StructPat { syntax })), | ||
1004 | FIELD_PAT_LIST => Some(Pat::FieldPatList(FieldPatList { syntax })), | ||
1005 | TUPLE_STRUCT_PAT => Some(Pat::TupleStructPat(TupleStructPat { syntax })), | ||
1006 | TUPLE_PAT => Some(Pat::TuplePat(TuplePat { syntax })), | ||
1007 | SLICE_PAT => Some(Pat::SlicePat(SlicePat { syntax })), | ||
1008 | RANGE_PAT => Some(Pat::RangePat(RangePat { syntax })), | ||
1009 | _ => None, | ||
1010 | } | ||
1011 | } | ||
1012 | fn syntax(self) -> SyntaxNodeRef<'a> { | ||
1013 | match self { | ||
1014 | Pat::RefPat(inner) => inner.syntax(), | ||
1015 | Pat::BindPat(inner) => inner.syntax(), | ||
1016 | Pat::PlaceholderPat(inner) => inner.syntax(), | ||
1017 | Pat::PathPat(inner) => inner.syntax(), | ||
1018 | Pat::StructPat(inner) => inner.syntax(), | ||
1019 | Pat::FieldPatList(inner) => inner.syntax(), | ||
1020 | Pat::TupleStructPat(inner) => inner.syntax(), | ||
1021 | Pat::TuplePat(inner) => inner.syntax(), | ||
1022 | Pat::SlicePat(inner) => inner.syntax(), | ||
1023 | Pat::RangePat(inner) => inner.syntax(), | ||
1024 | } | ||
1025 | } | ||
1026 | } | ||
1027 | |||
1028 | impl<'a> Pat<'a> {} | ||
1029 | |||
870 | // PathExpr | 1030 | // PathExpr |
871 | #[derive(Debug, Clone, Copy)] | 1031 | #[derive(Debug, Clone, Copy)] |
872 | pub struct PathExpr<'a> { | 1032 | pub struct PathExpr<'a> { |
@@ -885,6 +1045,24 @@ impl<'a> AstNode<'a> for PathExpr<'a> { | |||
885 | 1045 | ||
886 | impl<'a> PathExpr<'a> {} | 1046 | impl<'a> PathExpr<'a> {} |
887 | 1047 | ||
1048 | // PathPat | ||
1049 | #[derive(Debug, Clone, Copy)] | ||
1050 | pub struct PathPat<'a> { | ||
1051 | syntax: SyntaxNodeRef<'a>, | ||
1052 | } | ||
1053 | |||
1054 | impl<'a> AstNode<'a> for PathPat<'a> { | ||
1055 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1056 | match syntax.kind() { | ||
1057 | PATH_PAT => Some(PathPat { syntax }), | ||
1058 | _ => None, | ||
1059 | } | ||
1060 | } | ||
1061 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1062 | } | ||
1063 | |||
1064 | impl<'a> PathPat<'a> {} | ||
1065 | |||
888 | // PathType | 1066 | // PathType |
889 | #[derive(Debug, Clone, Copy)] | 1067 | #[derive(Debug, Clone, Copy)] |
890 | pub struct PathType<'a> { | 1068 | pub struct PathType<'a> { |
@@ -903,6 +1081,24 @@ impl<'a> AstNode<'a> for PathType<'a> { | |||
903 | 1081 | ||
904 | impl<'a> PathType<'a> {} | 1082 | impl<'a> PathType<'a> {} |
905 | 1083 | ||
1084 | // PlaceholderPat | ||
1085 | #[derive(Debug, Clone, Copy)] | ||
1086 | pub struct PlaceholderPat<'a> { | ||
1087 | syntax: SyntaxNodeRef<'a>, | ||
1088 | } | ||
1089 | |||
1090 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { | ||
1091 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1092 | match syntax.kind() { | ||
1093 | PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }), | ||
1094 | _ => None, | ||
1095 | } | ||
1096 | } | ||
1097 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1098 | } | ||
1099 | |||
1100 | impl<'a> PlaceholderPat<'a> {} | ||
1101 | |||
906 | // PlaceholderType | 1102 | // PlaceholderType |
907 | #[derive(Debug, Clone, Copy)] | 1103 | #[derive(Debug, Clone, Copy)] |
908 | pub struct PlaceholderType<'a> { | 1104 | pub struct PlaceholderType<'a> { |
@@ -975,6 +1171,24 @@ impl<'a> AstNode<'a> for RangeExpr<'a> { | |||
975 | 1171 | ||
976 | impl<'a> RangeExpr<'a> {} | 1172 | impl<'a> RangeExpr<'a> {} |
977 | 1173 | ||
1174 | // RangePat | ||
1175 | #[derive(Debug, Clone, Copy)] | ||
1176 | pub struct RangePat<'a> { | ||
1177 | syntax: SyntaxNodeRef<'a>, | ||
1178 | } | ||
1179 | |||
1180 | impl<'a> AstNode<'a> for RangePat<'a> { | ||
1181 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1182 | match syntax.kind() { | ||
1183 | RANGE_PAT => Some(RangePat { syntax }), | ||
1184 | _ => None, | ||
1185 | } | ||
1186 | } | ||
1187 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1188 | } | ||
1189 | |||
1190 | impl<'a> RangePat<'a> {} | ||
1191 | |||
978 | // RefExpr | 1192 | // RefExpr |
979 | #[derive(Debug, Clone, Copy)] | 1193 | #[derive(Debug, Clone, Copy)] |
980 | pub struct RefExpr<'a> { | 1194 | pub struct RefExpr<'a> { |
@@ -993,6 +1207,24 @@ impl<'a> AstNode<'a> for RefExpr<'a> { | |||
993 | 1207 | ||
994 | impl<'a> RefExpr<'a> {} | 1208 | impl<'a> RefExpr<'a> {} |
995 | 1209 | ||
1210 | // RefPat | ||
1211 | #[derive(Debug, Clone, Copy)] | ||
1212 | pub struct RefPat<'a> { | ||
1213 | syntax: SyntaxNodeRef<'a>, | ||
1214 | } | ||
1215 | |||
1216 | impl<'a> AstNode<'a> for RefPat<'a> { | ||
1217 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1218 | match syntax.kind() { | ||
1219 | REF_PAT => Some(RefPat { syntax }), | ||
1220 | _ => None, | ||
1221 | } | ||
1222 | } | ||
1223 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1224 | } | ||
1225 | |||
1226 | impl<'a> RefPat<'a> {} | ||
1227 | |||
996 | // ReferenceType | 1228 | // ReferenceType |
997 | #[derive(Debug, Clone, Copy)] | 1229 | #[derive(Debug, Clone, Copy)] |
998 | pub struct ReferenceType<'a> { | 1230 | pub struct ReferenceType<'a> { |
@@ -1055,6 +1287,24 @@ impl<'a> Root<'a> { | |||
1055 | } | 1287 | } |
1056 | } | 1288 | } |
1057 | 1289 | ||
1290 | // SlicePat | ||
1291 | #[derive(Debug, Clone, Copy)] | ||
1292 | pub struct SlicePat<'a> { | ||
1293 | syntax: SyntaxNodeRef<'a>, | ||
1294 | } | ||
1295 | |||
1296 | impl<'a> AstNode<'a> for SlicePat<'a> { | ||
1297 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1298 | match syntax.kind() { | ||
1299 | SLICE_PAT => Some(SlicePat { syntax }), | ||
1300 | _ => None, | ||
1301 | } | ||
1302 | } | ||
1303 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1304 | } | ||
1305 | |||
1306 | impl<'a> SlicePat<'a> {} | ||
1307 | |||
1058 | // SliceType | 1308 | // SliceType |
1059 | #[derive(Debug, Clone, Copy)] | 1309 | #[derive(Debug, Clone, Copy)] |
1060 | pub struct SliceType<'a> { | 1310 | pub struct SliceType<'a> { |
@@ -1137,6 +1387,24 @@ impl<'a> AstNode<'a> for StructLit<'a> { | |||
1137 | 1387 | ||
1138 | impl<'a> StructLit<'a> {} | 1388 | impl<'a> StructLit<'a> {} |
1139 | 1389 | ||
1390 | // StructPat | ||
1391 | #[derive(Debug, Clone, Copy)] | ||
1392 | pub struct StructPat<'a> { | ||
1393 | syntax: SyntaxNodeRef<'a>, | ||
1394 | } | ||
1395 | |||
1396 | impl<'a> AstNode<'a> for StructPat<'a> { | ||
1397 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1398 | match syntax.kind() { | ||
1399 | STRUCT_PAT => Some(StructPat { syntax }), | ||
1400 | _ => None, | ||
1401 | } | ||
1402 | } | ||
1403 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1404 | } | ||
1405 | |||
1406 | impl<'a> StructPat<'a> {} | ||
1407 | |||
1140 | // TokenTree | 1408 | // TokenTree |
1141 | #[derive(Debug, Clone, Copy)] | 1409 | #[derive(Debug, Clone, Copy)] |
1142 | pub struct TokenTree<'a> { | 1410 | pub struct TokenTree<'a> { |
@@ -1211,6 +1479,42 @@ impl<'a> AstNode<'a> for TupleExpr<'a> { | |||
1211 | 1479 | ||
1212 | impl<'a> TupleExpr<'a> {} | 1480 | impl<'a> TupleExpr<'a> {} |
1213 | 1481 | ||
1482 | // TuplePat | ||
1483 | #[derive(Debug, Clone, Copy)] | ||
1484 | pub struct TuplePat<'a> { | ||
1485 | syntax: SyntaxNodeRef<'a>, | ||
1486 | } | ||
1487 | |||
1488 | impl<'a> AstNode<'a> for TuplePat<'a> { | ||
1489 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1490 | match syntax.kind() { | ||
1491 | TUPLE_PAT => Some(TuplePat { syntax }), | ||
1492 | _ => None, | ||
1493 | } | ||
1494 | } | ||
1495 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1496 | } | ||
1497 | |||
1498 | impl<'a> TuplePat<'a> {} | ||
1499 | |||
1500 | // TupleStructPat | ||
1501 | #[derive(Debug, Clone, Copy)] | ||
1502 | pub struct TupleStructPat<'a> { | ||
1503 | syntax: SyntaxNodeRef<'a>, | ||
1504 | } | ||
1505 | |||
1506 | impl<'a> AstNode<'a> for TupleStructPat<'a> { | ||
1507 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1508 | match syntax.kind() { | ||
1509 | TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }), | ||
1510 | _ => None, | ||
1511 | } | ||
1512 | } | ||
1513 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
1514 | } | ||
1515 | |||
1516 | impl<'a> TupleStructPat<'a> {} | ||
1517 | |||
1214 | // TupleType | 1518 | // TupleType |
1215 | #[derive(Debug, Clone, Copy)] | 1519 | #[derive(Debug, Clone, Copy)] |
1216 | pub struct TupleType<'a> { | 1520 | pub struct TupleType<'a> { |