-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
144 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using EdgeDB.QueryNodes; | ||
|
||
namespace EdgeDB; | ||
|
||
internal static class NodeReducer | ||
{ | ||
public static void Apply(QueryStringWriter writer, QueryGlobal global, Action<QueryGlobal, QueryStringWriter, Action<QueryNode>?> compile) | ||
{ | ||
if (!writer.TryGetLabeled(global.Name, out var markers)) | ||
return; | ||
|
||
// general rules for reducing nodes: | ||
// - Shapes are not included in function arguments | ||
|
||
foreach (var marker in markers) | ||
{ | ||
Action<QueryNode>? modifier = marker switch | ||
{ | ||
_ when marker.Parent?.Type is MarkerType.Function => ApplyShapeReducer, | ||
_ => null | ||
}; | ||
|
||
marker.Replace(writer => compile(global, writer, modifier)); | ||
} | ||
} | ||
|
||
private static void ApplyShapeReducer(QueryNode node) | ||
{ | ||
if (node.Context is SelectContext sctx) | ||
sctx.IncludeShape = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ public enum MarkerType | |
{ | ||
Global, | ||
Function, | ||
|
||
Shape | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters