using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
using UnityEditor;
using MCPForUnity.Editor.Helpers;
namespace MCPForUnity.Editor.Tools.MenuItems
{
///
/// Provides read/list/exists capabilities for Unity menu items with caching.
///
public static class MenuItemsReader
{
private static List _cached;
[InitializeOnLoadMethod]
private static void Build() => Refresh();
///
/// Returns the cached list, refreshing if necessary.
///
public static IReadOnlyList AllMenuItems() => _cached ??= Refresh();
///
/// Rebuilds the cached list from reflection.
///
private static List Refresh()
{
try
{
var methods = TypeCache.GetMethodsWithAttribute