mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
ZoneCodeGenerator: Extend reorder test to be able to specify first member and skip any members before to start reordering from a certain point
This commit is contained in:
parent
ce9d0d37de
commit
799a999a66
@ -14,12 +14,14 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
|||||||
{
|
{
|
||||||
private const string TypeNameToken = "typeName";
|
private const string TypeNameToken = "typeName";
|
||||||
private const string ReorderMemberNameToken = "member";
|
private const string ReorderMemberNameToken = "member";
|
||||||
|
private const string TokenFindFirst = "findFirst";
|
||||||
|
|
||||||
private static readonly TokenMatcher[] matchers =
|
private static readonly TokenMatcher[] matchers =
|
||||||
{
|
{
|
||||||
new MatcherLiteral("reorder"),
|
new MatcherLiteral("reorder"),
|
||||||
new MatcherGroupOptional(new MatcherTypename().WithName(TypeNameToken)),
|
new MatcherGroupOptional(new MatcherTypename().WithName(TypeNameToken)),
|
||||||
new MatcherLiteral(":"),
|
new MatcherLiteral(":"),
|
||||||
|
new MatcherGroupOptional(new MatcherLiteral(".", ".", ".").WithName(TokenFindFirst)),
|
||||||
new MatcherGroupLoop(MatcherGroupLoop.LoopMode.OneMultiple,
|
new MatcherGroupLoop(MatcherGroupLoop.LoopMode.OneMultiple,
|
||||||
new MatcherName().WithName(ReorderMemberNameToken)),
|
new MatcherName().WithName(ReorderMemberNameToken)),
|
||||||
new MatcherLiteral(";")
|
new MatcherLiteral(";")
|
||||||
@ -71,6 +73,23 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
|||||||
// Create a list that will be the sorted list at the end.
|
// Create a list that will be the sorted list at the end.
|
||||||
var sortedMembers = new List<MemberInformation>(memberPool.Count);
|
var sortedMembers = new List<MemberInformation>(memberPool.Count);
|
||||||
|
|
||||||
|
if (HasMatcherTokens(TokenFindFirst))
|
||||||
|
{
|
||||||
|
var firstMemberName = NextMatch(ReorderMemberNameToken);
|
||||||
|
var firstMember =
|
||||||
|
memberPool.FirstOrDefault(information => information.Member.Name.Equals(firstMemberName));
|
||||||
|
|
||||||
|
if (firstMember == null)
|
||||||
|
{
|
||||||
|
throw new TestFailedException(
|
||||||
|
$"Cannot find member with name '{firstMemberName}' in type '{typeToReorder.Type.FullName}'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstMemberIndex = memberPool.IndexOf(firstMember);
|
||||||
|
sortedMembers.AddRange(memberPool.GetRange(0, firstMemberIndex + 1));
|
||||||
|
memberPool.RemoveRange(0, firstMemberIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
string nextMemberName;
|
string nextMemberName;
|
||||||
while ((nextMemberName = NextMatch(ReorderMemberNameToken)) != null)
|
while ((nextMemberName = NextMatch(ReorderMemberNameToken)) != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user