//! Core types for the language server.

use std::collections::HashSet;

use eure::query::{TextFile, TextFileContent};

use eure_ls::queries::LspSemanticTokens;

/// LSP commands wrapping query structs generated by #[query] macro.
#[derive(Clone)]
pub enum CommandQuery {
    SemanticTokensFull(LspSemanticTokens),
}

/// A pending LSP request waiting for assets to be resolved.
pub struct PendingRequest {
    /// The command to execute.
    pub command: CommandQuery,
    /// Assets this request is waiting for.
    pub waiting_for: HashSet<TextFile>,
}

/// Request to read a file from disk.
pub struct IoRequest {
    pub file: TextFile,
}

/// Response from reading a file.
pub struct IoResponse {
    pub file: TextFile,
    /// Content or error from fetching the file.
    /// Network errors are wrapped in Arc for cheap cloning.
    pub result: Result<TextFileContent, anyhow::Error>,
}
