IDE: Move a BuildMode related function to BuildModesManager.

git-svn-id: trunk@58962 -
This commit is contained in:
juha 2018-09-12 11:18:18 +00:00
parent 8fd406ca25
commit 2cfe697409
2 changed files with 60 additions and 60 deletions

View File

@ -123,6 +123,7 @@ procedure UpdateBuildModeCombo(aCombo: TComboBox);
// Functions dealing with many BuildModes. They depend on TBuildModesCheckList. // Functions dealing with many BuildModes. They depend on TBuildModesCheckList.
function AddPathToBuildModes(aPath, CurDirectory: string; IsIncludeFile: Boolean): Boolean; function AddPathToBuildModes(aPath, CurDirectory: string; IsIncludeFile: Boolean): Boolean;
procedure RemovePathFromBuildModes(ObsoletePaths: String; pcos: TParsedCompilerOptString);
function BuildManyModes: Boolean; function BuildManyModes: Boolean;
// Check if UnitDirectory is part of the Unit Search Paths. // Check if UnitDirectory is part of the Unit Search Paths.
@ -241,6 +242,64 @@ begin
end; end;
end; end;
procedure RemovePathFromBuildModes(ObsoletePaths: String; pcos: TParsedCompilerOptString);
var
bm: TProjectBuildMode;
DlgCapt, DlgMsg: String;
ProjPaths, CurDir, ResolvedDir, PrevResolvedDir: String;
i, p, OldP: Integer;
QRes: TModalResult;
begin
if pcos=pcosUnitPath then begin
DlgCapt:=lisRemoveUnitPath;
DlgMsg:=lisTheDirectoryContainsNoProjectUnitsAnyMoreRemoveThi;
end
else begin // pcos=pcosIncludePath
DlgCapt:=lisRemoveIncludePath;
DlgMsg:=lisTheDirectoryContainsNoProjectIncludeFilesAnyMoreRe;
end;
QRes:=mrNone;
i:=0;
// Iterate all build modes until the user chooses to cancel.
PrevResolvedDir:='';
while (i < Project1.BuildModes.Count) and (QRes in [mrNone,mrYes]) do
begin
bm:=Project1.BuildModes[i];
p:=1;
repeat
OldP:=p;
if pcos=pcosUnitPath then
ProjPaths:=bm.CompilerOptions.OtherUnitFiles
else
ProjPaths:=bm.CompilerOptions.IncludePath;
CurDir:=GetNextDirectoryInSearchPath(ProjPaths,p);
if CurDir='' then break;
// Find build modes that have unneeded search paths
ResolvedDir:=bm.CompilerOptions.ParsedOpts.DoParseOption(CurDir,pcos,false);
if (ResolvedDir<>'')
and (SearchDirectoryInSearchPath(ObsoletePaths,ResolvedDir)>0) then begin
// Ask confirmation once for each path.
// In fact there should be only one path after one source file is removed.
if (QRes=mrNone) or ((PrevResolvedDir<>'') and (PrevResolvedDir<>ResolvedDir)) then
QRes:=IDEQuestionDialog(DlgCapt,Format(DlgMsg,[CurDir]),
mtConfirmation, [mrYes, lisRemove,
mrNo, lisKeep2], '');
if QRes=mrYes then begin
// remove
if pcos=pcosUnitPath then
bm.CompilerOptions.OtherUnitFiles:=RemoveSearchPaths(ProjPaths,CurDir)
else
bm.CompilerOptions.IncludePath:=RemoveSearchPaths(ProjPaths,CurDir);
p:=OldP;
end;
PrevResolvedDir:=ResolvedDir;
end;
until false;
Inc(i);
end;
end;
function BuildManyModes(): Boolean; function BuildManyModes(): Boolean;
var var
ModeCnt: Integer; ModeCnt: Integer;

View File

@ -43,7 +43,7 @@ uses
BasicCodeTools, CodeToolsStructs, CodeToolManager, FileProcs, DefineTemplates, BasicCodeTools, CodeToolsStructs, CodeToolManager, FileProcs, DefineTemplates,
CodeCache, CodeTree, FindDeclarationTool, KeywordFuncLists, CodeCache, CodeTree, FindDeclarationTool, KeywordFuncLists,
// IdeIntf // IdeIntf
IDEDialogs, PropEdits, IDEMsgIntf, LazIDEIntf, MenuIntf, NewItemIntf, CompOptsIntf, IDEDialogs, PropEdits, IDEMsgIntf, LazIDEIntf, MenuIntf, NewItemIntf,
IDEWindowIntf, ProjectIntf, PackageIntf, PackageDependencyIntf, FormEditingIntf, IDEWindowIntf, ProjectIntf, PackageIntf, PackageDependencyIntf, FormEditingIntf,
IDEExternToolIntf, ObjectInspector, UnitResources, ComponentReg, IDEExternToolIntf, ObjectInspector, UnitResources, ComponentReg,
SrcEditorIntf, EditorSyntaxHighlighterDef, SrcEditorIntf, EditorSyntaxHighlighterDef,
@ -173,7 +173,6 @@ type
function CheckMainSrcLCLInterfaces(Silent: boolean): TModalResult; function CheckMainSrcLCLInterfaces(Silent: boolean): TModalResult;
function FileExistsInIDE(const Filename: string; function FileExistsInIDE(const Filename: string;
SearchFlags: TProjectFileSearchFlags): boolean; SearchFlags: TProjectFileSearchFlags): boolean;
procedure RemovePathFromBuildModes(ObsoletePaths: String; pcos: TParsedCompilerOptString);
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
@ -7308,64 +7307,6 @@ begin
//DebugLn(['TLazSourceFileManager.UnitComponentIsUsed ',AnUnitInfo.Filename,' ',dbgs(AnUnitInfo.Flags)]); //DebugLn(['TLazSourceFileManager.UnitComponentIsUsed ',AnUnitInfo.Filename,' ',dbgs(AnUnitInfo.Flags)]);
end; end;
procedure TLazSourceFileManager.RemovePathFromBuildModes(ObsoletePaths: String;
pcos: TParsedCompilerOptString);
var
bm: TProjectBuildMode;
DlgCapt, DlgMsg: String;
ProjPaths, CurDir, ResolvedDir, PrevResolvedDir: String;
i, p, OldP: Integer;
QRes: TModalResult;
begin
if pcos=pcosUnitPath then begin
DlgCapt:=lisRemoveUnitPath;
DlgMsg:=lisTheDirectoryContainsNoProjectUnitsAnyMoreRemoveThi;
end
else begin // pcos=pcosIncludePath
DlgCapt:=lisRemoveIncludePath;
DlgMsg:=lisTheDirectoryContainsNoProjectIncludeFilesAnyMoreRe;
end;
QRes:=mrNone;
i:=0;
// Iterate all build modes until the user chooses to cancel.
PrevResolvedDir:='';
while (i < Project1.BuildModes.Count) and (QRes in [mrNone,mrYes]) do begin
bm:=Project1.BuildModes[i];
p:=1;
repeat
OldP:=p;
if pcos=pcosUnitPath then
ProjPaths:=bm.CompilerOptions.OtherUnitFiles
else
ProjPaths:=bm.CompilerOptions.IncludePath;
CurDir:=GetNextDirectoryInSearchPath(ProjPaths,p);
if CurDir='' then break;
// Find build modes that have unneeded search paths
ResolvedDir:=bm.CompilerOptions.ParsedOpts.DoParseOption(CurDir,pcos,false);
if (ResolvedDir<>'')
and (SearchDirectoryInSearchPath(ObsoletePaths,ResolvedDir)>0) then begin
// Ask confirmation once for each path.
// In fact there should be only one path after one source file is removed.
if (QRes=mrNone) or ((PrevResolvedDir<>'') and (PrevResolvedDir<>ResolvedDir)) then
QRes:=IDEQuestionDialog(DlgCapt,Format(DlgMsg,[CurDir]),
mtConfirmation, [mrYes, lisRemove,
mrNo, lisKeep2], '');
if QRes=mrYes then begin
// remove
if pcos=pcosUnitPath then
bm.CompilerOptions.OtherUnitFiles:=RemoveSearchPaths(ProjPaths,CurDir)
else
bm.CompilerOptions.IncludePath:=RemoveSearchPaths(ProjPaths,CurDir);
p:=OldP;
end;
PrevResolvedDir:=ResolvedDir;
end;
until false;
Inc(i);
end;
end;
function TLazSourceFileManager.RemoveFilesFromProject(UnitInfos: TFPList): TModalResult; function TLazSourceFileManager.RemoveFilesFromProject(UnitInfos: TFPList): TModalResult;
var var
AnUnitInfo: TUnitInfo; AnUnitInfo: TUnitInfo;