ink_analyzer_ir/
topic.rs

1//! ink! topic IR.
2
3use ra_ap_syntax::ast;
4
5/// An ink! topic.
6#[ink_analyzer_macro::entity(arg_kind = Topic)]
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub struct Topic {
9    // ASTNode type.
10    ast: ast::RecordField,
11}
12
13impl Topic {
14    impl_pub_ast_type_getter!(field, RecordField);
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20    use crate::test_utils::*;
21    use crate::traits::InkEntity;
22    use ra_ap_syntax::AstNode;
23    use test_utils::quote_as_str;
24
25    #[test]
26    fn cast_works() {
27        let node: ast::RecordField = parse_first_ast_node_of_type(quote_as_str! {
28            pub struct MyEvent {
29                #[ink(topic)]
30                value: i32,
31            }
32        });
33
34        let topic = Topic::cast(node.syntax().clone()).unwrap();
35
36        // `field` item exists.
37        assert!(topic.field().is_some());
38    }
39}