mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 23:40:35 +02:00
IDE: refactor, move 3 methods from MainIDE to SourceFileManager.
git-svn-id: trunk@45265 -
This commit is contained in:
parent
91a561581b
commit
debd43a9dc
186
ide/main.pp
186
ide/main.pp
@ -892,8 +892,7 @@ type
|
|||||||
Flags: TFindSourceFlags): string; override;
|
Flags: TFindSourceFlags): string; override;
|
||||||
function DoLoadMemoryStreamFromFile(MemStream: TMemoryStream;
|
function DoLoadMemoryStreamFromFile(MemStream: TMemoryStream;
|
||||||
const AFilename:string): TModalResult;
|
const AFilename:string): TModalResult;
|
||||||
function DoRenameUnitLowerCase(AnUnitInfo: TUnitInfo;
|
function DoRenameUnitLowerCase(AnUnitInfo: TUnitInfo; AskUser: boolean): TModalresult;
|
||||||
AskUser: boolean): TModalresult;
|
|
||||||
function DoCheckFilesOnDisk(Instantaneous: boolean = false): TModalResult; override;
|
function DoCheckFilesOnDisk(Instantaneous: boolean = false): TModalResult; override;
|
||||||
function DoPublishModule(Options: TPublishModuleOptions;
|
function DoPublishModule(Options: TPublishModuleOptions;
|
||||||
const SrcDirectory, DestDirectory: string
|
const SrcDirectory, DestDirectory: string
|
||||||
@ -6671,154 +6670,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoAddActiveUnitToProject: TModalResult;
|
function TMainIDE.DoAddActiveUnitToProject: TModalResult;
|
||||||
var
|
|
||||||
ActiveSourceEditor: TSourceEditor;
|
|
||||||
ActiveUnitInfo: TUnitInfo;
|
|
||||||
s, ShortUnitName: string;
|
|
||||||
OkToAdd: boolean;
|
|
||||||
Owners: TFPList;
|
|
||||||
i: Integer;
|
|
||||||
APackage: TLazPackage;
|
|
||||||
MsgResult: TModalResult;
|
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=SourceFileMgr.AddActiveUnitToProject;
|
||||||
ActiveSourceEditor:=nil;
|
|
||||||
if not BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]) then exit;
|
|
||||||
if (ActiveUnitInfo=nil) then exit;
|
|
||||||
if ActiveUnitInfo.IsPartOfProject then begin
|
|
||||||
if not ActiveUnitInfo.IsVirtual then
|
|
||||||
s:=Format(lisTheFile, ['"', ActiveUnitInfo.Filename, '"'])
|
|
||||||
else
|
|
||||||
s:=Format(lisTheFile, ['"', ActiveSourceEditor.PageName, '"']);
|
|
||||||
s:=Format(lisisAlreadyPartOfTheProject, [s]);
|
|
||||||
IDEMessageDialog(lisInformation, s, mtInformation, [mbOk]);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
if not ActiveUnitInfo.IsVirtual then
|
|
||||||
s:='"'+ActiveUnitInfo.Filename+'"'
|
|
||||||
else
|
|
||||||
s:='"'+ActiveSourceEditor.PageName+'"';
|
|
||||||
if (ActiveUnitInfo.Unit_Name<>'')
|
|
||||||
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.Unit_Name,true,ActiveUnitInfo)>=0) then
|
|
||||||
begin
|
|
||||||
IDEMessageDialog(lisInformation, Format(
|
|
||||||
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
|
||||||
mtInformation, [mbOk]);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Owners:=PkgBoss.GetPossibleOwnersOfUnit(ActiveUnitInfo.Filename,[]);
|
|
||||||
try
|
|
||||||
if (Owners<>nil) then begin
|
|
||||||
for i:=0 to Owners.Count-1 do begin
|
|
||||||
if TObject(Owners[i]) is TLazPackage then begin
|
|
||||||
APackage:=TLazPackage(Owners[i]);
|
|
||||||
MsgResult:=IDEQuestionDialog(lisAddPackageRequirement,
|
|
||||||
Format(lisTheUnitBelongsToPackage, [APackage.IDAsString]),
|
|
||||||
mtConfirmation, [mrYes, lisAddPackageToProject2,
|
|
||||||
mrIgnore, lisAddUnitNotRecommended, mrCancel],'');
|
|
||||||
case MsgResult of
|
|
||||||
mrYes:
|
|
||||||
begin
|
|
||||||
PkgBoss.AddProjectDependency(Project1,APackage);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
mrIgnore: ;
|
|
||||||
else
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
Owners.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename)
|
|
||||||
and (EnvironmentOptions.CharcaseFileAction<>ccfaIgnore) then
|
|
||||||
begin
|
|
||||||
// ask user to apply naming conventions
|
|
||||||
Result:=DoRenameUnitLowerCase(ActiveUnitInfo,true);
|
|
||||||
if Result=mrIgnore then Result:=mrOk;
|
|
||||||
if Result<>mrOk then begin
|
|
||||||
debugln('TMainIDE.DoAddActiveUnitToProject A DoRenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if IDEMessageDialog(lisConfirmation, Format(lisAddToProject, [s]),
|
|
||||||
mtConfirmation, [mbYes, mbCancel]) in [mrOk, mrYes]
|
|
||||||
then begin
|
|
||||||
OkToAdd:=True;
|
|
||||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
|
||||||
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(ActiveUnitInfo,False,False)
|
|
||||||
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
|
||||||
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(ActiveUnitInfo,False,True);
|
|
||||||
if OkToAdd then begin
|
|
||||||
ActiveUnitInfo.IsPartOfProject:=true;
|
|
||||||
Project1.Modified:=true;
|
|
||||||
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
|
||||||
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
|
||||||
then begin
|
|
||||||
ActiveUnitInfo.ReadUnitNameFromSource(false);
|
|
||||||
ShortUnitName:=ActiveUnitInfo.CreateUnitName;
|
|
||||||
if (ShortUnitName<>'') then begin
|
|
||||||
if CodeToolBoss.AddUnitToMainUsesSection(Project1.MainUnitInfo.Source,ShortUnitName,'')
|
|
||||||
then
|
|
||||||
Project1.MainUnitInfo.Modified:=true;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoRemoveFromProjectDialog: TModalResult;
|
function TMainIDE.DoRemoveFromProjectDialog: TModalResult;
|
||||||
var
|
|
||||||
ViewUnitEntries: TViewUnitEntries;
|
|
||||||
i:integer;
|
|
||||||
AName: string;
|
|
||||||
AnUnitInfo: TUnitInfo;
|
|
||||||
UnitInfos: TFPList;
|
|
||||||
UEntry: TViewUnitsEntry;
|
|
||||||
const
|
|
||||||
MultiSelectCheckedState: Boolean = true;
|
|
||||||
Begin
|
Begin
|
||||||
if Project1=nil then exit(mrCancel);
|
Result:=SourceFileMgr.RemoveFromProjectDialog;
|
||||||
ViewUnitEntries := TViewUnitEntries.Create;
|
|
||||||
UnitInfos:=nil;
|
|
||||||
try
|
|
||||||
for i := 0 to Project1.UnitCount-1 do
|
|
||||||
begin
|
|
||||||
AnUnitInfo:=Project1.Units[i];
|
|
||||||
if (AnUnitInfo.IsPartOfProject) and (i<>Project1.MainUnitID) then
|
|
||||||
begin
|
|
||||||
AName := Project1.RemoveProjectPathFromFilename(AnUnitInfo.FileName);
|
|
||||||
ViewUnitEntries.Add(AName,AnUnitInfo.FileName,i,false);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if ShowViewUnitsDlg(ViewUnitEntries, true, MultiSelectCheckedState,
|
|
||||||
lisRemoveFromProject, piUnit) <> mrOk then
|
|
||||||
exit(mrOk);
|
|
||||||
{ This is where we check what the user selected. }
|
|
||||||
UnitInfos:=TFPList.Create;
|
|
||||||
for UEntry in ViewUnitEntries do
|
|
||||||
begin
|
|
||||||
if UEntry.Selected then
|
|
||||||
begin
|
|
||||||
if UEntry.ID<0 then continue;
|
|
||||||
AnUnitInfo:=Project1.Units[UEntry.ID];
|
|
||||||
if AnUnitInfo.IsPartOfProject then
|
|
||||||
UnitInfos.Add(AnUnitInfo);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if UnitInfos.Count>0 then
|
|
||||||
Result:=SourceFileMgr.RemoveFilesFromProject(Project1,UnitInfos)
|
|
||||||
else
|
|
||||||
Result:=mrOk;
|
|
||||||
finally
|
|
||||||
UnitInfos.Free;
|
|
||||||
ViewUnitEntries.Free;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoWarnAmbiguousFiles: TModalResult;
|
function TMainIDE.DoWarnAmbiguousFiles: TModalResult;
|
||||||
@ -8445,43 +8303,9 @@ begin
|
|||||||
until Result<>mrRetry;
|
until Result<>mrRetry;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoRenameUnitLowerCase(AnUnitInfo: TUnitInfo;
|
function TMainIDE.DoRenameUnitLowerCase(AnUnitInfo: TUnitInfo; AskUser: boolean): TModalresult;
|
||||||
AskUser: boolean): TModalresult;
|
|
||||||
var
|
|
||||||
OldFilename: String;
|
|
||||||
OldShortFilename: String;
|
|
||||||
NewFilename: String;
|
|
||||||
NewShortFilename: String;
|
|
||||||
LFMCode, LRSCode: TCodeBuffer;
|
|
||||||
NewUnitName: String;
|
|
||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=SourceFileMgr.RenameUnitLowerCase(AnUnitInfo, AskUser);
|
||||||
OldFilename:=AnUnitInfo.Filename;
|
|
||||||
// check if file is unit
|
|
||||||
if not FilenameIsPascalUnit(OldFilename) then exit;
|
|
||||||
// check if file is already lowercase (or it does not matter in current OS)
|
|
||||||
OldShortFilename:=ExtractFilename(OldFilename);
|
|
||||||
NewShortFilename:=lowercase(OldShortFilename);
|
|
||||||
if CompareFilenames(OldShortFilename,NewShortFilename)=0 then exit;
|
|
||||||
// create new filename
|
|
||||||
NewFilename:=ExtractFilePath(OldFilename)+NewShortFilename;
|
|
||||||
|
|
||||||
// rename unit
|
|
||||||
if AskUser then begin
|
|
||||||
Result:=IDEQuestionDialog(lisFileNotLowercase,
|
|
||||||
Format(lisTheUnitIsNotLowercaseTheFreePascalCompiler,
|
|
||||||
['"', OldFilename, '"', LineEnding, LineEnding, LineEnding]),
|
|
||||||
mtConfirmation,[mrYes,mrIgnore,lisNo,mrAbort],'');
|
|
||||||
if Result<>mrYes then exit;
|
|
||||||
end;
|
|
||||||
NewUnitName:=AnUnitInfo.Unit_Name;
|
|
||||||
if NewUnitName='' then begin
|
|
||||||
AnUnitInfo.ReadUnitNameFromSource(false);
|
|
||||||
NewUnitName:=AnUnitInfo.CreateUnitName;
|
|
||||||
end;
|
|
||||||
LFMCode:=nil;
|
|
||||||
LRSCode:=nil;
|
|
||||||
Result:=SourceFileMgr.RenameUnit(AnUnitInfo,NewFilename,NewUnitName,LFMCode,LRSCode);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoCheckFilesOnDisk(Instantaneous: boolean): TModalResult;
|
function TMainIDE.DoCheckFilesOnDisk(Instantaneous: boolean): TModalResult;
|
||||||
|
@ -41,7 +41,7 @@ uses
|
|||||||
ComponentReg, SourceEditor, EditorOptions, CustomFormEditor, FormEditor,
|
ComponentReg, SourceEditor, EditorOptions, CustomFormEditor, FormEditor,
|
||||||
EmptyMethodsDlg, BaseDebugManager, ControlSelection, TransferMacros,
|
EmptyMethodsDlg, BaseDebugManager, ControlSelection, TransferMacros,
|
||||||
EnvironmentOpts, BuildManager, Designer, EditorMacroListViewer,
|
EnvironmentOpts, BuildManager, Designer, EditorMacroListViewer,
|
||||||
KeywordFuncLists, FindRenameIdentifier, GenericCheckList,
|
KeywordFuncLists, FindRenameIdentifier, GenericCheckList, ViewUnit_Dlg,
|
||||||
{$IFDEF EnableNewExtTools}
|
{$IFDEF EnableNewExtTools}
|
||||||
etMessagesWnd,
|
etMessagesWnd,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -100,6 +100,8 @@ type
|
|||||||
UseWindowID: Boolean = False): TModalResult; // WindowIndex is WindowID
|
UseWindowID: Boolean = False): TModalResult; // WindowIndex is WindowID
|
||||||
function OpenFileAtCursor(ActiveSrcEdit: TSourceEditor;
|
function OpenFileAtCursor(ActiveSrcEdit: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo): TModalResult;
|
ActiveUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
function AddActiveUnitToProject: TModalResult;
|
||||||
|
function RemoveFromProjectDialog: TModalResult;
|
||||||
function InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
function InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
||||||
function InitOpenedProjectFile(AFileName: string; Flags: TOpenFlags): TModalResult;
|
function InitOpenedProjectFile(AFileName: string; Flags: TOpenFlags): TModalResult;
|
||||||
procedure NewProjectFromFile;
|
procedure NewProjectFromFile;
|
||||||
@ -133,6 +135,7 @@ type
|
|||||||
OkOnCodeErrors: boolean): TModalResult;
|
OkOnCodeErrors: boolean): TModalResult;
|
||||||
function RenameUnit(AnUnitInfo: TUnitInfo; NewFilename, NewUnitName: string;
|
function RenameUnit(AnUnitInfo: TUnitInfo; NewFilename, NewUnitName: string;
|
||||||
var LFMCode, LRSCode: TCodeBuffer): TModalResult;
|
var LFMCode, LRSCode: TCodeBuffer): TModalResult;
|
||||||
|
function RenameUnitLowerCase(AnUnitInfo: TUnitInfo; AskUser: boolean): TModalresult;
|
||||||
|
|
||||||
// methods for 'open unit' and 'open main unit'
|
// methods for 'open unit' and 'open main unit'
|
||||||
private
|
private
|
||||||
@ -1881,6 +1884,157 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazSourceFileManager.AddActiveUnitToProject: TModalResult;
|
||||||
|
var
|
||||||
|
ActiveSourceEditor: TSourceEditor;
|
||||||
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
s, ShortUnitName: string;
|
||||||
|
OkToAdd: boolean;
|
||||||
|
Owners: TFPList;
|
||||||
|
i: Integer;
|
||||||
|
APackage: TLazPackage;
|
||||||
|
MsgResult: TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=mrCancel;
|
||||||
|
ActiveSourceEditor:=nil;
|
||||||
|
if not MainIDE.BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]) then exit;
|
||||||
|
if (ActiveUnitInfo=nil) then exit;
|
||||||
|
if ActiveUnitInfo.IsPartOfProject then begin
|
||||||
|
if not ActiveUnitInfo.IsVirtual then
|
||||||
|
s:=Format(lisTheFile, ['"', ActiveUnitInfo.Filename, '"'])
|
||||||
|
else
|
||||||
|
s:=Format(lisTheFile, ['"', ActiveSourceEditor.PageName, '"']);
|
||||||
|
s:=Format(lisisAlreadyPartOfTheProject, [s]);
|
||||||
|
IDEMessageDialog(lisInformation, s, mtInformation, [mbOk]);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if not ActiveUnitInfo.IsVirtual then
|
||||||
|
s:='"'+ActiveUnitInfo.Filename+'"'
|
||||||
|
else
|
||||||
|
s:='"'+ActiveSourceEditor.PageName+'"';
|
||||||
|
if (ActiveUnitInfo.Unit_Name<>'')
|
||||||
|
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.Unit_Name,true,ActiveUnitInfo)>=0) then
|
||||||
|
begin
|
||||||
|
IDEMessageDialog(lisInformation, Format(
|
||||||
|
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
||||||
|
mtInformation, [mbOk]);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Owners:=PkgBoss.GetPossibleOwnersOfUnit(ActiveUnitInfo.Filename,[]);
|
||||||
|
try
|
||||||
|
if (Owners<>nil) then begin
|
||||||
|
for i:=0 to Owners.Count-1 do begin
|
||||||
|
if TObject(Owners[i]) is TLazPackage then begin
|
||||||
|
APackage:=TLazPackage(Owners[i]);
|
||||||
|
MsgResult:=IDEQuestionDialog(lisAddPackageRequirement,
|
||||||
|
Format(lisTheUnitBelongsToPackage, [APackage.IDAsString]),
|
||||||
|
mtConfirmation, [mrYes, lisAddPackageToProject2,
|
||||||
|
mrIgnore, lisAddUnitNotRecommended, mrCancel],'');
|
||||||
|
case MsgResult of
|
||||||
|
mrYes:
|
||||||
|
begin
|
||||||
|
PkgBoss.AddProjectDependency(Project1,APackage);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
mrIgnore: ;
|
||||||
|
else
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Owners.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if FilenameIsPascalUnit(ActiveUnitInfo.Filename)
|
||||||
|
and (EnvironmentOptions.CharcaseFileAction<>ccfaIgnore) then
|
||||||
|
begin
|
||||||
|
// ask user to apply naming conventions
|
||||||
|
Result:=RenameUnitLowerCase(ActiveUnitInfo,true);
|
||||||
|
if Result=mrIgnore then Result:=mrOk;
|
||||||
|
if Result<>mrOk then begin
|
||||||
|
DebugLn('AddActiveUnitToProject A RenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if IDEMessageDialog(lisConfirmation, Format(lisAddToProject, [s]),
|
||||||
|
mtConfirmation, [mbYes, mbCancel]) in [mrOk, mrYes]
|
||||||
|
then begin
|
||||||
|
OkToAdd:=True;
|
||||||
|
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||||
|
OkToAdd:=CheckDirIsInSearchPath(ActiveUnitInfo,False,False)
|
||||||
|
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
||||||
|
OkToAdd:=CheckDirIsInSearchPath(ActiveUnitInfo,False,True);
|
||||||
|
if OkToAdd then begin
|
||||||
|
ActiveUnitInfo.IsPartOfProject:=true;
|
||||||
|
Project1.Modified:=true;
|
||||||
|
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
|
||||||
|
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
||||||
|
then begin
|
||||||
|
ActiveUnitInfo.ReadUnitNameFromSource(false);
|
||||||
|
ShortUnitName:=ActiveUnitInfo.CreateUnitName;
|
||||||
|
if (ShortUnitName<>'') then begin
|
||||||
|
if CodeToolBoss.AddUnitToMainUsesSection(Project1.MainUnitInfo.Source,ShortUnitName,'')
|
||||||
|
then
|
||||||
|
Project1.MainUnitInfo.Modified:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLazSourceFileManager.RemoveFromProjectDialog: TModalResult;
|
||||||
|
var
|
||||||
|
ViewUnitEntries: TViewUnitEntries;
|
||||||
|
i:integer;
|
||||||
|
AName: string;
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
|
UnitInfos: TFPList;
|
||||||
|
UEntry: TViewUnitsEntry;
|
||||||
|
const
|
||||||
|
MultiSelectCheckedState: Boolean = true;
|
||||||
|
Begin
|
||||||
|
if Project1=nil then exit(mrCancel);
|
||||||
|
ViewUnitEntries := TViewUnitEntries.Create;
|
||||||
|
UnitInfos:=nil;
|
||||||
|
try
|
||||||
|
for i := 0 to Project1.UnitCount-1 do
|
||||||
|
begin
|
||||||
|
AnUnitInfo:=Project1.Units[i];
|
||||||
|
if (AnUnitInfo.IsPartOfProject) and (i<>Project1.MainUnitID) then
|
||||||
|
begin
|
||||||
|
AName := Project1.RemoveProjectPathFromFilename(AnUnitInfo.FileName);
|
||||||
|
ViewUnitEntries.Add(AName,AnUnitInfo.FileName,i,false);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if ShowViewUnitsDlg(ViewUnitEntries, true, MultiSelectCheckedState,
|
||||||
|
lisRemoveFromProject, piUnit) <> mrOk then
|
||||||
|
exit(mrOk);
|
||||||
|
{ This is where we check what the user selected. }
|
||||||
|
UnitInfos:=TFPList.Create;
|
||||||
|
for UEntry in ViewUnitEntries do
|
||||||
|
begin
|
||||||
|
if UEntry.Selected then
|
||||||
|
begin
|
||||||
|
if UEntry.ID<0 then continue;
|
||||||
|
AnUnitInfo:=Project1.Units[UEntry.ID];
|
||||||
|
if AnUnitInfo.IsPartOfProject then
|
||||||
|
UnitInfos.Add(AnUnitInfo);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if UnitInfos.Count>0 then
|
||||||
|
Result:=RemoveFilesFromProject(Project1,UnitInfos)
|
||||||
|
else
|
||||||
|
Result:=mrOk;
|
||||||
|
finally
|
||||||
|
UnitInfos.Free;
|
||||||
|
ViewUnitEntries.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TLazSourceFileManager.InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
function TLazSourceFileManager.InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
||||||
var
|
var
|
||||||
i:integer;
|
i:integer;
|
||||||
@ -3837,6 +3991,45 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazSourceFileManager.RenameUnitLowerCase(AnUnitInfo: TUnitInfo;
|
||||||
|
AskUser: boolean): TModalresult;
|
||||||
|
var
|
||||||
|
OldFilename: String;
|
||||||
|
OldShortFilename: String;
|
||||||
|
NewFilename: String;
|
||||||
|
NewShortFilename: String;
|
||||||
|
LFMCode, LRSCode: TCodeBuffer;
|
||||||
|
NewUnitName: String;
|
||||||
|
begin
|
||||||
|
Result:=mrOk;
|
||||||
|
OldFilename:=AnUnitInfo.Filename;
|
||||||
|
// check if file is unit
|
||||||
|
if not FilenameIsPascalUnit(OldFilename) then exit;
|
||||||
|
// check if file is already lowercase (or it does not matter in current OS)
|
||||||
|
OldShortFilename:=ExtractFilename(OldFilename);
|
||||||
|
NewShortFilename:=lowercase(OldShortFilename);
|
||||||
|
if CompareFilenames(OldShortFilename,NewShortFilename)=0 then exit;
|
||||||
|
// create new filename
|
||||||
|
NewFilename:=ExtractFilePath(OldFilename)+NewShortFilename;
|
||||||
|
|
||||||
|
// rename unit
|
||||||
|
if AskUser then begin
|
||||||
|
Result:=IDEQuestionDialog(lisFileNotLowercase,
|
||||||
|
Format(lisTheUnitIsNotLowercaseTheFreePascalCompiler,
|
||||||
|
['"', OldFilename, '"', LineEnding, LineEnding, LineEnding]),
|
||||||
|
mtConfirmation,[mrYes,mrIgnore,lisNo,mrAbort],'');
|
||||||
|
if Result<>mrYes then exit;
|
||||||
|
end;
|
||||||
|
NewUnitName:=AnUnitInfo.Unit_Name;
|
||||||
|
if NewUnitName='' then begin
|
||||||
|
AnUnitInfo.ReadUnitNameFromSource(false);
|
||||||
|
NewUnitName:=AnUnitInfo.CreateUnitName;
|
||||||
|
end;
|
||||||
|
LFMCode:=nil;
|
||||||
|
LRSCode:=nil;
|
||||||
|
Result:=RenameUnit(AnUnitInfo,NewFilename,NewUnitName,LFMCode,LRSCode);
|
||||||
|
end;
|
||||||
|
|
||||||
function TLazSourceFileManager.OpenNotExistingFile(const AFileName: string;
|
function TLazSourceFileManager.OpenNotExistingFile(const AFileName: string;
|
||||||
Flags: TOpenFlags): TModalResult;
|
Flags: TOpenFlags): TModalResult;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user