From 59b75a0c3b934cd1e886b3d55c47b314661dc334 Mon Sep 17 00:00:00 2001 From: Steve Baer Date: Thu, 7 Sep 2023 17:57:58 -0700 Subject: [PATCH] add indexer support --- src/Parse/ParsedMember.cs | 21 +++++++++++++++++++++ src/Parse/SourceFileWalker.cs | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/src/Parse/ParsedMember.cs b/src/Parse/ParsedMember.cs index 20e79fe4..5cae9faa 100644 --- a/src/Parse/ParsedMember.cs +++ b/src/Parse/ParsedMember.cs @@ -425,6 +425,27 @@ public string Signature(bool forSorting) return signature; } } + { + IndexerDeclarationSyntax indexerMember = Member as IndexerDeclarationSyntax; + if (indexerMember != null) + { + var signature = new System.Text.StringBuilder(); + if (forSorting) + { + signature.Append($"{ClassPath}.this[{indexerMember.ParameterList.Parameters[0]}]"); + } + else + { + string proptype = $"{indexerMember.Type}"; + int index = proptype.LastIndexOf('.'); + if (index > 0) + proptype = proptype.Substring(index + 1); + signature.Append($"{prefix}{proptype} this[{indexerMember.ParameterList.Parameters[0]}]"); + } + return signature.ToString(); + + } + } throw new NotImplementedException(); } diff --git a/src/Parse/SourceFileWalker.cs b/src/Parse/SourceFileWalker.cs index a3698624..58430494 100644 --- a/src/Parse/SourceFileWalker.cs +++ b/src/Parse/SourceFileWalker.cs @@ -76,6 +76,13 @@ public override void VisitMethodDeclaration(MethodDeclarationSyntax node) base.VisitMethodDeclaration(node); } + public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node) + { + var docComment = node.GetLeadingTrivia().Select(i => i.GetStructure()).OfType().FirstOrDefault(); + _parsedMembers.Add(new ParsedMember(node, docComment, _usingDirectives)); + base.VisitIndexerDeclaration(node); + } + public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) { var docComment = node.GetLeadingTrivia().Select(i => i.GetStructure()).OfType().FirstOrDefault();