//! 语法关键字字典数据
//!
//! 各编程语言的关键字列表、原始类型列表、注释前缀等静态数据。
//! 从 `highlight.rs` 提取以降低主文件复杂度。

/// Rust 关键字（控制流/定义关键字）
pub const RUST_KEYWORDS: &[&str] = &[
    "fn", "let", "mut", "pub", "use", "mod", "struct", "enum", "impl", "trait", "for", "while",
    "loop", "if", "else", "match", "return", "self", "Self", "where", "async", "await", "move",
    "ref", "type", "const", "static", "crate", "super", "as", "in", "true", "false", "unsafe",
    "extern", "dyn", "abstract", "become", "box", "do", "final", "macro", "override", "priv",
    "typeof", "unsized", "virtual", "yield", "union", "break", "continue",
];

/// Rust 原始类型
pub const RUST_PRIMITIVE_TYPES: &[&str] = &[
    "i8", "i16", "i32", "i64", "i128", "isize", "u8", "u16", "u32", "u64", "u128", "usize", "f32",
    "f64", "bool", "char", "str",
];

/// Python 关键字
pub const PYTHON_KEYWORDS: &[&str] = &[
    "def", "class", "return", "if", "elif", "else", "for", "while", "import", "from", "as", "with",
    "try", "except", "finally", "raise", "pass", "break", "continue", "yield", "lambda", "and",
    "or", "not", "in", "is", "True", "False", "None", "global", "nonlocal", "assert", "del",
    "async", "await", "self", "print",
];

/// JavaScript / TypeScript 关键字
pub const JS_TS_KEYWORDS: &[&str] = &[
    "function",
    "const",
    "let",
    "var",
    "return",
    "if",
    "else",
    "for",
    "while",
    "class",
    "new",
    "this",
    "import",
    "export",
    "from",
    "default",
    "async",
    "await",
    "try",
    "catch",
    "finally",
    "throw",
    "typeof",
    "instanceof",
    "true",
    "false",
    "null",
    "undefined",
    "of",
    "in",
    "switch",
    "case",
];

/// Go 关键字
pub const GO_KEYWORDS: &[&str] = &[
    "func",
    "package",
    "import",
    "return",
    "if",
    "else",
    "for",
    "range",
    "struct",
    "interface",
    "type",
    "var",
    "const",
    "defer",
    "go",
    "chan",
    "select",
    "case",
    "switch",
    "default",
    "break",
    "continue",
    "map",
    "true",
    "false",
    "nil",
    "make",
    "append",
    "len",
    "cap",
];

/// Go 原始类型
pub const GO_PRIMITIVE_TYPES: &[&str] = &[
    "int",
    "int8",
    "int16",
    "int32",
    "int64",
    "uint",
    "uint8",
    "uint16",
    "uint32",
    "uint64",
    "uintptr",
    "float32",
    "float64",
    "complex64",
    "complex128",
    "bool",
    "byte",
    "rune",
    "string",
    "error",
    "any",
];

/// Go 显式类型名（标准库常见类型）
pub const GO_TYPE_NAMES: &[&str] = &[
    "Reader",
    "Writer",
    "Closer",
    "ReadWriter",
    "ReadCloser",
    "WriteCloser",
    "ReadWriteCloser",
    "Seeker",
    "Context",
    "Error",
    "Stringer",
    "Mutex",
    "RWMutex",
    "WaitGroup",
    "Once",
    "Pool",
    "Map",
    "Duration",
    "Time",
    "Timer",
    "Ticker",
    "Buffer",
    "Builder",
    "Request",
    "Response",
    "ResponseWriter",
    "Handler",
    "HandlerFunc",
    "Server",
    "Client",
    "Transport",
    "File",
    "FileInfo",
    "FileMode",
    "Decoder",
    "Encoder",
    "Marshaler",
    "Unmarshaler",
    "Logger",
    "Flag",
    "Regexp",
    "Conn",
    "Listener",
    "Addr",
    "Scanner",
    "Token",
    "Type",
    "Value",
    "Kind",
    "Cmd",
    "Signal",
];

/// Java / Kotlin 关键字
pub const JAVA_KOTLIN_KEYWORDS: &[&str] = &[
    "public",
    "private",
    "protected",
    "class",
    "interface",
    "extends",
    "implements",
    "return",
    "if",
    "else",
    "for",
    "while",
    "new",
    "this",
    "import",
    "package",
    "static",
    "final",
    "void",
    "int",
    "String",
    "boolean",
    "true",
    "false",
    "null",
    "try",
    "catch",
    "throw",
    "throws",
    "fun",
    "val",
    "var",
    "when",
    "object",
    "companion",
];

/// Shell 关键字（Bash/Zsh/sh + Go/Cargo 命令）
pub const SHELL_KEYWORDS: &[&str] = &[
    "if",
    "then",
    "else",
    "elif",
    "fi",
    "for",
    "while",
    "do",
    "done",
    "case",
    "esac",
    "function",
    "return",
    "exit",
    "echo",
    "export",
    "local",
    "readonly",
    "set",
    "unset",
    "shift",
    "source",
    "in",
    "true",
    "false",
    "read",
    "declare",
    "typeset",
    "trap",
    "eval",
    "exec",
    "test",
    "select",
    "until",
    "break",
    "continue",
    "printf",
    // Go 命令
    "go",
    "build",
    "run",
    "test",
    "fmt",
    "vet",
    "mod",
    "get",
    "install",
    "clean",
    "doc",
    "list",
    "version",
    "env",
    "generate",
    "tool",
    "proxy",
    "GOPATH",
    "GOROOT",
    "GOBIN",
    "GOMODCACHE",
    "GOPROXY",
    "GOSUMDB",
    // Cargo 命令
    "cargo",
    "new",
    "init",
    "add",
    "remove",
    "update",
    "check",
    "clippy",
    "rustfmt",
    "rustc",
    "rustup",
    "publish",
    "uninstall",
    "search",
    "tree",
    "locate_project",
    "metadata",
    "audit",
    "watch",
    "expand",
];

/// C / C++ 关键字
pub const C_CPP_KEYWORDS: &[&str] = &[
    "int",
    "char",
    "float",
    "double",
    "void",
    "long",
    "short",
    "unsigned",
    "signed",
    "const",
    "static",
    "extern",
    "struct",
    "union",
    "enum",
    "typedef",
    "sizeof",
    "return",
    "if",
    "else",
    "for",
    "while",
    "do",
    "switch",
    "case",
    "break",
    "continue",
    "default",
    "goto",
    "auto",
    "register",
    "volatile",
    "class",
    "public",
    "private",
    "protected",
    "virtual",
    "override",
    "template",
    "namespace",
    "using",
    "new",
    "delete",
    "try",
    "catch",
    "throw",
    "nullptr",
    "true",
    "false",
    "this",
    "include",
    "define",
    "ifdef",
    "ifndef",
    "endif",
];

/// SQL 关键字（大写 + 小写）
pub const SQL_KEYWORDS: &[&str] = &[
    "SELECT",
    "FROM",
    "WHERE",
    "INSERT",
    "UPDATE",
    "DELETE",
    "CREATE",
    "DROP",
    "ALTER",
    "TABLE",
    "INDEX",
    "INTO",
    "VALUES",
    "SET",
    "AND",
    "OR",
    "NOT",
    "NULL",
    "JOIN",
    "LEFT",
    "RIGHT",
    "INNER",
    "OUTER",
    "ON",
    "GROUP",
    "BY",
    "ORDER",
    "ASC",
    "DESC",
    "HAVING",
    "LIMIT",
    "OFFSET",
    "UNION",
    "AS",
    "DISTINCT",
    "COUNT",
    "SUM",
    "AVG",
    "MIN",
    "MAX",
    "LIKE",
    "IN",
    "BETWEEN",
    "EXISTS",
    "CASE",
    "WHEN",
    "THEN",
    "ELSE",
    "END",
    "BEGIN",
    "COMMIT",
    "ROLLBACK",
    "PRIMARY",
    "KEY",
    "FOREIGN",
    "REFERENCES",
    "select",
    "from",
    "where",
    "insert",
    "update",
    "delete",
    "create",
    "drop",
    "alter",
    "table",
    "index",
    "into",
    "values",
    "set",
    "and",
    "or",
    "not",
    "null",
    "join",
    "left",
    "right",
    "inner",
    "outer",
    "on",
    "group",
    "by",
    "order",
    "asc",
    "desc",
    "having",
    "limit",
    "offset",
    "union",
    "as",
    "distinct",
    "count",
    "sum",
    "avg",
    "min",
    "max",
    "like",
    "in",
    "between",
    "exists",
    "case",
    "when",
    "then",
    "else",
    "end",
    "begin",
    "commit",
    "rollback",
    "primary",
    "key",
    "foreign",
    "references",
];

/// YAML 关键字
pub const YAML_KEYWORDS: &[&str] = &["true", "false", "null", "yes", "no", "on", "off"];

/// TOML 关键字（含 Cargo.toml 常用配置项）
pub const TOML_KEYWORDS: &[&str] = &[
    "true",
    "false",
    // Cargo.toml 常用
    "name",
    "version",
    "edition",
    "authors",
    "dependencies",
    "dev-dependencies",
    "build-dependencies",
    "features",
    "workspace",
    "members",
    "exclude",
    "include",
    "path",
    "git",
    "branch",
    "tag",
    "rev",
    "package",
    "lib",
    "bin",
    "example",
    "test",
    "bench",
    "doc",
    "profile",
    "release",
    "debug",
    "opt-level",
    "lto",
    "codegen-units",
    "panic",
    "strip",
    "default",
    "optional",
    // 常见配置项
    "repository",
    "homepage",
    "documentation",
    "license",
    "license-file",
    "keywords",
    "categories",
    "readme",
    "description",
    "resolver",
];

/// CSS / SCSS / Less 关键字
pub const CSS_KEYWORDS: &[&str] = &[
    "color",
    "background",
    "border",
    "margin",
    "padding",
    "display",
    "position",
    "width",
    "height",
    "font",
    "text",
    "flex",
    "grid",
    "align",
    "justify",
    "important",
    "none",
    "auto",
    "inherit",
    "initial",
    "unset",
];

/// Dockerfile 关键字
pub const DOCKERFILE_KEYWORDS: &[&str] = &[
    "FROM",
    "RUN",
    "CMD",
    "LABEL",
    "EXPOSE",
    "ENV",
    "ADD",
    "COPY",
    "ENTRYPOINT",
    "VOLUME",
    "USER",
    "WORKDIR",
    "ARG",
    "ONBUILD",
    "STOPSIGNAL",
    "HEALTHCHECK",
    "SHELL",
    "AS",
];

/// Ruby 关键字
pub const RUBY_KEYWORDS: &[&str] = &[
    "def", "end", "class", "module", "if", "elsif", "else", "unless", "while", "until", "for",
    "do", "begin", "rescue", "ensure", "raise", "return", "yield", "require", "include", "attr",
    "self", "true", "false", "nil", "puts", "print",
];

/// 通用后备关键字（未知语言使用）
pub const FALLBACK_KEYWORDS: &[&str] = &[
    "fn", "function", "def", "class", "return", "if", "else", "for", "while", "import", "export",
    "const", "let", "var", "true", "false", "null", "nil", "None", "self", "this",
];

/// 根据语言标识返回关键字列表。
pub fn keywords_for_lang(lang: &str) -> &'static [&'static str] {
    match lang {
        "rust" | "rs" => RUST_KEYWORDS,
        "python" | "py" => PYTHON_KEYWORDS,
        "javascript" | "js" | "typescript" | "ts" | "jsx" | "tsx" => JS_TS_KEYWORDS,
        "go" | "golang" => GO_KEYWORDS,
        "java" | "kotlin" | "kt" => JAVA_KOTLIN_KEYWORDS,
        "sh" | "bash" | "zsh" | "shell" => SHELL_KEYWORDS,
        "c" | "cpp" | "c++" | "h" | "hpp" => C_CPP_KEYWORDS,
        "sql" => SQL_KEYWORDS,
        "yaml" | "yml" => YAML_KEYWORDS,
        "toml" => TOML_KEYWORDS,
        "css" | "scss" | "less" => CSS_KEYWORDS,
        "dockerfile" | "docker" => DOCKERFILE_KEYWORDS,
        "ruby" | "rb" => RUBY_KEYWORDS,
        _ => FALLBACK_KEYWORDS,
    }
}

/// 根据语言标识返回原始类型列表。
pub fn primitive_types_for_lang(lang: &str) -> &'static [&'static str] {
    match lang {
        "rust" | "rs" => RUST_PRIMITIVE_TYPES,
        "go" | "golang" => GO_PRIMITIVE_TYPES,
        _ => &[],
    }
}

/// 根据语言标识返回 Go 类型名列表（仅 Go 语言有效）。
pub fn go_type_names_for_lang(lang: &str) -> &'static [&'static str] {
    if matches!(lang, "go" | "golang") {
        GO_TYPE_NAMES
    } else {
        &[]
    }
}

/// 根据语言标识返回注释前缀。
pub fn comment_prefix_for_lang(lang: &str) -> &'static str {
    match lang {
        "python" | "py" | "sh" | "bash" | "zsh" | "shell" | "ruby" | "rb" | "yaml" | "yml"
        | "toml" | "dockerfile" | "docker" => "#",
        "sql" => "--",
        "css" | "scss" | "less" => "/*",
        _ => "//",
    }
}
