Skip to content

Commit

Permalink
New test application
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanYankovsky committed Mar 27, 2015
1 parent 7a4c4b9 commit c337ce2
Show file tree
Hide file tree
Showing 12 changed files with 693 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Test/DelphiASTTest.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
program DelphiASTTest;

uses
Vcl.Forms,
uMainForm in 'uMainForm.pas' {Form2};

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
474 changes: 474 additions & 0 deletions Test/DelphiASTTest.dproj

Large diffs are not rendered by default.

Binary file added Test/DelphiASTTest.res
Binary file not shown.
14 changes: 14 additions & 0 deletions Test/Snippets/deprecatedtype.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
unit deprecatedtype;

interface

type
TFoo = record
end deprecated 'Use TBar';

TBar = record
end deprecated;

implementation

end.
18 changes: 18 additions & 0 deletions Test/Snippets/experimentals.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
unit experimentals;

interface

type
TExperimentalClass = class
Field: Integer;
end experimental;

procedure someExperimentalProc();

implementation

procedure someExperimentalProc(); experimental;
begin
end;

end.
9 changes: 9 additions & 0 deletions Test/Snippets/externalfunction.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
unit externalfunction;

interface

function CreateJobObjectA; external Kernel32 name 'CreateJobObjectA';

implementation

end.
19 changes: 19 additions & 0 deletions Test/Snippets/forwardoverloaded.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
unit forwardoverloaded;

interface

implementation

procedure Test; forward; overload;

procedure Test(AParam: Integer); overload;
begin

end;

procedure Test;
begin

end;

end.
20 changes: 20 additions & 0 deletions Test/Snippets/forwardwithoutsemicolon.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
unit forwardwithoutsemicolon;

interface

procedure proc1(); forward // NO TRAILING SEMICOLON
procedure proc2();

implementation

procedure proc1();
begin

end;

procedure proc2();
begin

end;

end.
18 changes: 18 additions & 0 deletions Test/Snippets/implementsgenerictype.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
unit implementsgenerictype;

interface

type
IFoo<T> = interface
end;

TBar = class(TInterfacedObject, IFoo<IInterface>)
private
FFoo : IFoo<IInterface>;
public
property Foo : IFoo<IInterface> read FFoo implements IFoo<IInterface>;
end;

implementation

end.
Binary file added Test/Snippets/umlauts.pas
Binary file not shown.
45 changes: 45 additions & 0 deletions Test/uMainForm.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
object Form2: TForm2
Left = 0
Top = 0
Caption = 'DelphiAST Test Application'
ClientHeight = 231
ClientWidth = 687
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
DesignSize = (
687
231)
PixelsPerInch = 96
TextHeight = 13
object memLog: TMemo
Left = 0
Top = 0
Width = 687
Height = 193
Anchors = [akLeft, akTop, akRight, akBottom]
Font.Charset = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Lucida Console'
Font.Style = []
ParentFont = False
TabOrder = 0
ExplicitWidth = 505
end
object btnRun: TButton
Left = 604
Top = 198
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = 'Run'
TabOrder = 1
OnClick = btnRunClick
ExplicitLeft = 422
end
end
62 changes: 62 additions & 0 deletions Test/uMainForm.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
unit uMainForm;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
TForm2 = class(TForm)
memLog: TMemo;
btnRun: TButton;
procedure btnRunClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

uses
FileCtrl, IOUtils, DelphiAST, DelphiAST.Classes;

{$R *.dfm}

procedure TForm2.btnRunClick(Sender: TObject);
var
Path, FileName: string;
SyntaxTree: TSyntaxNode;
begin
memLog.Clear;

Path := ExtractFilePath(Application.ExeName) + 'Snippets\';
if not SelectDirectory('Select Folder', '', Path) then
Exit;

for FileName in TDirectory.GetFiles(Path, '*.pas', TSearchOption.soAllDirectories) do
begin
try
SyntaxTree := TPasSyntaxTreeBuilder.Run(FileName);
try
memLog.Lines.Add('OK: ' + FileName);
finally
SyntaxTree.Free;
end;
except
on E: Exception do
begin
memLog.Lines.Add('FAILED: ' + FileName);
memLog.Lines.Add(' ' + E.ClassName);
memLog.Lines.Add(' ' + E.Message);
memLog.Repaint;
end;
end;
end;
end;

end.

0 comments on commit c337ce2

Please sign in to comment.