diff --git a/sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs b/sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs new file mode 100644 index 00000000..38681a09 --- /dev/null +++ b/sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using ClangSharp.Interop; +using static ClangSharp.Interop.CXCursorKind; + +namespace ClangSharp; + +public sealed class OverloadedDeclRef : Ref +{ + private readonly Lazy> _overloadedDecls; + + internal OverloadedDeclRef(CXCursor handle) : base(handle, CXCursor_OverloadedDeclRef) + { + _overloadedDecls = new Lazy>(() => { + uint num = Handle.NumOverloadedDecls; + return Enumerable.Range(0, (int)num) + .Select(i => Handle.GetOverloadedDecl((uint)i)) + .Select(c => TranslationUnit.GetOrCreate(c)) + .ToArray(); + }); + } + + public IEnumerable OverloadedDecls => _overloadedDecls.Value; +} diff --git a/sources/ClangSharp/Cursors/Refs/Ref.cs b/sources/ClangSharp/Cursors/Refs/Ref.cs index b4dfe8f6..8a8901fb 100644 --- a/sources/ClangSharp/Cursors/Refs/Ref.cs +++ b/sources/ClangSharp/Cursors/Refs/Ref.cs @@ -34,6 +34,12 @@ internal static new Ref Create(CXCursor handle) break; } + case CXCursor_OverloadedDeclRef: + { + result = new OverloadedDeclRef(handle); + break; + } + case CXCursor_ObjCSuperClassRef: case CXCursor_ObjCProtocolRef: case CXCursor_ObjCClassRef: @@ -42,7 +48,6 @@ internal static new Ref Create(CXCursor handle) case CXCursor_NamespaceRef: case CXCursor_MemberRef: case CXCursor_LabelRef: - case CXCursor_OverloadedDeclRef: case CXCursor_VariableRef: { result = new Ref(handle, handle.Kind);