Ast UI handlers split into separate units
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
unit Myc.Fmx.AstEditor.Handlers.Lists;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Myc.Ast.Nodes,
|
||||
Myc.Fmx.AstEditor.Render,
|
||||
Myc.Fmx.AstEditor.Node,
|
||||
Myc.Fmx.AstEditor.Handlers;
|
||||
|
||||
type
|
||||
TParameterListHandler = class(TNodeListHandler<IIdentifierNode>)
|
||||
protected
|
||||
function GetOrientation: TLayoutOrientation; override;
|
||||
public
|
||||
function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
|
||||
end;
|
||||
|
||||
TArgumentListHandler = class(TNodeListHandler<IAstNode>)
|
||||
protected
|
||||
function GetOrientation: TLayoutOrientation; override;
|
||||
public
|
||||
function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
|
||||
end;
|
||||
|
||||
TExpressionListHandler = class(TNodeListHandler<IAstNode>)
|
||||
protected
|
||||
function GetOrientation: TLayoutOrientation; override;
|
||||
function GetAlignment: TLayoutAlignment; override;
|
||||
public
|
||||
function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
|
||||
end;
|
||||
|
||||
TRecordFieldListHandler = class(TNodeListHandler<IRecordFieldNode>)
|
||||
protected
|
||||
function GetOrientation: TLayoutOrientation; override;
|
||||
function GetAlignment: TLayoutAlignment; override;
|
||||
public
|
||||
function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TParameterListHandler }
|
||||
|
||||
function TParameterListHandler.GetOrientation: TLayoutOrientation;
|
||||
begin
|
||||
Result := loHorizontal;
|
||||
end;
|
||||
|
||||
function TParameterListHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
|
||||
var
|
||||
arr: TArray<IIdentifierNode>;
|
||||
i: Integer;
|
||||
begin
|
||||
SetLength(arr, FChildNodes.Count);
|
||||
for i := 0 to FChildNodes.Count - 1 do
|
||||
arr[i] := FChildNodes[i].CreateAst.AsIdentifier;
|
||||
|
||||
Result := TParameterList.Create(arr, FNode.Identity);
|
||||
end;
|
||||
|
||||
{ TArgumentListHandler }
|
||||
|
||||
function TArgumentListHandler.GetOrientation: TLayoutOrientation;
|
||||
begin
|
||||
Result := loHorizontal;
|
||||
end;
|
||||
|
||||
function TArgumentListHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
|
||||
var
|
||||
arr: TArray<IAstNode>;
|
||||
i: Integer;
|
||||
begin
|
||||
SetLength(arr, FChildNodes.Count);
|
||||
for i := 0 to FChildNodes.Count - 1 do
|
||||
arr[i] := FChildNodes[i].CreateAst;
|
||||
|
||||
Result := TArgumentList.Create(arr, FNode.Identity);
|
||||
end;
|
||||
|
||||
{ TExpressionListHandler }
|
||||
|
||||
function TExpressionListHandler.GetOrientation: TLayoutOrientation;
|
||||
begin
|
||||
Result := loVertical;
|
||||
end;
|
||||
|
||||
function TExpressionListHandler.GetAlignment: TLayoutAlignment;
|
||||
begin
|
||||
Result := laFlush;
|
||||
end;
|
||||
|
||||
function TExpressionListHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
|
||||
var
|
||||
arr: TArray<IAstNode>;
|
||||
i: Integer;
|
||||
begin
|
||||
SetLength(arr, FChildNodes.Count);
|
||||
for i := 0 to FChildNodes.Count - 1 do
|
||||
arr[i] := FChildNodes[i].CreateAst;
|
||||
|
||||
Result := TExpressionList.Create(arr, FNode.Identity);
|
||||
end;
|
||||
|
||||
{ TRecordFieldListHandler }
|
||||
|
||||
function TRecordFieldListHandler.GetOrientation: TLayoutOrientation;
|
||||
begin
|
||||
Result := loVertical;
|
||||
end;
|
||||
|
||||
function TRecordFieldListHandler.GetAlignment: TLayoutAlignment;
|
||||
begin
|
||||
Result := laFlush;
|
||||
end;
|
||||
|
||||
function TRecordFieldListHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
|
||||
var
|
||||
arr: TArray<IRecordFieldNode>;
|
||||
i: Integer;
|
||||
begin
|
||||
SetLength(arr, FChildNodes.Count);
|
||||
for i := 0 to FChildNodes.Count - 1 do
|
||||
arr[i] := FChildNodes[i].CreateAst.AsRecordField;
|
||||
|
||||
Result := TRecordFieldList.Create(arr, FNode.Identity);
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user