Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OverloadedDeclRef #526

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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<IEnumerable<Decl>> _overloadedDecls;

internal OverloadedDeclRef(CXCursor handle) : base(handle, CXCursor_OverloadedDeclRef)
{
_overloadedDecls = new Lazy<IEnumerable<Decl>>(() => {
uint num = Handle.NumOverloadedDecls;
return Enumerable.Range(0, (int)num)
.Select(i => Handle.GetOverloadedDecl((uint)i))
.Select(c => TranslationUnit.GetOrCreate<Decl>(c))
.ToArray();
});
}

public IEnumerable<Decl> OverloadedDecls => _overloadedDecls.Value;

tannergooding marked this conversation as resolved.
Show resolved Hide resolved
}
7 changes: 6 additions & 1 deletion sources/ClangSharp/Cursors/Refs/Ref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down