Skip to content

Commit

Permalink
Merge pull request #491 from joelverhagen/sort-partial
Browse files Browse the repository at this point in the history
Sort partial definitions before accepting them
  • Loading branch information
yanghuan committed Jan 18, 2024
2 parents a694e83 + 8d24086 commit 4acae76
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions CSharp.lua/LuaSyntaxGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ public int CompareTo(PartialTypeDeclaration other) {
string filePath = CompilationUnit.FilePath;
string otherFilePath = other.CompilationUnit.FilePath;

if (filePath.Contains(otherFilePath)) {
return 1;
int c = filePath.CompareTo(otherFilePath);
if (c != 0) {
return c;
}

if (otherFilePath.Contains(filePath)) {
return -1;
}
return other.Node.Members.Count.CompareTo(Node.Members.Count);
}
}
Expand Down Expand Up @@ -513,9 +511,10 @@ private void CheckPartialTypes() {
var types = partialTypes_.Values.ToArray();
partialTypes_.Clear();
foreach (var typeDeclarations in types) {
var major = typeDeclarations.Min();
var sortedTypeDeclarations = typeDeclarations.OrderBy(x => x).ToList();
var major = sortedTypeDeclarations[0];
var transform = new LuaSyntaxNodeTransform(this, null);
transform.AcceptPartialType(major, typeDeclarations);
transform.AcceptPartialType(major, sortedTypeDeclarations);
}
}
}
Expand Down

0 comments on commit 4acae76

Please sign in to comment.