mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 10:19:36 +02:00
codetools: clean up
git-svn-id: trunk@56361 -
This commit is contained in:
parent
0e12730671
commit
87da0fc570
@ -754,8 +754,6 @@ type
|
|||||||
const ClassContext, AncestorClassContext: TFindContext;
|
const ClassContext, AncestorClassContext: TFindContext;
|
||||||
{%H-}LFMNode: TLFMTreeNode;
|
{%H-}LFMNode: TLFMTreeNode;
|
||||||
const IdentName: string; var IsDefined: boolean);
|
const IdentName: string; var IsDefined: boolean);
|
||||||
function UpdateComponentInit(Code: TCodeBuffer; const aClassName,
|
|
||||||
AccessClass, StartSignature, EndSignature, InitSrc: string): boolean;
|
|
||||||
|
|
||||||
// register proc
|
// register proc
|
||||||
function HasInterfaceRegisterProc(Code: TCodeBuffer;
|
function HasInterfaceRegisterProc(Code: TCodeBuffer;
|
||||||
@ -5385,23 +5383,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.UpdateComponentInit(Code: TCodeBuffer;
|
|
||||||
const aClassName, AccessClass, StartSignature, EndSignature, InitSrc: string
|
|
||||||
): boolean;
|
|
||||||
begin
|
|
||||||
Result:=false;
|
|
||||||
{$IFDEF CTDEBUG}
|
|
||||||
DebugLn(['TCodeToolManager.UpdateComponentInit A ',Code.Filename,' Class="'+aClassName+'" AccessClass="'+AccessClass+'" StartSignature="'+StartSignature+'" EndSignature="'+EndSignature+'" InitSrc={'+InitSrc+'}']);
|
|
||||||
{$ENDIF}
|
|
||||||
if not InitCurCodeTool(Code) then exit;
|
|
||||||
try
|
|
||||||
Result:=FCurCodeTool.UpdateComponentInit(aClassName,AccessClass,
|
|
||||||
StartSignature,EndSignature,InitSrc,SourceChangeCache);
|
|
||||||
except
|
|
||||||
on e: Exception do Result:=HandleException(e);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCodeToolManager.FindCreateFormStatement(Code: TCodeBuffer;
|
function TCodeToolManager.FindCreateFormStatement(Code: TCodeBuffer;
|
||||||
StartPos: integer;
|
StartPos: integer;
|
||||||
const AClassName, AVarName: string;
|
const AClassName, AVarName: string;
|
||||||
|
@ -124,10 +124,6 @@ type
|
|||||||
const WithExpr: string; // if empty: collect Candidates
|
const WithExpr: string; // if empty: collect Candidates
|
||||||
Candidates: TStrings; SourceChangeCache: TSourceChangeCache): boolean;
|
Candidates: TStrings; SourceChangeCache: TSourceChangeCache): boolean;
|
||||||
|
|
||||||
function UpdateComponentInit(const aClassName, AccessClass,
|
|
||||||
StartSignature, EndSignature, InitSrc: string;
|
|
||||||
SourceChangeCache: TSourceChangeCache): boolean;
|
|
||||||
|
|
||||||
procedure CalcMemSize(Stats: TCTMemStats); override;
|
procedure CalcMemSize(Stats: TCTMemStats); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1700,35 +1696,6 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TExtractProcTool.UpdateComponentInit(const aClassName, AccessClass,
|
|
||||||
StartSignature, EndSignature, InitSrc: string;
|
|
||||||
SourceChangeCache: TSourceChangeCache): boolean;
|
|
||||||
|
|
||||||
procedure E(TheID: int64; Msg: string);
|
|
||||||
begin
|
|
||||||
raise ECodeToolError.Create(Self,TheID,'TExtractProcTool.UpdateComponentInit: '+Msg);
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
|
||||||
Result:=false;
|
|
||||||
{$IFDEF VerboseCompWriterPas}
|
|
||||||
debugln(['TExtractProcTool.UpdateComponentInit START ',MainFilename,' aClassName="'+aClassName+'" AccessClass="'+AccessClass+'" StartSignature={'+DbgStr(StartSignature)+'} EndSignature={'+dbgstr(EndSignature)+'} InitSrc={'+InitSrc+'}']);
|
|
||||||
{$ENDIF}
|
|
||||||
if aClassName='' then
|
|
||||||
E(20171025224428,'missing aClassName');
|
|
||||||
if not IsValidIdent(aClassName) then
|
|
||||||
E(20171025224540,'invalid aClassName "'+aClassName+'"');
|
|
||||||
if (AccessClass<>'') and not IsValidIdent(AccessClass) then
|
|
||||||
E(20171025224607,'invalid AccessClass "'+AccessClass+'"');
|
|
||||||
if StartSignature='' then
|
|
||||||
E(20171025224636,'missing StartSignature');
|
|
||||||
if EndSignature='' then
|
|
||||||
E(20171025224647,'missing EndSignature');
|
|
||||||
|
|
||||||
// find class
|
|
||||||
// ToDo
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TExtractProcTool.CalcMemSize(Stats: TCTMemStats);
|
procedure TExtractProcTool.CalcMemSize(Stats: TCTMemStats);
|
||||||
begin
|
begin
|
||||||
inherited CalcMemSize(Stats);
|
inherited CalcMemSize(Stats);
|
||||||
|
@ -30,7 +30,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, typinfo, LazLoggerBase, LazUTF8, LazLogger, CompWriterPas,
|
Classes, SysUtils, typinfo, LazLoggerBase, LazUTF8, LazLogger, CompWriterPas,
|
||||||
LazPasReadUtil, fpcunit, testregistry, CodeToolManager, LinkScanner,
|
LazPasReadUtil, fpcunit, testregistry, CodeToolManager, LinkScanner,
|
||||||
CodeToolsStructs, CodeCache, BasicCodeTools, TestStdCodetools, TestGlobals,
|
CodeToolsStructs, TestStdCodetools,
|
||||||
variants;
|
variants;
|
||||||
|
|
||||||
// Tests =======================================================================
|
// Tests =======================================================================
|
||||||
@ -484,8 +484,6 @@ type
|
|||||||
procedure TestDesignInfo;
|
procedure TestDesignInfo;
|
||||||
procedure TestDefineProperties_ListOfStrings;
|
procedure TestDefineProperties_ListOfStrings;
|
||||||
procedure Test_TStrings;
|
procedure Test_TStrings;
|
||||||
|
|
||||||
procedure TestFindComponentInit; // ToDo
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -2190,45 +2188,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTestCompReaderWriterPas.TestFindComponentInit;
|
|
||||||
var
|
|
||||||
Code: TCodeBuffer;
|
|
||||||
Init, IndentedInit, Src: String;
|
|
||||||
begin
|
|
||||||
exit;
|
|
||||||
|
|
||||||
Code:=CodeToolBoss.CreateFile('form1.pas');
|
|
||||||
Init:='Name:=''Form1'';'+LineEnding;
|
|
||||||
IndentText(CSPDefaultSignatureBegin+LineEnding
|
|
||||||
+Init
|
|
||||||
+CSPDefaultSignatureEnd+LineEnding,2,8,IndentedInit);
|
|
||||||
Src:=LinesToStr(['unit Unit1;'
|
|
||||||
,'{$mode objfpc}{$H+}'
|
|
||||||
,'interface'
|
|
||||||
,'uses Classes;'
|
|
||||||
,'type'
|
|
||||||
,' TForm1 = class(TComponent)'
|
|
||||||
,' public'
|
|
||||||
,' constructor Create(TheOwner: TComponent); override;'
|
|
||||||
,' end;'
|
|
||||||
,'implementation'
|
|
||||||
,'type'
|
|
||||||
,' '+CSPDefaultAccessClass+' = class(TComponent);'
|
|
||||||
,'constructor TForm.Create(TheOwner: TComponent);'
|
|
||||||
,'begin'+LineEnding
|
|
||||||
,' inherited;'])
|
|
||||||
+IndentedInit
|
|
||||||
+LinesToStr(['end;'
|
|
||||||
,'end.']);
|
|
||||||
Code.Source:=Src;
|
|
||||||
if not CodeToolBoss.UpdateComponentInit(Code,'TForm1',CSPDefaultAccessClass,
|
|
||||||
CSPDefaultSignatureBegin,CSPDefaultSignatureEnd,Init)
|
|
||||||
then begin
|
|
||||||
Fail('CodeToolBoss.UpdateComponentInit failed');
|
|
||||||
end;
|
|
||||||
CheckDiff('TestFindComponentInit',Src,Code.Source);
|
|
||||||
end;
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterTest(TTestCompReaderWriterPas);
|
RegisterTest(TTestCompReaderWriterPas);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user