forked from RomanYankovsky/DelphiAST
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7a4c4b9
commit c337ce2
Showing
12 changed files
with
693 additions
and
0 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,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. |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,14 @@ | ||
unit deprecatedtype; | ||
|
||
interface | ||
|
||
type | ||
TFoo = record | ||
end deprecated 'Use TBar'; | ||
|
||
TBar = record | ||
end deprecated; | ||
|
||
implementation | ||
|
||
end. |
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,18 @@ | ||
unit experimentals; | ||
|
||
interface | ||
|
||
type | ||
TExperimentalClass = class | ||
Field: Integer; | ||
end experimental; | ||
|
||
procedure someExperimentalProc(); | ||
|
||
implementation | ||
|
||
procedure someExperimentalProc(); experimental; | ||
begin | ||
end; | ||
|
||
end. |
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,9 @@ | ||
unit externalfunction; | ||
|
||
interface | ||
|
||
function CreateJobObjectA; external Kernel32 name 'CreateJobObjectA'; | ||
|
||
implementation | ||
|
||
end. |
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,19 @@ | ||
unit forwardoverloaded; | ||
|
||
interface | ||
|
||
implementation | ||
|
||
procedure Test; forward; overload; | ||
|
||
procedure Test(AParam: Integer); overload; | ||
begin | ||
|
||
end; | ||
|
||
procedure Test; | ||
begin | ||
|
||
end; | ||
|
||
end. |
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,20 @@ | ||
unit forwardwithoutsemicolon; | ||
|
||
interface | ||
|
||
procedure proc1(); forward // NO TRAILING SEMICOLON | ||
procedure proc2(); | ||
|
||
implementation | ||
|
||
procedure proc1(); | ||
begin | ||
|
||
end; | ||
|
||
procedure proc2(); | ||
begin | ||
|
||
end; | ||
|
||
end. |
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,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 not shown.
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,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 |
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,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. |