mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 04:39:36 +02:00
codetools: CheckLFM: added boolean RootMustBeClassInUnit parameter
git-svn-id: trunk@27481 -
This commit is contained in:
parent
82369989ce
commit
5dd01ce874
@ -604,7 +604,8 @@ type
|
||||
function FindLFMFileName(Code: TCodeBuffer): string;
|
||||
function CheckLFM(UnitCode, LFMBuf: TCodeBuffer;
|
||||
out LFMTree: TLFMTree;
|
||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): boolean;
|
||||
RootMustBeClassInUnit, RootMustBeClassInIntf,
|
||||
ObjectsMustExists: boolean): boolean;
|
||||
function FindNextResourceFile(Code: TCodeBuffer;
|
||||
var LinkIndex: integer): TCodeBuffer;
|
||||
function AddLazarusResourceHeaderComment(Code: TCodeBuffer;
|
||||
@ -4259,8 +4260,8 @@ begin
|
||||
end;
|
||||
|
||||
function TCodeToolManager.CheckLFM(UnitCode, LFMBuf: TCodeBuffer;
|
||||
out LFMTree: TLFMTree; RootMustBeClassInIntf, ObjectsMustExists: boolean
|
||||
): boolean;
|
||||
out LFMTree: TLFMTree; RootMustBeClassInUnit, RootMustBeClassInIntf,
|
||||
ObjectsMustExists: boolean): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
{$IFDEF CTDEBUG}
|
||||
@ -4269,7 +4270,7 @@ begin
|
||||
if not InitCurCodeTool(UnitCode) then exit;
|
||||
try
|
||||
Result:=FCurCodeTool.CheckLFM(LFMBuf,LFMTree,OnFindDefinePropertyForContext,
|
||||
RootMustBeClassInIntf,ObjectsMustExists);
|
||||
RootMustBeClassInUnit,RootMustBeClassInIntf,ObjectsMustExists);
|
||||
except
|
||||
on e: Exception do HandleException(e);
|
||||
end;
|
||||
|
@ -133,8 +133,9 @@ type
|
||||
KeepPath: boolean;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
function CheckLFM(LFMBuf: TCodeBuffer; out LFMTree: TLFMTree;
|
||||
const OnFindDefineProperty: TOnFindDefinePropertyForContext;
|
||||
RootMustBeClassInIntf, ObjectsMustExist: boolean): boolean;
|
||||
const OnFindDefineProperty: TOnFindDefinePropertyForContext;
|
||||
RootMustBeClassInUnit: boolean; RootMustBeClassInIntf: boolean;
|
||||
ObjectsMustExist: boolean): boolean;
|
||||
|
||||
// Application.Createform statements
|
||||
function FindCreateFormStatement(StartPos: integer;
|
||||
@ -2046,7 +2047,8 @@ end;
|
||||
|
||||
function TStandardCodeTool.CheckLFM(LFMBuf: TCodeBuffer; out LFMTree: TLFMTree;
|
||||
const OnFindDefineProperty: TOnFindDefinePropertyForContext;
|
||||
RootMustBeClassInIntf, ObjectsMustExist: boolean): boolean;
|
||||
RootMustBeClassInUnit: boolean; RootMustBeClassInIntf: boolean;
|
||||
ObjectsMustExist: boolean): boolean;
|
||||
var
|
||||
RootContext: TFindContext;
|
||||
|
||||
@ -2561,6 +2563,11 @@ var
|
||||
RootContext:=CleanFindContext;
|
||||
RootContext.Node:=RootClassNode;
|
||||
RootContext.Tool:=Self;
|
||||
end else if RootMustBeClassInUnit then begin
|
||||
RootClassNode:=FindClassNodeInUnit(LookupRootTypeName,true,false,false,false);
|
||||
RootContext:=CleanFindContext;
|
||||
RootContext.Node:=RootClassNode;
|
||||
RootContext.Tool:=Self;
|
||||
end else begin
|
||||
RootContext:=FindClassContext(LookupRootTypeName);
|
||||
RootClassNode:=RootContext.Node;
|
||||
|
@ -595,6 +595,7 @@ begin
|
||||
LfmFixer:=TLFMFixer.Create(fPascalBuffer,fLFMBuffer,@IDEMessagesWindow.AddMsg);
|
||||
try
|
||||
LfmFixer.Settings:=fSettings;
|
||||
LfmFixer.RootMustBeClassInUnit:=true;
|
||||
LfmFixer.RootMustBeClassInIntf:=true;
|
||||
LfmFixer.ObjectsMustExists:=true;
|
||||
if LfmFixer.Repair<>mrOk then begin
|
||||
|
@ -452,7 +452,7 @@ begin
|
||||
LoopCount:=0;
|
||||
repeat
|
||||
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
||||
fRootMustBeClassInIntf,fObjectsMustExists) then
|
||||
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExists) then
|
||||
Result:=mrOk
|
||||
else // Rename/remove properties and types interactively.
|
||||
Result:=ShowRepairLFMWizard; // Can return mrRetry.
|
||||
|
@ -177,7 +177,7 @@ var
|
||||
//debugln('ChangePersistentClass-Before-Checking--------------------------------------------');
|
||||
//debugln(LFMBuffer.Source);
|
||||
//debugln('ChangePersistentClass-Before-Checking-------------------------------------------');
|
||||
if not CodeToolBoss.CheckLFM(UnitCode,LFMBuffer,LFMTree,false,false) then
|
||||
if not CodeToolBoss.CheckLFM(UnitCode,LFMBuffer,LFMTree,false,false,false) then
|
||||
begin
|
||||
debugln('ChangePersistentClass-Before--------------------------------------------');
|
||||
debugln(LFMBuffer.Source);
|
||||
@ -221,7 +221,7 @@ var
|
||||
|
||||
function CheckProperties: boolean;
|
||||
begin
|
||||
Result:=RepairLFMBuffer(UnitCode,LFMBuffer,nil,false,false)=mrOk;
|
||||
Result:=RepairLFMBuffer(UnitCode,LFMBuffer,nil,false,false,false)=mrOk;
|
||||
if not Result and (CodeToolBoss.ErrorMessage<>'') then
|
||||
MainIDEInterface.DoJumpToCodeToolBossError;
|
||||
end;
|
||||
|
@ -58,6 +58,7 @@ type
|
||||
fPascalBuffer: TCodeBuffer;
|
||||
fLFMBuffer: TCodeBuffer;
|
||||
fLFMTree: TLFMTree;
|
||||
fRootMustBeClassInUnit: boolean;
|
||||
fRootMustBeClassInIntf: boolean;
|
||||
fObjectsMustExists: boolean;
|
||||
// References to controls in UI:
|
||||
@ -88,6 +89,8 @@ type
|
||||
property PascalBuffer: TCodeBuffer read fPascalBuffer;
|
||||
property LFMBuffer: TCodeBuffer read fLFMBuffer;
|
||||
property OnOutput: TOnAddFilteredLine read fOnOutput;
|
||||
property RootMustBeClassInUnit: boolean read fRootMustBeClassInUnit
|
||||
write fRootMustBeClassInUnit;
|
||||
property RootMustBeClassInIntf: boolean read fRootMustBeClassInIntf
|
||||
write fRootMustBeClassInIntf;
|
||||
property ObjectsMustExists: boolean read fObjectsMustExists
|
||||
@ -128,7 +131,8 @@ function QuickCheckLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
||||
// Now this is just a wrapper for designer/changeclassdialog. Could be moved there.
|
||||
function RepairLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
||||
const OnOutput: TOnAddFilteredLine;
|
||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
||||
RootMustBeClassInUnit, RootMustBeClassInIntf,
|
||||
ObjectsMustExists: boolean): TModalResult;
|
||||
// Not use anywhere.
|
||||
{function RepairLFMText(PascalBuffer: TCodeBuffer; var LFMText: string;
|
||||
const OnOutput: TOnAddFilteredLine;
|
||||
@ -248,12 +252,14 @@ end;
|
||||
|
||||
function RepairLFMBuffer(PascalBuffer, LFMBuffer: TCodeBuffer;
|
||||
const OnOutput: TOnAddFilteredLine;
|
||||
RootMustBeClassInIntf, ObjectsMustExists: boolean): TModalResult;
|
||||
RootMustBeClassInUnit, RootMustBeClassInIntf,
|
||||
ObjectsMustExists: boolean): TModalResult;
|
||||
var
|
||||
LFMChecker: TLFMChecker;
|
||||
begin
|
||||
LFMChecker:=TLFMChecker.Create(PascalBuffer,LFMBuffer,OnOutput);
|
||||
try
|
||||
LFMChecker.RootMustBeClassInUnit:=RootMustBeClassInUnit;
|
||||
LFMChecker.RootMustBeClassInIntf:=RootMustBeClassInIntf;
|
||||
LFMChecker.ObjectsMustExists:=ObjectsMustExists;
|
||||
Result:=LFMChecker.Repair;
|
||||
@ -413,7 +419,7 @@ begin
|
||||
Result:=mrCancel;
|
||||
if not CheckUnit then exit;
|
||||
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
||||
fRootMustBeClassInIntf,fObjectsMustExists)
|
||||
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExists)
|
||||
then begin
|
||||
Result:=mrOk;
|
||||
exit;
|
||||
@ -512,7 +518,7 @@ begin
|
||||
|
||||
// check LFM again
|
||||
if CodeToolBoss.CheckLFM(fPascalBuffer,fLFMBuffer,fLFMTree,
|
||||
fRootMustBeClassInIntf,fObjectsMustExists)
|
||||
fRootMustBeClassInUnit,fRootMustBeClassInIntf,fObjectsMustExists)
|
||||
then begin
|
||||
Result:=mrOk;
|
||||
end else begin
|
||||
|
@ -11673,6 +11673,7 @@ begin
|
||||
// parse the LFM file and the pascal unit
|
||||
LFMChecker:=TLFMChecker.Create(PascalBuf,LFMUnitInfo.Source,@MessagesView.AddMsg);
|
||||
try
|
||||
LFMChecker.RootMustBeClassInUnit:=true;
|
||||
LFMChecker.RootMustBeClassInIntf:=true;
|
||||
LFMChecker.ObjectsMustExists:=true;
|
||||
if LFMChecker.Repair=mrOk then begin
|
||||
|
Loading…
Reference in New Issue
Block a user