diff options
| author | Yong He <yonghe@outlook.com> | 2025-06-17 21:36:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-17 21:36:10 -0700 |
| commit | 4d517794eaac7dfe6196e9a36d709d66c5720492 (patch) | |
| tree | a7e65d8307b4e25f2a7bafcc9a2de1666c8b689e /source/compiler-core/slang-json-value.h | |
| parent | b9799e6137fb1d173cefd823521bb70b09ac435a (diff) | |
LanguageServer: Enhance auto completion for override. (#7465)
* Add additional completion keywords.
* LanguageServer: Enhance auto completion for `override`.
Diffstat (limited to 'source/compiler-core/slang-json-value.h')
| -rw-r--r-- | source/compiler-core/slang-json-value.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/compiler-core/slang-json-value.h b/source/compiler-core/slang-json-value.h index d9b17f1d5..ae0123d30 100644 --- a/source/compiler-core/slang-json-value.h +++ b/source/compiler-core/slang-json-value.h @@ -8,6 +8,8 @@ #include "slang-json-parser.h" #include "slang-source-loc.h" +#include <optional> + namespace Slang { @@ -439,6 +441,39 @@ protected: List<JSONKeyValue> m_objectValues; }; +template<typename T> +class JSONOptional +{ +public: + bool hasValue = false; + T value; + JSONOptional() = default; + JSONOptional(std::nullopt_t) {} + JSONOptional(const T& inValue) + : hasValue(true), value(inValue) + { + } +}; + +template<typename T> +struct GetRttiInfo<JSONOptional<T>> +{ + static const OptionalRttiInfo _make() + { + OptionalRttiInfo info; + info.init<JSONOptional<T>>(RttiInfo::Kind::Optional); + info.m_elementType = GetRttiInfo<T>::get(); + info.m_valueOffset = (uint32_t)offsetof(JSONOptional<T>, value); + return info; + } + static const RttiInfo* get() + { + static const OptionalRttiInfo g_info = _make(); + return &g_info; + } +}; + + class JSONBuilder : public JSONListener { public: |
