mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 01:49:25 +02:00
IDE: Improve renaming project unit filenames to lowercase. Still not perfect. Issue #10370.
This commit is contained in:
parent
d7234ffa6e
commit
848d1492d9
@ -718,7 +718,6 @@ resourcestring
|
|||||||
+'%sRename it to lowercase?';
|
+'%sRename it to lowercase?';
|
||||||
lisRenameToLowercase = 'Rename to lowercase';
|
lisRenameToLowercase = 'Rename to lowercase';
|
||||||
lisKeepName = 'Keep name';
|
lisKeepName = 'Keep name';
|
||||||
lisAmbiguousFilesFound = 'Ambiguous files found';
|
|
||||||
lisThereAreOtherFilesInTheDirectoryWithTheSameName = 'There are other files in '
|
lisThereAreOtherFilesInTheDirectoryWithTheSameName = 'There are other files in '
|
||||||
+'the directory with the same name,'
|
+'the directory with the same name,'
|
||||||
+'%swhich only differ in case:'
|
+'%swhich only differ in case:'
|
||||||
@ -5306,7 +5305,6 @@ resourcestring
|
|||||||
lisShort = 'Short:';
|
lisShort = 'Short:';
|
||||||
lisInsertUrlTag = 'Insert url tag';
|
lisInsertUrlTag = 'Insert url tag';
|
||||||
lisInsertPrintshortTag2 = 'Insert printshort tag';
|
lisInsertPrintshortTag2 = 'Insert printshort tag';
|
||||||
lisDeleteOldFile2 = 'Delete old file?';
|
|
||||||
lisTheUnitSearchPathOfContainsTheSourceDirectoryOfPac = 'The unit search '
|
lisTheUnitSearchPathOfContainsTheSourceDirectoryOfPac = 'The unit search '
|
||||||
+'path of "%s" contains the source directory "%s" of package %s';
|
+'path of "%s" contains the source directory "%s" of package %s';
|
||||||
lisFPCVersionEG222 = 'FPC Version (e.g. 2.2.2)';
|
lisFPCVersionEG222 = 'FPC Version (e.g. 2.2.2)';
|
||||||
|
@ -1834,7 +1834,6 @@ begin
|
|||||||
try
|
try
|
||||||
Result:=ActionForFiles;
|
Result:=ActionForFiles;
|
||||||
finally
|
finally
|
||||||
// all changes were handled automatically by events, just clear the logs
|
|
||||||
CodeToolBoss.SourceCache.ClearAllSourceLogEntries;
|
CodeToolBoss.SourceCache.ClearAllSourceLogEntries;
|
||||||
Project1.EndUpdate;
|
Project1.EndUpdate;
|
||||||
end;
|
end;
|
||||||
@ -1931,33 +1930,19 @@ function TRenameFilesSelector.ActionForFiles: TModalResult;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
AnUnitInfo: TUnitInfo;
|
AnUnitInfo: TUnitInfo;
|
||||||
UnitPath, ShortUnitN, FileN, LowerFileN, FullFileName: String;
|
|
||||||
begin
|
begin
|
||||||
Assert(fUnitInfos.Count > 0, 'TRemoveFilesSelector.ActionForFiles: No files');
|
Assert(fUnitInfos.Count > 0, 'TRemoveFilesSelector.ActionForFiles: No files');
|
||||||
|
Result:=mrOK;
|
||||||
for i:=0 to fUnitInfos.Count-1 do
|
for i:=0 to fUnitInfos.Count-1 do
|
||||||
begin
|
begin
|
||||||
AnUnitInfo:=TUnitInfo(fUnitInfos[i]);
|
AnUnitInfo:=TUnitInfo(fUnitInfos[i]);
|
||||||
Assert(AnUnitInfo.IsPartOfProject, 'TRenameFilesSelector.ActionForFiles: '
|
Assert(AnUnitInfo.IsPartOfProject, 'TRenameFilesSelector.ActionForFiles: '
|
||||||
+ AnUnitInfo.Unit_Name + ' is not part of project');
|
+ AnUnitInfo.Unit_Name + ' is not part of project');
|
||||||
UnitPath:=ExtractFilePath(AnUnitInfo.Filename);
|
Result:=RenameUnitLowerCase(AnUnitInfo, false);
|
||||||
FileN:=ExtractFileName(AnUnitInfo.Filename);
|
if Result<>mrOK then exit;
|
||||||
ShortUnitN:=ExtractFileNameOnly(FileN);
|
|
||||||
LowerFileN:=LowerCase(FileN);
|
|
||||||
DebugLn(['TRenameFilesSelector.ActionForFiles: UnitPath=', UnitPath,
|
|
||||||
', FileN=', FileN, ', LowerFileN=', LowerFileN]);
|
|
||||||
if LowerFileN<>FileN then begin
|
|
||||||
FullFileName:=UnitPath+LowerFileN;
|
|
||||||
Result:=RenameFileWithErrorDialogs(AnUnitInfo.Filename, FullFileName, [mbAbort]);
|
|
||||||
if Result<>mrOK then begin
|
|
||||||
//MainIDE.DoJumpToCodeToolBossError; // ToDo
|
|
||||||
exit(mrCancel);
|
|
||||||
end;
|
|
||||||
AnUnitInfo.Unit_Name:=ShortUnitN;
|
|
||||||
AnUnitInfo.Modified:=true;
|
|
||||||
//AnUnitInfo.ReadUnitSource(false,false);
|
|
||||||
Project1.Modified:=true;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
if Result=mrOK then
|
||||||
|
Result:=SaveProject([sfDoNotSaveVirtualFiles,sfCanAbort]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
@ -5900,7 +5885,7 @@ begin
|
|||||||
else
|
else
|
||||||
S:=Format(lisThereAreOtherFilesInTheDirectoryWithTheSameName,
|
S:=Format(lisThereAreOtherFilesInTheDirectoryWithTheSameName,
|
||||||
[LineEnding, LineEnding, AmbiguousFiles.Text, LineEnding]);
|
[LineEnding, LineEnding, AmbiguousFiles.Text, LineEnding]);
|
||||||
Result:=IDEMessageDialog(lisAmbiguousFilesFound, S,
|
Result:=IDEMessageDialog(lisAmbiguousFileFound, S,
|
||||||
mtWarning,[mbYes,mbNo,mbAbort]);
|
mtWarning,[mbYes,mbNo,mbAbort]);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
if Result=mrYes then begin
|
if Result=mrYes then begin
|
||||||
@ -5942,7 +5927,7 @@ begin
|
|||||||
// delete old pas, .pp, .ppu
|
// delete old pas, .pp, .ppu
|
||||||
if (CompareFilenames(NewFilename,OldFilename)<>0)
|
if (CompareFilenames(NewFilename,OldFilename)<>0)
|
||||||
and OldFileExisted then begin
|
and OldFileExisted then begin
|
||||||
if IDEMessageDialog(lisDeleteOldFile2, Format(lisDeleteOldFile,[OldFilename]),
|
if IDEMessageDialog(lisDelete2, Format(lisDeleteOldFile,[OldFilename]),
|
||||||
mtConfirmation,[mbYes,mbNo])=mrYes then
|
mtConfirmation,[mbYes,mbNo])=mrYes then
|
||||||
begin
|
begin
|
||||||
Result:=DeleteFileInteractive(OldFilename,[mbAbort]);
|
Result:=DeleteFileInteractive(OldFilename,[mbAbort]);
|
||||||
|
Loading…
Reference in New Issue
Block a user