df_ls_derive 0.3.0-rc.1

A language server for Dwarf Fortress RAW files
Documentation
#![forbid(unsafe_code)]
#![deny(clippy::all)]

//-------------------------------------------------------------
// NOTE: Code is this folder is not easy to understand.
// If you are not familiar with Derive Macro's please do not edit this file.
// To learn more see: https://doc.rust-lang.org/reference/procedural-macros.html
// Short: This is code that generates more code when `#[derive(...)]`
// is called. This is done at compile time.
//-------------------------------------------------------------

pub(crate) mod common;
mod referenceable;
mod token_deserialize;

use proc_macro::TokenStream;
use quote::quote;

#[proc_macro_derive(TokenDeserialize, attributes(token_de))]
pub fn token_deserialize_derive(input: TokenStream) -> TokenStream {
    // Construct a representation of Rust code as a syntax tree
    // that we can manipulate
    let ast = syn::parse(input).unwrap();

    // Build the trait implementation
    let impl_token_deserialize = token_deserialize::impl_token_deserialize_macro(&ast);
    let gen = quote! {
        #impl_token_deserialize
    };
    gen.into()
}

#[proc_macro_derive(Referenceable, attributes(referenceable))]
pub fn referenceable_derive(input: TokenStream) -> TokenStream {
    // Construct a representation of Rust code as a syntax tree
    // that we can manipulate
    let ast = syn::parse(input).unwrap();

    // Build the trait implementation
    let impl_referenceable = referenceable::impl_referenceable_macro(&ast);
    let gen = quote! {
        #impl_referenceable
    };
    gen.into()
}