mago_reflection/function_like/
return.rs

1use serde::Deserialize;
2use serde::Serialize;
3
4use mago_source::HasSource;
5use mago_source::SourceIdentifier;
6use mago_span::HasSpan;
7use mago_span::Span;
8
9use crate::r#type::TypeReflection;
10
11/// Represents the return type information for a function-like entity,
12/// including the type itself and its location in the source code.
13///
14/// This structure provides metadata about the return type of a function or method,
15/// allowing for introspection and reflection of its type and position.
16#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
17pub struct FunctionLikeReturnTypeReflection {
18    /// The return type of the function-like entity.
19    pub type_reflection: TypeReflection,
20
21    /// The location in the source code where the return type is specified.
22    pub span: Span,
23}
24
25impl HasSpan for FunctionLikeReturnTypeReflection {
26    /// Returns the span of the return type in the source code.
27    fn span(&self) -> Span {
28        self.span
29    }
30}
31
32impl HasSource for FunctionLikeReturnTypeReflection {
33    /// Returns the source identifier of the file containing this return type.
34    fn source(&self) -> SourceIdentifier {
35        self.span.source()
36    }
37}