Skip to content

Commit e1c6712

Browse files
committed
Clarify ElmTreeWalker pattern matching logic
Added comments to explain the behavior and intent of the pattern matching logic in the `ElmTreeWalker` creation within the `MissingResultTypeSpecifierCorrector` class. The comments highlight the importance of processing order and why a switch expression is not suitable. These changes improve code readability and help prevent unintended modifications that could disrupt functionality.
1 parent cd4edcd commit e1c6712

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Cql/Cql.Compiler/Preprocessing/MissingResultTypeSpecifierCorrector.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ internal class MissingResultTypeSpecifierCorrector(ILogger<MissingResultTypeSpec
1919
{
2020
private readonly ElmTreeWalker _walker = ElmTreeWalker.Create((self, node) =>
2121
{
22+
// DO NOT turn this into a switch expression.
23+
// It is possible to match multiple patterns in one node, e.g.
24+
// Element with resultTypeName then Query with ListTypeSpecifier
25+
// The order of these blocks matters too, starting with the most general ones first.
26+
2227
{
2328
// If an Element has a resultTypeName but no resultTypeSpecifier, set resultTypeSpecifier to a NamedTypeSpecifier with the name from resultTypeName
2429
if (node is Element { resultTypeSpecifier: null, resultTypeName: { } resultTypeName } element)

0 commit comments

Comments
 (0)