mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 01:29:55 +02:00
Converter: Omit some unit names from project. Settings GUI improvements. Refactoring.
git-svn-id: trunk@29452 -
This commit is contained in:
parent
ef9ef55693
commit
f0f24c280f
@ -54,8 +54,6 @@ type
|
||||
fCodeTool: TCodeTool;
|
||||
fCode: TCodeBuffer;
|
||||
fSrcCache: TSourceChangeCache;
|
||||
fIsMainFile: Boolean; // Main project / package file.
|
||||
fIsConsoleApp: Boolean;
|
||||
fAskAboutError: Boolean;
|
||||
fSettings: TConvertSettings; // Conversion settings.
|
||||
procedure InitCodeTool;
|
||||
@ -68,8 +66,6 @@ type
|
||||
property CodeTool: TCodeTool read fCodeTool;
|
||||
property Code: TCodeBuffer read fCode;
|
||||
property SrcCache: TSourceChangeCache read fSrcCache;
|
||||
property IsMainFile: Boolean read fIsMainFile write fIsMainFile;
|
||||
property IsConsoleApp: Boolean read fIsConsoleApp write fIsConsoleApp;
|
||||
property AskAboutError: Boolean read fAskAboutError write fAskAboutError;
|
||||
property Settings: TConvertSettings read fSettings write fSettings;
|
||||
end;
|
||||
@ -79,6 +75,7 @@ type
|
||||
TConvDelphiCodeTool = class
|
||||
private
|
||||
fCTLink: TCodeToolLink;
|
||||
fIsConsoleApp: Boolean;
|
||||
fHasFormFile: boolean;
|
||||
fLowerCaseRes: boolean;
|
||||
fAddUnitEvent: TAddUnitEvent;
|
||||
@ -102,6 +99,7 @@ type
|
||||
function FixMainClassAncestor(const AClassName: string;
|
||||
AReplaceTypes: TStringToStringTree): boolean;
|
||||
public
|
||||
property IsConsoleApp: Boolean read fIsConsoleApp write fIsConsoleApp;
|
||||
property HasFormFile: boolean read fHasFormFile write fHasFormFile;
|
||||
property LowerCaseRes: boolean read fLowerCaseRes write fLowerCaseRes;
|
||||
property AddUnitEvent: TAddUnitEvent read fAddUnitEvent write fAddUnitEvent;
|
||||
@ -116,7 +114,6 @@ constructor TCodeToolLink.Create(ACode: TCodeBuffer);
|
||||
begin
|
||||
inherited Create;
|
||||
fCode:=ACode;
|
||||
fIsConsoleApp:=False;
|
||||
fAskAboutError:=True;
|
||||
InitCodeTool;
|
||||
end;
|
||||
@ -170,7 +167,8 @@ constructor TConvDelphiCodeTool.Create(ACTLink: TCodeToolLink);
|
||||
begin
|
||||
inherited Create;
|
||||
fCTLink:=ACTLink;
|
||||
fLowerCaseRes:=false;
|
||||
fLowerCaseRes:=False;
|
||||
fIsConsoleApp:=False;
|
||||
end;
|
||||
|
||||
destructor TConvDelphiCodeTool.Destroy;
|
||||
@ -192,7 +190,7 @@ begin
|
||||
if not AddModeDelphiDirective then exit;
|
||||
if not RenameResourceDirectives then exit;
|
||||
if fCTLink.Settings.FuncReplaceMode=rsEnabled then
|
||||
if not ReplaceFuncCalls(fCTLink.IsConsoleApp) then exit;
|
||||
if not ReplaceFuncCalls(fIsConsoleApp) then exit;
|
||||
finally
|
||||
fCTLink.SrcCache.EndUpdate;
|
||||
end;
|
||||
|
@ -196,7 +196,7 @@ type
|
||||
private
|
||||
// Resource code
|
||||
fMainUnitConverter: TConvertDelphiUnit;
|
||||
function AddUnit(AUnitName: string; out OutUnitInfo: TUnitInfo): TModalResult;
|
||||
function AddUnit(AFileName: string; out OutUnitInfo: TUnitInfo): TModalResult;
|
||||
function GetLazProject: TProject;
|
||||
procedure SetLazProject(const AValue: TProject);
|
||||
protected
|
||||
@ -461,6 +461,7 @@ begin
|
||||
if not LazarusIDE.BeginCodeTools then
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiBeginCodeToolsFailed, '', -1);
|
||||
fCTLink:=Nil; // Will be created later.
|
||||
fUsedUnitsTool:=Nil;
|
||||
end;
|
||||
|
||||
destructor TConvertDelphiUnit.Destroy;
|
||||
@ -493,9 +494,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
if Result=mrOk then
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiReady, '', -1)
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiConversionReady, '', -1)
|
||||
else
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiAborted, '', -1)
|
||||
IDEMessagesWindow.AddMsg(lisConvDelphiConversionAborted, '', -1)
|
||||
end;
|
||||
|
||||
function TConvertDelphiUnit.GetDfmFileName: string;
|
||||
@ -531,6 +532,14 @@ begin
|
||||
Assert(fCTLink=Nil, 'fCTLink should be Nil in CopyAndLoadFile');
|
||||
fCTLink:=TCodeToolLink.Create(fPascalBuffer);
|
||||
fCTLink.Settings:=fSettings;
|
||||
fCTLink.AskAboutError:=Assigned(fOwnerConverter);
|
||||
// Create a toold for missing units.
|
||||
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
||||
if Assigned(fOwnerConverter) then begin
|
||||
fUsedUnitsTool.CheckPackDepEvent:=@fOwnerConverter.CheckPackageDependency;
|
||||
fUsedUnitsTool.IsMainFile:=fOwnerConverter.MainName=fLazUnitFilename;
|
||||
fUsedUnitsTool.IsConsoleApp:=fOwnerConverter.fIsConsoleApp;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TConvertDelphiUnit.FixLfmFilename(ADfmFilename: string): TModalResult;
|
||||
@ -612,20 +621,7 @@ begin
|
||||
// Fix include file names.
|
||||
Result:=FixIncludeFiles;
|
||||
if Result<>mrOk then exit;
|
||||
fCTLink.IsConsoleApp:=False;
|
||||
fCTLink.IsMainFile:=False;
|
||||
fCTLink.AskAboutError:=False;
|
||||
if Assigned(fOwnerConverter) then begin
|
||||
fCTLink.IsConsoleApp:= fOwnerConverter.fIsConsoleApp;
|
||||
fCTLink.IsMainFile:=fOwnerConverter.MainName=fLazUnitFilename;
|
||||
fCTLink.AskAboutError:=True;
|
||||
end;
|
||||
// Take care of missing units in uses sections.
|
||||
fUsedUnitsTool:=Nil;
|
||||
if fSettings.UnitsReplaceMode<>rlDisabled then begin
|
||||
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
||||
if Assigned(fOwnerConverter) then
|
||||
fUsedUnitsTool.CheckPackDepEvent:=@fOwnerConverter.CheckPackageDependency;
|
||||
// Find and prepare the missing units. Don't replace yet.
|
||||
Result:=fUsedUnitsTool.Prepare;
|
||||
if Result<>mrOk then exit;
|
||||
@ -637,10 +633,11 @@ begin
|
||||
// Do the actual code conversion.
|
||||
ConvTool:=TConvDelphiCodeTool.Create(fCTLink);
|
||||
try
|
||||
if Assigned(fOwnerConverter) then
|
||||
ConvTool.IsConsoleApp:=fOwnerConverter.fIsConsoleApp;
|
||||
ConvTool.LowerCaseRes:=FileExistsUTF8(ChangeFileExt(fLazUnitFilename, '.res'));
|
||||
ConvTool.HasFormFile:=DfmFilename<>'';
|
||||
if Assigned(fUsedUnitsTool) then
|
||||
ConvTool.AddUnitEvent:=@fUsedUnitsTool.AddUnitIfNeeded;
|
||||
ConvTool.AddUnitEvent:=@fUsedUnitsTool.AddUnitIfNeeded;
|
||||
Result:=ConvTool.Convert;
|
||||
finally
|
||||
ConvTool.Free;
|
||||
@ -675,10 +672,10 @@ begin
|
||||
if Result<>mrOk then exit;
|
||||
end;
|
||||
// After other changes: add, remove, fix and comment out units in uses sections.
|
||||
if Assigned(fUsedUnitsTool) then begin
|
||||
Result:=fUsedUnitsTool.Convert;
|
||||
if Result<>mrOk then exit;
|
||||
end;
|
||||
IDEMessagesWindow.AddMsg(Format(lisConvDelphiFixingUsedUnits,
|
||||
[fOrigUnitFilename]), '', -1);
|
||||
Result:=fUsedUnitsTool.Convert;
|
||||
if Result<>mrOk then exit;
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
@ -877,13 +874,13 @@ begin
|
||||
|
||||
SetCompilerModeForDefineTempl(CustomDefines);
|
||||
try
|
||||
Result:=ConvertMainSourceFile; // Convert project's LPR file.
|
||||
if Result<>mrOK then exit;
|
||||
// get all options from the .dpr or .dpk file
|
||||
Result:=ExtractOptionsFromDelphiSource;
|
||||
if Result<>mrOK then exit;
|
||||
Result:=FindAllUnits; // find all files and save the project.
|
||||
if Result<>mrOK then exit;
|
||||
Result:=ConvertMainSourceFile; // Convert project's LPR file.
|
||||
Result:=ConvertAllUnits; // convert all files.
|
||||
finally
|
||||
UnsetCompilerModeForDefineTempl(CustomDefines);
|
||||
@ -1323,51 +1320,59 @@ begin
|
||||
Result:=fMainUnitConverter.ConvertFormFile;
|
||||
end;
|
||||
|
||||
function TConvertDelphiProject.AddUnit(AUnitName: string;
|
||||
function TConvertDelphiProject.AddUnit(AFileName: string;
|
||||
out OutUnitInfo: TUnitInfo): TModalResult;
|
||||
// add new unit to project
|
||||
var
|
||||
CurUnitInfo: TUnitInfo;
|
||||
RP: String;
|
||||
RP, PureUnitName: String;
|
||||
x: Integer;
|
||||
begin
|
||||
Result:=mrOK;
|
||||
OutUnitInfo:=nil;
|
||||
if not FilenameIsAbsolute(AUnitName) then
|
||||
AUnitName:=AppendPathDelim(LazProject.ProjectDirectory)+AUnitName;
|
||||
AUnitName:=TrimFilename(AUnitName);
|
||||
if not FileExistsUTF8(AUnitName) then
|
||||
if not FilenameIsAbsolute(AFileName) then
|
||||
AFileName:=AppendPathDelim(LazProject.ProjectDirectory)+AFileName;
|
||||
AFileName:=TrimFilename(AFileName);
|
||||
if not FileExistsUTF8(AFileName) then
|
||||
exit(mrNo);
|
||||
// Create relative search path for project settings.
|
||||
RP:=ExtractFilePath(CreateRelativePath(AUnitName, LazProject.ProjectDirectory));
|
||||
RP:=ExtractFilePath(CreateRelativePath(AFileName, LazProject.ProjectDirectory));
|
||||
if (RP<>'') and (fUnitSearchPaths.IndexOf(RP)<0) then
|
||||
fUnitSearchPaths.Add(RP);
|
||||
// Check unitname and create UnitInfo.
|
||||
CurUnitInfo:=LazProject.UnitInfoWithFilename(AUnitName);
|
||||
if CurUnitInfo=nil then begin
|
||||
if FilenameIsPascalUnit(AUnitName) then begin
|
||||
CurUnitInfo:=LazProject.UnitWithUnitname(ExtractFileNameOnly(AUnitName));
|
||||
if CurUnitInfo<>nil then begin
|
||||
Result:=QuestionDlg(lisConvDelphiUnitnameExistsTwice,
|
||||
Format(lisConvDelphiThereAreTwoUnitsWithTheSameUnitname,
|
||||
[#13, CurUnitInfo.Filename, #13, AUnitName, #13]),
|
||||
mtWarning, [mrYes, lisConvDelphiRemoveFirst, mrNo,
|
||||
lisConvDelphiRemoveSecond,
|
||||
mrIgnore, lisConvDelphiKeepBoth, mrAbort], 0);
|
||||
case Result of
|
||||
mrYes: CurUnitInfo.IsPartOfProject:=false;
|
||||
mrNo: exit(mrNo);
|
||||
mrIgnore: ;
|
||||
else
|
||||
exit(mrAbort);
|
||||
PureUnitName:=ExtractFileNameOnly(AFileName);
|
||||
if not fSettings.OmitProjUnits.Find(PureUnitName, x) then begin
|
||||
// Check unitname and create UnitInfo.
|
||||
CurUnitInfo:=LazProject.UnitInfoWithFilename(AFileName);
|
||||
if CurUnitInfo=nil then begin
|
||||
if FilenameIsPascalUnit(AFileName) then begin
|
||||
CurUnitInfo:=LazProject.UnitWithUnitname(PureUnitName);
|
||||
if CurUnitInfo<>nil then begin
|
||||
Result:=QuestionDlg(lisConvDelphiUnitnameExistsTwice,
|
||||
Format(lisConvDelphiThereAreTwoUnitsWithTheSameUnitname,
|
||||
[#13, CurUnitInfo.Filename, #13, AFileName, #13]),
|
||||
mtWarning, [mrYes, lisConvDelphiRemoveFirst, mrNo,
|
||||
lisConvDelphiRemoveSecond,
|
||||
mrIgnore, lisConvDelphiKeepBoth, mrAbort], 0);
|
||||
case Result of
|
||||
mrYes: CurUnitInfo.IsPartOfProject:=false;
|
||||
mrNo: exit(mrNo);
|
||||
mrIgnore: ;
|
||||
else
|
||||
exit(mrAbort);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
CurUnitInfo:=TUnitInfo.Create(nil);
|
||||
CurUnitInfo.Filename:=AFileName;
|
||||
LazProject.AddFile(CurUnitInfo,false);
|
||||
end;
|
||||
CurUnitInfo:=TUnitInfo.Create(nil);
|
||||
CurUnitInfo.Filename:=AUnitName;
|
||||
LazProject.AddFile(CurUnitInfo,false);
|
||||
CurUnitInfo.IsPartOfProject:=true;
|
||||
OutUnitInfo:=CurUnitInfo;
|
||||
end
|
||||
else begin
|
||||
fMainUnitConverter.fUsedUnitsTool.Remove(PureUnitName);
|
||||
IDEMessagesWindow.AddMsg(Format(lisConvDelphiProjOmittedUnit,[PureUnitName]), '', -1);
|
||||
end;
|
||||
CurUnitInfo.IsPartOfProject:=true;
|
||||
OutUnitInfo:=CurUnitInfo;
|
||||
end;
|
||||
|
||||
function TConvertDelphiProject.FindAllUnits: TModalResult;
|
||||
|
@ -176,19 +176,6 @@ object ConvertSettingsForm: TConvertSettingsForm
|
||||
ShowHint = True
|
||||
TabOrder = 5
|
||||
end
|
||||
object TypeReplaceInfoLabel: TLabel
|
||||
AnchorSideLeft.Control = TypeReplaceButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = TypeReplaceButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 395
|
||||
Height = 16
|
||||
Top = 143
|
||||
Width = 67
|
||||
BorderSpacing.Left = 23
|
||||
Caption = 'Interactive'
|
||||
ParentColor = False
|
||||
end
|
||||
object FuncReplaceDivider: TDividerBevel
|
||||
AnchorSideLeft.Control = UnitReplaceDivider
|
||||
AnchorSideTop.Control = TypeReplaceDivider
|
||||
@ -375,4 +362,18 @@ object ConvertSettingsForm: TConvertSettingsForm
|
||||
Style = csDropDownList
|
||||
TabOrder = 12
|
||||
end
|
||||
object TypeReplaceComboBox: TComboBox
|
||||
AnchorSideLeft.Control = TypeReplaceButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = TypeReplaceButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 395
|
||||
Height = 21
|
||||
Top = 141
|
||||
Width = 136
|
||||
BorderSpacing.Left = 23
|
||||
ItemHeight = 0
|
||||
Style = csDropDownList
|
||||
TabOrder = 13
|
||||
end
|
||||
end
|
||||
|
@ -39,6 +39,7 @@ type
|
||||
|
||||
TReplaceModeLong = (rlDisabled, rlInteractive, rlAutomatic);
|
||||
TReplaceModeShort = (rsDisabled, rsEnabled);
|
||||
TReplaceModeAllow = (raEnabled, raAutomatic);
|
||||
|
||||
TConvertSettingsForm = class;
|
||||
|
||||
@ -62,9 +63,12 @@ type
|
||||
fSameDfmFile: boolean;
|
||||
// Modes for replacements:
|
||||
fUnitsReplaceMode: TReplaceModeLong;
|
||||
fUnknownPropsMode: TReplaceModeLong;
|
||||
fPropReplaceMode: TReplaceModeLong;
|
||||
fTypeReplaceMode: TReplaceModeAllow;
|
||||
fFuncReplaceMode: TReplaceModeShort;
|
||||
fCoordOffsMode: TReplaceModeShort;
|
||||
// Unit names to leave out of a project. Currently not user editable.
|
||||
fOmitProjUnits: TStringList;
|
||||
// Delphi units mapped to Lazarus units, will be replaced or removed.
|
||||
fReplaceUnits: TStringToStringTree;
|
||||
// Delphi types mapped to Lazarus types, will be replaced.
|
||||
@ -109,9 +113,11 @@ type
|
||||
property SupportDelphi: boolean read fSupportDelphi;
|
||||
property SameDfmFile: boolean read fSameDfmFile;
|
||||
property UnitsReplaceMode: TReplaceModeLong read fUnitsReplaceMode;
|
||||
property UnknownPropsMode: TReplaceModeLong read fUnknownPropsMode;
|
||||
property PropReplaceMode: TReplaceModeLong read fPropReplaceMode;
|
||||
property TypeReplaceMode: TReplaceModeAllow read fTypeReplaceMode;
|
||||
property FuncReplaceMode: TReplaceModeShort read fFuncReplaceMode;
|
||||
property CoordOffsMode: TReplaceModeShort read fCoordOffsMode;
|
||||
property OmitProjUnits: TStringList read fOmitProjUnits;
|
||||
property ReplaceUnits: TStringToStringTree read fReplaceUnits;
|
||||
property ReplaceTypes: TStringToStringTree read fReplaceTypes;
|
||||
property ReplaceFuncs: TFuncsAndCategories read fReplaceFuncs;
|
||||
@ -129,6 +135,7 @@ type
|
||||
SupportDelphiCheckBox: TCheckBox;
|
||||
TargetGroupBox: TGroupBox;
|
||||
FuncReplaceComboBox: TComboBox;
|
||||
TypeReplaceComboBox: TComboBox;
|
||||
UnknownPropsComboBox: TComboBox;
|
||||
UnknownPropsDivider: TDividerBevel;
|
||||
UnitReplaceDivider: TDividerBevel;
|
||||
@ -140,7 +147,6 @@ type
|
||||
BackupCheckBox: TCheckBox;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
TypeReplaceButton: TBitBtn;
|
||||
TypeReplaceInfoLabel: TLabel;
|
||||
UnitReplaceButton: TBitBtn;
|
||||
ProjectPathEdit: TLabeledEdit;
|
||||
CoordOffsButton: TBitBtn;
|
||||
@ -355,6 +361,7 @@ begin
|
||||
fMainPath:='';
|
||||
fEnabled:=True;
|
||||
fSettingsForm:=Nil;
|
||||
fOmitProjUnits:=TStringList.Create;
|
||||
fReplaceUnits:=TStringToStringTree.Create(false);
|
||||
fReplaceTypes:=TStringToStringTree.Create(false);
|
||||
fReplaceFuncs:=TFuncsAndCategories.Create;
|
||||
@ -367,7 +374,8 @@ begin
|
||||
fSupportDelphi :=fConfigStorage.GetValue('SupportDelphi', false);
|
||||
fSameDfmFile :=fConfigStorage.GetValue('SameDfmFile', false);
|
||||
fUnitsReplaceMode:=TReplaceModeLong(fConfigStorage.GetValue('UnitsReplaceMode', 2));
|
||||
fUnknownPropsMode:=TReplaceModeLong(fConfigStorage.GetValue('UnknownPropsMode', 2));
|
||||
fPropReplaceMode:=TReplaceModeLong(fConfigStorage.GetValue('UnknownPropsMode', 2));
|
||||
fTypeReplaceMode:=TReplaceModeAllow(fConfigStorage.GetValue('TypeReplaceMode', 1));
|
||||
fFuncReplaceMode:=TReplaceModeShort(fConfigStorage.GetValue('FuncReplaceMode', 1));
|
||||
fCoordOffsMode :=TReplaceModeShort(fConfigStorage.GetValue('CoordOffsMode', 1));
|
||||
LoadStringToStringTree(fConfigStorage, 'UnitReplacements/', fReplaceUnits);
|
||||
@ -375,7 +383,15 @@ begin
|
||||
LoadFuncReplacements(fConfigStorage, 'FuncReplacements/', 'Categories/', fReplaceFuncs);
|
||||
LoadVisualOffsets(fConfigStorage, 'VisualOffsets/', fCoordOffsets);
|
||||
|
||||
// Add default values for configuration if ConfigStorage doesn't have them.
|
||||
// * Add default values for configuration if ConfigStorage doesn't have them *
|
||||
|
||||
// Units left out of project. Not saved in configuration.
|
||||
with fOmitProjUnits do begin
|
||||
Add('FastMM4');
|
||||
Add('FastMM4Messages');
|
||||
Add('OpenGL');
|
||||
Sorted:=True;
|
||||
end;
|
||||
|
||||
// Map Delphi units to Lazarus units.
|
||||
TheMap:=fReplaceUnits;
|
||||
@ -493,7 +509,8 @@ begin
|
||||
fConfigStorage.SetDeleteValue('SupportDelphi', fSupportDelphi, false);
|
||||
fConfigStorage.SetDeleteValue('SameDfmFile', fSameDfmFile, false);
|
||||
fConfigStorage.SetDeleteValue('UnitsReplaceMode', integer(fUnitsReplaceMode), 2);
|
||||
fConfigStorage.SetDeleteValue('UnknownPropsMode', integer(fUnknownPropsMode), 2);
|
||||
fConfigStorage.SetDeleteValue('UnknownPropsMode', integer(fPropReplaceMode), 2);
|
||||
fConfigStorage.SetDeleteValue('TypeReplaceMode', integer(fTypeReplaceMode), 1);
|
||||
fConfigStorage.SetDeleteValue('FuncReplaceMode', integer(fFuncReplaceMode), 1);
|
||||
fConfigStorage.SetDeleteValue('CoordOffsMode', integer(fCoordOffsMode), 1);
|
||||
SaveStringToStringTree(fConfigStorage, 'UnitReplacements/', fReplaceUnits);
|
||||
@ -502,11 +519,12 @@ begin
|
||||
SaveVisualOffsets(fConfigStorage, 'VisualOffsets/', fCoordOffsets);
|
||||
// Free stuff
|
||||
fConfigStorage.Free;
|
||||
fCoordOffsets.Free;
|
||||
fReplaceFuncs.Clear;
|
||||
fReplaceFuncs.Free;
|
||||
fReplaceTypes.Free;
|
||||
fReplaceUnits.Free;
|
||||
fCoordOffsets.Free;
|
||||
fOmitProjUnits.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -524,7 +542,8 @@ begin
|
||||
SupportDelphiCheckBox.Checked :=fSupportDelphi;
|
||||
SameDfmCheckBox.Checked :=fSameDfmFile;
|
||||
UnitReplaceComboBox.ItemIndex :=integer(fUnitsReplaceMode);
|
||||
UnknownPropsComboBox.ItemIndex :=integer(fUnknownPropsMode);
|
||||
UnknownPropsComboBox.ItemIndex :=integer(fPropReplaceMode);
|
||||
TypeReplaceComboBox.ItemIndex :=integer(fTypeReplaceMode);
|
||||
FuncReplaceComboBox.ItemIndex :=integer(fFuncReplaceMode);
|
||||
CoordOffsComboBox.ItemIndex :=integer(fCoordOffsMode);
|
||||
SupportDelphiCheckBoxChange(SupportDelphiCheckBox);
|
||||
@ -538,7 +557,8 @@ begin
|
||||
fSupportDelphi :=SupportDelphiCheckBox.Checked;
|
||||
fSameDfmFile :=SameDfmCheckBox.Checked;
|
||||
fUnitsReplaceMode:=TReplaceModeLong(UnitReplaceComboBox.ItemIndex);
|
||||
fUnknownPropsMode:=TReplaceModeLong(UnknownPropsComboBox.ItemIndex);
|
||||
fPropReplaceMode:=TReplaceModeLong(UnknownPropsComboBox.ItemIndex);
|
||||
fTypeReplaceMode :=TReplaceModeAllow(TypeReplaceComboBox.ItemIndex);
|
||||
fFuncReplaceMode :=TReplaceModeShort(FuncReplaceComboBox.ItemIndex);
|
||||
fCoordOffsMode :=TReplaceModeShort(CoordOffsComboBox.ItemIndex);
|
||||
end;
|
||||
@ -691,7 +711,8 @@ begin
|
||||
TypeReplaceButton.Caption:=lisCodeToolsDefsEdit;
|
||||
TypeReplaceDivider.Hint:=lisConvTypeReplHint;
|
||||
TypeReplaceButton.Hint:=lisConvTypeReplHint;
|
||||
TypeReplaceInfoLabel.Caption:=lisInteractive;
|
||||
TypeReplaceComboBox.Items.Add(lisInteractive);
|
||||
TypeReplaceComboBox.Items.Add(lisAutomatic);
|
||||
// Func Replacements
|
||||
FuncReplaceDivider.Caption:=lisConvFuncReplacements;
|
||||
FuncReplaceButton.Caption:=lisCodeToolsDefsEdit;
|
||||
|
@ -9,7 +9,7 @@ object FixLFMDialog: TFixLFMDialog
|
||||
ClientWidth = 756
|
||||
OnCreate = CheckLFMDialogCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '0.9.31'
|
||||
object NoteLabel: TLabel
|
||||
Left = 0
|
||||
Height = 16
|
||||
@ -22,17 +22,17 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end
|
||||
object LFMGroupBox: TGroupBox
|
||||
Left = 0
|
||||
Height = 469
|
||||
Height = 468
|
||||
Top = 16
|
||||
Width = 408
|
||||
Align = alLeft
|
||||
Caption = 'LFM file'
|
||||
ClientHeight = 450
|
||||
ClientHeight = 449
|
||||
ClientWidth = 404
|
||||
TabOrder = 0
|
||||
inline LFMSynEdit: TSynEdit
|
||||
Left = 0
|
||||
Height = 450
|
||||
Height = 449
|
||||
Top = 0
|
||||
Width = 404
|
||||
Align = alClient
|
||||
@ -649,14 +649,12 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end>
|
||||
end
|
||||
end
|
||||
inline SynRightGutterPartList1: TSynRightGutterPartList
|
||||
end
|
||||
end
|
||||
end
|
||||
object ErrorsGroupBox: TGroupBox
|
||||
Left = 0
|
||||
Height = 104
|
||||
Top = 490
|
||||
Top = 489
|
||||
Width = 756
|
||||
Align = alBottom
|
||||
Caption = 'Errors'
|
||||
@ -676,20 +674,20 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end
|
||||
object BtnPanel: TPanel
|
||||
Left = 0
|
||||
Height = 43
|
||||
Top = 594
|
||||
Height = 44
|
||||
Top = 593
|
||||
Width = 756
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 43
|
||||
ClientHeight = 44
|
||||
ClientWidth = 756
|
||||
TabOrder = 2
|
||||
object CancelButton: TBitBtn
|
||||
Left = 670
|
||||
Height = 31
|
||||
Left = 673
|
||||
Height = 32
|
||||
Top = 6
|
||||
Width = 80
|
||||
Width = 77
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
@ -702,7 +700,7 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end
|
||||
object ReplaceAllButton: TBitBtn
|
||||
Left = 6
|
||||
Height = 26
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 218
|
||||
AutoSize = True
|
||||
@ -715,12 +713,12 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end
|
||||
object PropertyReplaceGroupBox: TGroupBox
|
||||
Left = 413
|
||||
Height = 469
|
||||
Height = 468
|
||||
Top = 16
|
||||
Width = 343
|
||||
Align = alClient
|
||||
Caption = 'Replacements'
|
||||
ClientHeight = 450
|
||||
ClientHeight = 449
|
||||
ClientWidth = 339
|
||||
TabOrder = 3
|
||||
object PropReplaceGrid: TStringGrid
|
||||
@ -770,7 +768,7 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end
|
||||
object TypeReplaceGrid: TStringGrid
|
||||
Left = 0
|
||||
Height = 224
|
||||
Height = 223
|
||||
Top = 226
|
||||
Width = 339
|
||||
Align = alClient
|
||||
@ -807,7 +805,7 @@ object FixLFMDialog: TFixLFMDialog
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 408
|
||||
Height = 469
|
||||
Height = 468
|
||||
Top = 16
|
||||
Width = 5
|
||||
end
|
||||
@ -815,7 +813,7 @@ object FixLFMDialog: TFixLFMDialog
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 485
|
||||
Top = 484
|
||||
Width = 756
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
@ -823,6 +821,12 @@ object FixLFMDialog: TFixLFMDialog
|
||||
object SynLFMSyn1: TSynLFMSyn
|
||||
DefaultFilter = 'Lazarus Form Files (*.lfm)|*.lfm'
|
||||
Enabled = False
|
||||
CommentAttri.FrameEdges = sfeAround
|
||||
IdentifierAttri.FrameEdges = sfeAround
|
||||
KeyAttri.FrameEdges = sfeAround
|
||||
NumberAttri.FrameEdges = sfeAround
|
||||
SpaceAttri.FrameEdges = sfeAround
|
||||
StringAttri.FrameEdges = sfeAround
|
||||
left = 129
|
||||
top = 104
|
||||
end
|
||||
|
@ -415,7 +415,7 @@ begin
|
||||
if NewIdent<>'' then
|
||||
fHasMissingObjectTypes:=true;
|
||||
end
|
||||
else if fSettings.UnknownPropsMode<>rlDisabled then begin
|
||||
else if fSettings.PropReplaceMode<>rlDisabled then begin
|
||||
OldIdent:=CurError.Node.GetIdentifier;
|
||||
PropUpdater.AddUnique(OldIdent); // Add each property only once.
|
||||
fHasMissingProperties:=true;
|
||||
@ -448,8 +448,8 @@ begin
|
||||
fPropReplaceGrid:=FixLFMDialog.PropReplaceGrid;
|
||||
fTypeReplaceGrid:=FixLFMDialog.TypeReplaceGrid;
|
||||
LoadLFM;
|
||||
if ((fSettings.UnknownPropsMode=rlAutomatic) or not fHasMissingProperties)
|
||||
and not fHasMissingObjectTypes then
|
||||
if ((fSettings.PropReplaceMode=rlAutomatic) or not fHasMissingProperties)
|
||||
and ((fSettings.TypeReplaceMode=raAutomatic) or not fHasMissingObjectTypes) then
|
||||
Result:=ReplaceAndRemoveAll // Can return mrRetry.
|
||||
else begin
|
||||
// Cursor is earlier set to HourGlass. Show normal cursor while in dialog.
|
||||
|
@ -76,6 +76,7 @@ type
|
||||
procedure CommentAutomatic(ACommentedUnits: TStringList);
|
||||
public
|
||||
property MissingUnits: TStringList read fMissingUnits;
|
||||
property UnitsToRemove: TStringList read fUnitsToRemove;
|
||||
property UnitsToRename: TStringToStringTree read fUnitsToRename;
|
||||
property UnitsToFixCase: TStringToStringTree read fUnitsToFixCase;
|
||||
end;
|
||||
@ -110,6 +111,8 @@ type
|
||||
private
|
||||
fCTLink: TCodeToolLink;
|
||||
fFilename: string;
|
||||
fIsMainFile: Boolean; // Main project / package file.
|
||||
fIsConsoleApp: Boolean;
|
||||
fMainUsedUnits: TUsedUnits;
|
||||
fImplUsedUnits: TUsedUnits;
|
||||
fCheckPackageDependencyEvent: TCheckUnitEvent;
|
||||
@ -119,10 +122,13 @@ type
|
||||
destructor Destroy; override;
|
||||
function Prepare: TModalResult;
|
||||
function Convert: TModalResult;
|
||||
function Remove(AUnit: string): TModalResult;
|
||||
procedure MoveMissingToComment(AAllCommentedUnits: TStrings);
|
||||
procedure AddUnitIfNeeded(AUnitName: string);
|
||||
function AddThreadSupport: TModalResult;
|
||||
public
|
||||
property IsMainFile: Boolean read fIsMainFile write fIsMainFile;
|
||||
property IsConsoleApp: Boolean read fIsConsoleApp write fIsConsoleApp;
|
||||
property MainUsedUnits: TUsedUnits read fMainUsedUnits;
|
||||
property ImplUsedUnits: TUsedUnits read fImplUsedUnits;
|
||||
property MissingUnitCount: integer read GetMissingUnitCount;
|
||||
@ -278,7 +284,7 @@ begin
|
||||
UnitN:=fMissingUnits[i];
|
||||
if AUnitUpdater.FindReplacement(UnitN, s) then begin
|
||||
// Don't replace Windows unit with LCL units in a console application.
|
||||
if (LowerCase(UnitN)='windows') and fCTLink.IsConsoleApp then
|
||||
if (LowerCase(UnitN)='windows') and fOwnerTool.IsConsoleApp then
|
||||
s:='';
|
||||
if Assigned(AMapToEdit) then
|
||||
AMapToEdit[UnitN]:=s // Add for interactive editing.
|
||||
@ -416,7 +422,7 @@ begin
|
||||
exit;
|
||||
if not fCTLink.SrcCache.Apply then exit;
|
||||
end;
|
||||
//fUnitsToRemove.Clear;
|
||||
fUnitsToRemove.Clear;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
@ -473,6 +479,8 @@ begin
|
||||
inherited Create;
|
||||
fCTLink:=ACTLink;
|
||||
fFilename:=AFilename;
|
||||
fIsMainFile:=False;
|
||||
fIsConsoleApp:=False;
|
||||
fCTLink.CodeTool.BuildTree(False);
|
||||
// These will read uses sections while creating.
|
||||
fMainUsedUnits:=TMainUsedUnits.Create(ACTLink, Self);
|
||||
@ -499,7 +507,7 @@ var
|
||||
begin
|
||||
Result:=mrOK;
|
||||
// Add unit 'Interfaces' if project uses 'Forms' and doesn't have 'Interfaces' yet.
|
||||
if fCTLink.IsMainFile then begin
|
||||
if fIsMainFile then begin
|
||||
if ( fMainUsedUnits.fExistingUnits.Find('forms', i)
|
||||
or fImplUsedUnits.fExistingUnits.Find('forms', i) )
|
||||
and (not fMainUsedUnits.fExistingUnits.Find('interfaces', i) )
|
||||
@ -567,8 +575,8 @@ begin
|
||||
if not CodeTool.AddUnitToSpecificUsesSection(
|
||||
fUsesSection, fUnitsToAdd[i], '', SrcCache) then exit;
|
||||
end;
|
||||
if Settings.MultiPlatform and not Settings.SupportDelphi then begin
|
||||
// One way conversion -> remove and rename units.
|
||||
if fIsMainFile or (Settings.MultiPlatform and not Settings.SupportDelphi) then begin
|
||||
// One way conversion (or main file) -> remove and rename units.
|
||||
if not fMainUsedUnits.RemoveUnits then exit; // Remove
|
||||
if not fImplUsedUnits.RemoveUnits then exit;
|
||||
// Rename
|
||||
@ -580,12 +588,12 @@ begin
|
||||
if not fMainUsedUnits.AddDelphiAndLCLSections then exit;
|
||||
if not fImplUsedUnits.AddDelphiAndLCLSections then exit;
|
||||
end
|
||||
else begin // Lazarus only -> comment out units if needed.
|
||||
else begin // Lazarus only multi- or single-platform -> comment out units if needed.
|
||||
if not CodeTool.CommentUnitsInUsesSections(fMainUsedUnits.fUnitsToComment,
|
||||
SrcCache) then exit;
|
||||
if not CodeTool.CommentUnitsInUsesSections(fImplUsedUnits.fUnitsToComment,
|
||||
SrcCache) then exit;
|
||||
// Add more units for only LCL.
|
||||
// Add more units meant for only LCL.
|
||||
with fMainUsedUnits do begin
|
||||
for i:=0 to fUnitsToAddForLCL.Count-1 do
|
||||
if not CodeTool.AddUnitToSpecificUsesSection(
|
||||
@ -601,6 +609,21 @@ begin
|
||||
Result:=mrOK;
|
||||
end;
|
||||
|
||||
function TUsedUnitsTool.Remove(AUnit: string): TModalResult;
|
||||
var
|
||||
x: Integer;
|
||||
begin
|
||||
Result:=mrIgnore;
|
||||
if fMainUsedUnits.fExistingUnits.Find(AUnit, x) then begin
|
||||
fMainUsedUnits.UnitsToRemove.Add(AUnit);
|
||||
Result:=mrOK;
|
||||
end
|
||||
else if fImplUsedUnits.fExistingUnits.Find(AUnit, x) then begin
|
||||
fImplUsedUnits.UnitsToRemove.Add(AUnit);
|
||||
Result:=mrOK;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUsedUnitsTool.MoveMissingToComment(AAllCommentedUnits: TStrings);
|
||||
begin
|
||||
// These units will be commented automatically in one project/package.
|
||||
|
@ -5097,37 +5097,37 @@ resourcestring
|
||||
lisConvDelphiSkipThisFile = 'Skip this file';
|
||||
lisConvDelphiSkipThisStep = 'Skip this step';
|
||||
lisConvDelphiConvertDelphiUnit = 'Convert Delphi unit';
|
||||
lisConvDelphiBeginCodeToolsFailed = 'BeginCodeTools failed!';
|
||||
lisConvDelphiReady = 'Ready.';
|
||||
lisConvDelphiAborted = 'Aborted.';
|
||||
lisConvDelphiConvertDelphiProject = 'Convert Delphi project';
|
||||
lisConvDelphiConvertDelphiPackage = 'Convert Delphi package';
|
||||
lisConvDelphiFindAllUnitFiles = '*** Find all unit files... ***';
|
||||
lisConvDelphiRepairingFormFiles = '*** Repairing form files... ***';
|
||||
lisConvDelphiRepairingFormFile = '* Repairing form file %s *';
|
||||
lisConvDelphiConvertingUnitFiles = '*** Converting unit files... ***';
|
||||
lisConvDelphiConvertingFile = '* Converting file %s *';
|
||||
lisConvDelphiRepairingFormFile = 'Repairing form file %s';
|
||||
lisConvDelphiFixingUsedUnits = '* Fixing used units for file %s *';
|
||||
lisConvDelphiErrorCanTFindUnit = '%s(%s,%s) Error: Can''t find unit %s';
|
||||
lisConvDelphiAllSubDirsScanned = 'All sub-directories will be scanned for unit files';
|
||||
lisConvDelphiMissingIncludeFile = '%s(%s,%s) missing include file';
|
||||
lisConvDelphiError = 'Error="%s"';
|
||||
lisConvDelphiFixedUnitCase = 'Fixed character case of unit "%s" to "%s".';
|
||||
lisConvDelphiReplacedUnitInUsesSection = 'Replaced unit "%s" with "%s" in uses section.';
|
||||
lisConvDelphiRemovedUnitInUsesSection = 'Removed unit "%s" in uses section.';
|
||||
lisConvDelphiUnitsToReplaceIn = 'Units to replace in %s';
|
||||
lisConvDelphiFailedConvertingUnit = 'Failed converting unit';
|
||||
lisConvDelphiFailedToConvertUnit = 'Failed to convert unit%s%s%s';
|
||||
lisConvDelphiConvertDelphiProject = 'Convert Delphi project';
|
||||
lisConvDelphiConvertDelphiPackage = 'Convert Delphi package';
|
||||
lisConvDelphiConversionReady = 'Conversion Ready.';
|
||||
lisConvDelphiConversionAborted = 'Conversion Aborted.';
|
||||
lisConvDelphiRepairingFormFiles = '*** Repairing form files... ***';
|
||||
lisConvDelphiBeginCodeToolsFailed = 'BeginCodeTools failed!';
|
||||
lisConvDelphiError = 'Error="%s"';
|
||||
lisConvDelphiFailedConvertingUnit = 'Failed converting unit';
|
||||
lisConvDelphiFailedToConvertUnit = 'Failed to convert unit%s%s%s';
|
||||
lisConvDelphiUnitnameExistsTwice = 'Unitname exists twice';
|
||||
lisConvDelphiThereAreTwoUnitsWithTheSameUnitname = 'There are two units '
|
||||
+'with the same unitname:%s%s%s%s%s';
|
||||
lisConvDelphiRemoveFirst = 'Remove first';
|
||||
lisConvDelphiRemoveSecond = 'Remove second';
|
||||
lisConvDelphiKeepBoth = 'Keep both';
|
||||
lisConvDelphiFindAllUnitFiles = '*** Find all unit files... ***';
|
||||
lisConvDelphiAtThisPointThereShouldBeNoMissingUnits = 'At this point there '
|
||||
+'should be no missing units!';
|
||||
lisConvDelphiConvertingUnitFiles = '*** Converting unit files... ***';
|
||||
lisConvDelphiPackageNameExists = 'Package name exists';
|
||||
lisConvDelphiProjOmittedUnit = 'Omitted unit %s from project';
|
||||
lisConvDelphiAddedPackageRequirement = 'Added Package %s as a requirement.';
|
||||
lisConvDelphiThereIsAlreadyAPackageWithTheNamePleaseCloseThisPa = 'There is '
|
||||
+'already a package with the name "%s"%sPlease close this package first.';
|
||||
|
Loading…
Reference in New Issue
Block a user