From 3ac605e6876056fa56098231cc2f96553faab8f0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 20 Dec 2018 21:56:28 +0100 Subject: Add beginnings of type infrastructure --- crates/ra_syntax/src/ast/generated.rs | 44 ++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index bf056131e..91f27fb26 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -523,7 +523,15 @@ impl> CastExprNode { } -impl<'a> CastExpr<'a> {} +impl<'a> CastExpr<'a> { + pub fn expr(self) -> Option> { + super::child_opt(self) + } + + pub fn type_ref(self) -> Option> { + super::child_opt(self) + } +} // Char #[derive(Debug, Clone, Copy,)] @@ -2312,6 +2320,10 @@ impl<'a> Param<'a> { pub fn pat(self) -> Option> { super::child_opt(self) } + + pub fn type_ref(self) -> Option> { + super::child_opt(self) + } } // ParamList @@ -2394,7 +2406,11 @@ impl> ParenExprNode { } -impl<'a> ParenExpr<'a> {} +impl<'a> ParenExpr<'a> { + pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // ParenType #[derive(Debug, Clone, Copy,)] @@ -2829,7 +2845,11 @@ impl> PrefixExprNode { } -impl<'a> PrefixExpr<'a> {} +impl<'a> PrefixExpr<'a> { + pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // RangeExpr #[derive(Debug, Clone, Copy,)] @@ -2940,7 +2960,11 @@ impl> RefExprNode { } -impl<'a> RefExpr<'a> {} +impl<'a> RefExpr<'a> { + pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // RefPat #[derive(Debug, Clone, Copy,)] @@ -3088,7 +3112,11 @@ impl> ReturnExprNode { } -impl<'a> ReturnExpr<'a> {} +impl<'a> ReturnExpr<'a> { + pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // SelfParam #[derive(Debug, Clone, Copy,)] @@ -3578,7 +3606,11 @@ impl> TryExprNode { } -impl<'a> TryExpr<'a> {} +impl<'a> TryExpr<'a> { + pub fn expr(self) -> Option> { + super::child_opt(self) + } +} // TupleExpr #[derive(Debug, Clone, Copy,)] -- cgit v1.2.3 From 3899898d75176ce3cd87f9e2acecd7e3a987dda5 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 22 Dec 2018 22:17:55 +0100 Subject: Parse integer / float types --- crates/ra_syntax/src/ast/generated.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 91f27fb26..74bf4d3cc 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -2697,7 +2697,11 @@ impl> PathTypeNode { } -impl<'a> PathType<'a> {} +impl<'a> PathType<'a> { + pub fn path(self) -> Option> { + super::child_opt(self) + } +} // PlaceholderPat #[derive(Debug, Clone, Copy,)] -- cgit v1.2.3 From 93ffbf80c632a7d38fc8bbdf6357bfd26a96a35a Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 23 Dec 2018 13:22:29 +0100 Subject: Make let statements kind of work --- crates/ra_syntax/src/ast/generated.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 74bf4d3cc..b15c4ef6f 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1561,6 +1561,10 @@ impl<'a> LetStmt<'a> { super::child_opt(self) } + pub fn type_ref(self) -> Option> { + super::child_opt(self) + } + pub fn initializer(self) -> Option> { super::child_opt(self) } -- cgit v1.2.3 From ef67581104eb00a0c199f0b2a3b558da8a6f90a2 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 23 Dec 2018 17:13:11 +0100 Subject: Resolve paths to defs (functions currently) during type inference --- crates/ra_syntax/src/ast/generated.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index b15c4ef6f..c73533861 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -3083,7 +3083,11 @@ impl> RetTypeNode { } -impl<'a> RetType<'a> {} +impl<'a> RetType<'a> { + pub fn type_ref(self) -> Option> { + super::child_opt(self) + } +} // ReturnExpr #[derive(Debug, Clone, Copy,)] -- cgit v1.2.3