UNPKG

@macroforge/mcp-server

Version:

MCP server for Macroforge documentation and code analysis

35 lines (28 loc) • 1.09 kB
## Parsing Input Use `parse_ts_macro_input!` to convert the token stream: Rust ``` use macroforge_ts::ts_syn::{Data, DeriveInput, parse_ts_macro_input}; #[ts_macro_derive(MyMacro)] pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {     let input = parse_ts_macro_input!(input as DeriveInput);     match &input.data {         Data::Class(class) => {             let class_name = input.name();             let fields = class.fields();             // ...         }         Data::Interface(interface) => {             // Handle interfaces         }         Data::Enum(_) => {             // Handle enums (if supported)         }         Data::TypeAlias(_) => {             // Handle type aliases (if supported)         }     } } ``` When the input cannot be parsed, `parse_ts_macro_input!` returns early with a `MacroforgeError`, so the function's error type must accept one.