from __future__ import annotations

import lldb
from renderers.jb_lldb_logging_manager import RENDER_LOG


class LLDBAnnotations:
    @staticmethod
    def set_annotation(value: lldb.SBValue, annotation_key: str, annotation_value: str):
        if hasattr(value, "SetAnnotation"):
            value.SetAnnotation(annotation_key, annotation_value)
        else:
            RENDER_LOG.warning("Cannot set annotation '%s' for value of type '%s': LLDB does not support annotations",
                               annotation_key, value.GetTypeName())

    @staticmethod
    def get_annotation(value: lldb.SBValue, annotation_key: str) -> str | None:
        if hasattr(value, "GetAnnotation"):
            return value.GetAnnotation(annotation_key)
        RENDER_LOG.warning("Cannot get annotation '%s' for value of type '%s': LLDB does not support annotations",
                           annotation_key, value.GetTypeName())
        return None
