diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-30 19:05:09 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-30 19:05:09 +0000 |
commit | 998088876d91b7602068f8209a61918d4a8a8fe7 (patch) | |
tree | 12837dc698294e3673496130372359ef6e6c3ef8 /crates/ra_syntax | |
parent | ce3173469c9dc9c59de903dfe33a6156168d0325 (diff) | |
parent | 4d17658940ec73554dfef799b22e8829ab5ad61a (diff) |
Merge #2133
2133: Document match_ast! and use it in call_info r=matklad a=kjeremy
Suggested by @matklad in https://github.com/rust-analyzer/rust-analyzer/pull/2129#discussion_r340708660
Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index c315ba552..5dcb6a95a 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -160,6 +160,20 @@ impl SourceFile { | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | /// Matches a `SyntaxNode` against an `ast` type. | ||
164 | /// | ||
165 | /// # Example: | ||
166 | /// | ||
167 | /// ```ignore | ||
168 | /// match_ast! { | ||
169 | /// match node { | ||
170 | /// ast::CallExpr(it) => { ... }, | ||
171 | /// ast::MethodCallExpr(it) => { ... }, | ||
172 | /// ast::MacroCall(it) => { ... }, | ||
173 | /// _ => None, | ||
174 | /// } | ||
175 | /// } | ||
176 | /// ``` | ||
163 | #[macro_export] | 177 | #[macro_export] |
164 | macro_rules! match_ast { | 178 | macro_rules! match_ast { |
165 | (match $node:ident { | 179 | (match $node:ident { |