Skip to content

Commit 663c701

Browse files
committed
Changed method for retrieving parser rules
The previous approach resulted in mismatching rule names at times. This fixes that.
1 parent 9939b58 commit 663c701

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Utilities/Grammar/Scanner.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
using System.IO;
4242
using System.Linq;
4343
using System.Reflection;
44-
44+
using System.Runtime.InteropServices;
4545
using Antlr4.Runtime;
4646

4747
using JetBrains.Annotations;
@@ -245,9 +245,9 @@ public IEnumerable<string> GetParserRulesForGrammarParser([NotNull] Type parserT
245245
{
246246
if (parserType is null) throw new ArgumentNullException(nameof(parserType));
247247

248-
var methods = parserType.GetMethods()
249-
.Where(m => m.GetCustomAttributes(typeof(RuleVersionAttribute), false).Length > 0);
250-
return from method in methods select method.Name;
248+
var prop = parserType.GetField("ruleNames", BindingFlags.Public | BindingFlags.Static);
249+
var value = prop.GetValue(null) as string[];
250+
return value;
251251
}
252252

253253
private List<GrammarReference> FindGrammars([NotNull] string path, string name = null)

0 commit comments

Comments
 (0)