ITupleNode signature change

This commit is contained in:
Michael Schimmel
2026-01-06 11:37:18 +01:00
parent 264314cd93
commit 40ed51aef8
23 changed files with 340 additions and 270 deletions
+19 -14
View File
@@ -13,14 +13,15 @@ uses
type
// --- Abstract List Base ---
// Implements IReorderable to support drag & drop reordering within the virtual tree
TNodeListHandler<T: IAstNode> = class(TBaseNodeHandler<INodeList<T>>, IReorderable)
// Implements IReorderable to support drag & drop reordering within the virtual tree.
// Now operates on the untyped ITupleNode.
TNodeListHandler = class(TBaseNodeHandler<ITupleNode>, IReorderable)
protected
FChildNodes: TList<TAstViewNode>;
function GetOrientation: TLayoutOrientation; virtual; abstract;
function GetAlignment: TLayoutAlignment; virtual;
public
constructor Create(const ANode: INodeList<T>);
constructor Create(const ANode: ITupleNode);
destructor Destroy; override;
procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override; abstract;
@@ -32,32 +33,33 @@ type
implementation
{ TNodeListHandler<T> }
{ TNodeListHandler }
constructor TNodeListHandler<T>.Create(const ANode: INodeList<T>);
constructor TNodeListHandler.Create(const ANode: ITupleNode);
begin
inherited Create(ANode);
FChildNodes := TList<TAstViewNode>.Create;
end;
destructor TNodeListHandler<T>.Destroy;
destructor TNodeListHandler.Destroy;
begin
FChildNodes.Free;
inherited;
end;
function TNodeListHandler<T>.GetAlignment: TLayoutAlignment;
function TNodeListHandler.GetAlignment: TLayoutAlignment;
begin
Result := TLayoutAlignment.laCenter;
end;
procedure TNodeListHandler<T>.BuildUI(OwnerNode: TAstViewNode);
procedure TNodeListHandler.BuildUI(OwnerNode: TAstViewNode);
var
visu: IAstVisualizer;
i: Integer;
childView: TAstViewNode;
openTok, closeTok, sep: string;
listId: IListIdentity;
elements: TArray<IAstNode>;
begin
if (FNode.Identity <> nil) and (FNode.Identity.Kind = ikList) then
begin
@@ -83,19 +85,22 @@ begin
if openTok <> '' then
OwnerNode.AddLabel(OwnerNode, openTok);
for i := 0 to FNode.Count - 1 do
// Optimization: Access Elements array directly from ITupleNode
elements := FNode.Elements;
for i := 0 to High(elements) do
begin
childView := visu.CallAccept(FNode[i]);
childView := visu.CallAccept(elements[i]);
FChildNodes.Add(childView);
if (i < FNode.Count - 1) and (sep <> '') and (sep <> ' ') then
if (i < High(elements)) and (sep <> '') and (sep <> ' ') then
OwnerNode.AddLabel(OwnerNode, sep);
end;
if closeTok <> '' then
OwnerNode.AddLabel(OwnerNode, closeTok);
if FNode.Count = 0 then
if Length(elements) = 0 then
begin
if (openTok = '') and (closeTok = '') then
begin
@@ -107,7 +112,7 @@ end;
// IReorderable Implementation
function TNodeListHandler<T>.CanDrag(Child: TVisualNode): Boolean;
function TNodeListHandler.CanDrag(Child: TVisualNode): Boolean;
begin
// Only allow dragging if the child is one of our managed ViewNodes
if Child is TAstViewNode then
@@ -116,7 +121,7 @@ begin
Result := False;
end;
procedure TNodeListHandler<T>.MoveChild(SourceIndex, TargetIndex: Integer);
procedure TNodeListHandler.MoveChild(SourceIndex, TargetIndex: Integer);
var
item: TAstViewNode;
begin