mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 23:20:28 +02:00
Converter: Try to find used units when they are not included in a component package. Improve GUI texts.
This commit is contained in:
parent
9f5e0647a6
commit
45d350bfd2
@ -1420,30 +1420,39 @@ end;
|
||||
function TConvertDelphiProjPack.CheckPackageDep(AUnitName: string): Boolean;
|
||||
// Check if the given unit can be found in existing packages. Add a dependency if found.
|
||||
// This is called only if the unit is reported as missing.
|
||||
// Returns True if a dependency was really added.
|
||||
// Returns True if the unit was found.
|
||||
var
|
||||
Pack: TPkgFile;
|
||||
RegComp: TRegisteredComponent;
|
||||
PackFile: TPkgFile;
|
||||
Dep: TPkgDependency;
|
||||
s: String;
|
||||
begin
|
||||
Result:=False;
|
||||
Pack:=PackageGraph.FindUnitInAllPackages(AUnitName, True);
|
||||
if Assigned(Pack) then begin
|
||||
PackFile:=PackageGraph.FindUnitInAllPackages(AUnitName, True);
|
||||
if PackFile=Nil then begin
|
||||
// Do heuristics. Units of some registered components are not included in
|
||||
// their package file. Try to find 'T' + UnitName. Helps with Indy package.
|
||||
RegComp := IDEComponentPalette.FindRegComponent('T'+AUnitName);
|
||||
if RegComp is TPkgComponent then
|
||||
PackFile:=TPkgComponent(RegComp).PkgFile;
|
||||
end;
|
||||
if Assigned(PackFile) then begin
|
||||
// Found from package: add package to project dependencies and open it.
|
||||
s:=Pack.LazPackage.Name;
|
||||
s:=PackFile.LazPackage.Name;
|
||||
if s='LCLBase' then
|
||||
s:='LCL';
|
||||
Dep:=FindDependencyByName(s);
|
||||
if not Assigned(Dep) then begin
|
||||
if Dep=Nil then begin
|
||||
fProjPack.AddPackageDependency(s);
|
||||
fSettings.AddLogLine(mluNote, Format(lisConvDelphiAddedPackageDependency,[s]),
|
||||
fLazPInfoFilename);
|
||||
Dep:=FindDependencyByName(s);
|
||||
if Assigned(Dep) then
|
||||
PackageGraph.OpenDependency(Dep,false);
|
||||
Result:=True;
|
||||
end;
|
||||
end else begin;
|
||||
Result:=True;
|
||||
end
|
||||
else begin
|
||||
// ToDo: Install the required package automatically from a repository...
|
||||
end;
|
||||
end;
|
||||
|
@ -81,7 +81,7 @@ var
|
||||
MissingUnitsDialog: TMissingUnitsDialog;
|
||||
|
||||
function AskMissingUnits(AMainMissingUnits, AImplMissingUnits: TStrings;
|
||||
AMainUnitName: string; ATargetDelphi: boolean): TModalResult;
|
||||
AUnitName: string; ATargetDelphi: boolean): TModalResult;
|
||||
|
||||
|
||||
implementation
|
||||
@ -89,7 +89,7 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
function AskMissingUnits(AMainMissingUnits, AImplMissingUnits: TStrings;
|
||||
AMainUnitName: string; ATargetDelphi: boolean): TModalResult;
|
||||
AUnitName: string; ATargetDelphi: boolean): TModalResult;
|
||||
var
|
||||
UNFDialog: TMissingUnitsDialog;
|
||||
|
||||
@ -114,7 +114,7 @@ var
|
||||
end;
|
||||
|
||||
var
|
||||
UnitsTitle, s: string;
|
||||
s: string;
|
||||
i: Integer;
|
||||
ImplRemoved: Boolean;
|
||||
begin
|
||||
@ -124,14 +124,13 @@ begin
|
||||
Result:=mrCancel;
|
||||
// A title text containing filename.
|
||||
if (AMainMissingUnits.Count + AImplMissingUnits.Count) = 1 then
|
||||
s:=lisUnitNotFoundInProject
|
||||
s:=lisUnitNotFoundInFile
|
||||
else
|
||||
s:=lisUnitsNotFoundInProject;
|
||||
UnitsTitle:=Format(s, [AMainUnitName]);
|
||||
s:=lisUnitsNotFoundInFile;
|
||||
|
||||
UNFDialog:=TMissingUnitsDialog.Create(nil);
|
||||
with UNFDialog do begin
|
||||
Caption:=UnitsTitle;
|
||||
Caption:=Format(s, [AUnitName]);
|
||||
MissingUnitsGroupBox.Caption:=lisTheseUnitsWereNotFound;
|
||||
ChoicesLabel.Caption:=lisMissingUnitsChoices;
|
||||
SearchButton.Caption:=lisMissingUnitsSearch;
|
||||
|
@ -598,15 +598,15 @@ resourcestring
|
||||
lisMissingUnitsComment = 'Comment Out';
|
||||
lisMissingUnitsForDelphi = 'For Delphi only';
|
||||
lisMissingUnitsSearch = 'Search Unit Path';
|
||||
lisMissingUnitsSkip = 'Skip this Unit';
|
||||
lisMissingUnitsSkip = 'Skip';
|
||||
lisTheseUnitsWereNotFound = 'These units were not found:';
|
||||
lisMissingUnitsChoices = 'Your choices are:';
|
||||
lisMissingUnitsInfo1 = '1) Comment out the selected units.';
|
||||
lisMissingUnitsInfo1b = '1) Use the units only for Delphi.';
|
||||
lisMissingUnitsInfo2 = '2) Search for units. Found paths are added to project settings.';
|
||||
lisMissingUnitsInfo3 = '3) Abort now, install packages or fix paths and try again.';
|
||||
lisUnitNotFoundInProject = 'A unit not found in project %s';
|
||||
lisUnitsNotFoundInProject = 'Units not found in project %s';
|
||||
lisMissingUnitsInfo3 = '3) Leave these units in uses sections as they are.';
|
||||
lisUnitNotFoundInFile = 'A unit not found in file %s';
|
||||
lisUnitsNotFoundInFile = 'Units not found in file %s';
|
||||
lisProjectPathHint = 'Directory where project''s main file must be';
|
||||
lisAddDelphiDefine = 'Add defines simulating Delphi7';
|
||||
lisAddDelphiDefineHint = 'Useful when the code has checks for supported compiler versions';
|
||||
|
Loading…
Reference in New Issue
Block a user