"""Shared LSP types/constants with robust import handling."""

from __future__ import annotations

try:
    from lsprotocol.types import (  # type: ignore
        TEXT_DOCUMENT_CODE_ACTION,
        TEXT_DOCUMENT_COMPLETION,
        TEXT_DOCUMENT_DEFINITION,
        TEXT_DOCUMENT_DIAGNOSTIC,
        TEXT_DOCUMENT_DID_CHANGE,
        TEXT_DOCUMENT_DID_CLOSE,
        TEXT_DOCUMENT_DID_OPEN,
        TEXT_DOCUMENT_DID_SAVE,
        TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT,
        TEXT_DOCUMENT_DOCUMENT_LINK,
        TEXT_DOCUMENT_DOCUMENT_SYMBOL,
        TEXT_DOCUMENT_FOLDING_RANGE,
        TEXT_DOCUMENT_FORMATTING,
        TEXT_DOCUMENT_HOVER,
        TEXT_DOCUMENT_PREPARE_RENAME,
        TEXT_DOCUMENT_RANGE_FORMATTING,
        TEXT_DOCUMENT_REFERENCES,
        TEXT_DOCUMENT_RENAME,
        TEXT_DOCUMENT_SELECTION_RANGE,
        TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
        TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
        TEXT_DOCUMENT_SIGNATURE_HELP,
        WORKSPACE_DID_CHANGE_CONFIGURATION,
        WORKSPACE_DID_CHANGE_WATCHED_FILES,
        WORKSPACE_SYMBOL,
        CodeAction,
        CodeActionOptions,
        CodeActionParams,
        CompletionList,
        CompletionOptions,
        CompletionParams,
        DefinitionParams,
        DiagnosticOptions,
        DidChangeConfigurationParams,
        DidChangeTextDocumentParams,
        DidChangeWatchedFilesParams,
        DidCloseTextDocumentParams,
        DidOpenTextDocumentParams,
        DidSaveTextDocumentParams,
        DocumentDiagnosticParams,
        DocumentDiagnosticReportKind,
        DocumentFormattingParams,
        DocumentHighlight,
        DocumentHighlightParams,
        DocumentLink,
        DocumentLinkParams,
        DocumentRangeFormattingParams,
        DocumentSymbol,
        DocumentSymbolParams,
        FoldingRange,
        FoldingRangeParams,
        FullDocumentDiagnosticReport,
        Hover,
        HoverParams,
        InitializeParams,
        Location,
        PrepareRenameParams,
        Range,
        ReferenceParams,
        RelatedFullDocumentDiagnosticReport,
        RenameParams,
        SelectionRange,
        SelectionRangeParams,
        SemanticTokens,
        SemanticTokensParams,
        SemanticTokensRangeParams,
        SemanticTokensRegistrationOptions,
        SignatureHelp,
        SignatureHelpOptions,
        SignatureHelpParams,
        SymbolInformation,
        TextEdit,
        WorkspaceEdit,
        WorkspaceFoldersServerCapabilities,
        WorkspaceSymbolParams,
    )
except ImportError:  # pragma: no cover - exercised in environments without lsprotocol
    import importlib
    import site
    import sys

    for path in reversed(site.getsitepackages()):
        if path in sys.path:
            sys.path.remove(path)
        sys.path.insert(0, path)
    sys.modules.pop("lsprotocol", None)
    sys.modules.pop("lsprotocol.types", None)
    importlib.invalidate_caches()
    from lsprotocol.types import (  # type: ignore
        TEXT_DOCUMENT_CODE_ACTION,
        TEXT_DOCUMENT_COMPLETION,
        TEXT_DOCUMENT_DEFINITION,
        TEXT_DOCUMENT_DIAGNOSTIC,
        TEXT_DOCUMENT_DID_CHANGE,
        TEXT_DOCUMENT_DID_CLOSE,
        TEXT_DOCUMENT_DID_OPEN,
        TEXT_DOCUMENT_DID_SAVE,
        TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT,
        TEXT_DOCUMENT_DOCUMENT_LINK,
        TEXT_DOCUMENT_DOCUMENT_SYMBOL,
        TEXT_DOCUMENT_FOLDING_RANGE,
        TEXT_DOCUMENT_FORMATTING,
        TEXT_DOCUMENT_HOVER,
        TEXT_DOCUMENT_PREPARE_RENAME,
        TEXT_DOCUMENT_RANGE_FORMATTING,
        TEXT_DOCUMENT_REFERENCES,
        TEXT_DOCUMENT_RENAME,
        TEXT_DOCUMENT_SELECTION_RANGE,
        TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
        TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
        TEXT_DOCUMENT_SIGNATURE_HELP,
        WORKSPACE_DID_CHANGE_CONFIGURATION,
        WORKSPACE_DID_CHANGE_WATCHED_FILES,
        WORKSPACE_SYMBOL,
        CodeAction,
        CodeActionOptions,
        CodeActionParams,
        CompletionList,
        CompletionOptions,
        CompletionParams,
        DefinitionParams,
        DiagnosticOptions,
        DidChangeConfigurationParams,
        DidChangeTextDocumentParams,
        DidChangeWatchedFilesParams,
        DidCloseTextDocumentParams,
        DidOpenTextDocumentParams,
        DidSaveTextDocumentParams,
        DocumentDiagnosticParams,
        DocumentDiagnosticReportKind,
        DocumentFormattingParams,
        DocumentHighlight,
        DocumentHighlightParams,
        DocumentLink,
        DocumentLinkParams,
        DocumentRangeFormattingParams,
        DocumentSymbol,
        DocumentSymbolParams,
        FoldingRange,
        FoldingRangeParams,
        FullDocumentDiagnosticReport,
        Hover,
        HoverParams,
        InitializeParams,
        Location,
        PrepareRenameParams,
        Range,
        ReferenceParams,
        RelatedFullDocumentDiagnosticReport,
        RenameParams,
        SelectionRange,
        SelectionRangeParams,
        SemanticTokens,
        SemanticTokensParams,
        SemanticTokensRangeParams,
        SemanticTokensRegistrationOptions,
        SignatureHelp,
        SignatureHelpOptions,
        SignatureHelpParams,
        SymbolInformation,
        TextEdit,
        WorkspaceEdit,
        WorkspaceFoldersServerCapabilities,
        WorkspaceSymbolParams,
    )

YARAAST_RUNTIME_STATUS = "yaraast/status"

__all__ = [
    "TEXT_DOCUMENT_CODE_ACTION",
    "TEXT_DOCUMENT_COMPLETION",
    "TEXT_DOCUMENT_DEFINITION",
    "TEXT_DOCUMENT_DIAGNOSTIC",
    "TEXT_DOCUMENT_DID_CHANGE",
    "TEXT_DOCUMENT_DID_CLOSE",
    "TEXT_DOCUMENT_DID_OPEN",
    "TEXT_DOCUMENT_DID_SAVE",
    "TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT",
    "TEXT_DOCUMENT_DOCUMENT_LINK",
    "TEXT_DOCUMENT_DOCUMENT_SYMBOL",
    "TEXT_DOCUMENT_FOLDING_RANGE",
    "TEXT_DOCUMENT_FORMATTING",
    "TEXT_DOCUMENT_HOVER",
    "TEXT_DOCUMENT_PREPARE_RENAME",
    "TEXT_DOCUMENT_RANGE_FORMATTING",
    "TEXT_DOCUMENT_REFERENCES",
    "TEXT_DOCUMENT_RENAME",
    "TEXT_DOCUMENT_SELECTION_RANGE",
    "TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL",
    "TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE",
    "TEXT_DOCUMENT_SIGNATURE_HELP",
    "WORKSPACE_DID_CHANGE_CONFIGURATION",
    "WORKSPACE_DID_CHANGE_WATCHED_FILES",
    "WORKSPACE_SYMBOL",
    "YARAAST_RUNTIME_STATUS",
    "CodeAction",
    "CodeActionOptions",
    "CodeActionParams",
    "CompletionList",
    "CompletionOptions",
    "CompletionParams",
    "DefinitionParams",
    "DiagnosticOptions",
    "DidChangeConfigurationParams",
    "DidChangeTextDocumentParams",
    "DidChangeWatchedFilesParams",
    "DidCloseTextDocumentParams",
    "DidOpenTextDocumentParams",
    "DidSaveTextDocumentParams",
    "DocumentDiagnosticParams",
    "DocumentDiagnosticReportKind",
    "DocumentFormattingParams",
    "DocumentHighlight",
    "DocumentHighlightParams",
    "DocumentLink",
    "DocumentLinkParams",
    "DocumentRangeFormattingParams",
    "DocumentSymbol",
    "DocumentSymbolParams",
    "FoldingRange",
    "FoldingRangeParams",
    "FullDocumentDiagnosticReport",
    "Hover",
    "HoverParams",
    "InitializeParams",
    "Location",
    "PrepareRenameParams",
    "Range",
    "ReferenceParams",
    "RelatedFullDocumentDiagnosticReport",
    "RenameParams",
    "SelectionRange",
    "SelectionRangeParams",
    "SemanticTokens",
    "SemanticTokensParams",
    "SemanticTokensRangeParams",
    "SemanticTokensRegistrationOptions",
    "SignatureHelp",
    "SignatureHelpOptions",
    "SignatureHelpParams",
    "SymbolInformation",
    "TextEdit",
    "WorkspaceEdit",
    "WorkspaceFoldersServerCapabilities",
    "WorkspaceSymbolParams",
]
