mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-15 13:30:40 +01:00
Converter: Change unit name to match disk name unless the disk name is all lowercase.
git-svn-id: trunk@41593 -
This commit is contained in:
parent
173ff71396
commit
aa5f6fd0f7
@ -95,6 +95,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function Convert: TModalResult;
|
function Convert: TModalResult;
|
||||||
function FindApptypeConsole: boolean;
|
function FindApptypeConsole: boolean;
|
||||||
|
function RenameUnitIfNeeded: boolean;
|
||||||
function RenameResourceDirectives: boolean;
|
function RenameResourceDirectives: boolean;
|
||||||
function FixMainClassAncestor(const AClassName: string;
|
function FixMainClassAncestor(const AClassName: string;
|
||||||
AReplaceTypes: TStringToStringTree): boolean;
|
AReplaceTypes: TStringToStringTree): boolean;
|
||||||
@ -215,6 +216,7 @@ begin
|
|||||||
fCTLink.SrcCache.BeginUpdate;
|
fCTLink.SrcCache.BeginUpdate;
|
||||||
try
|
try
|
||||||
// these changes can be applied together without rescan
|
// these changes can be applied together without rescan
|
||||||
|
if not RenameUnitIfNeeded then exit;
|
||||||
if not AddModeDelphiDirective then exit;
|
if not AddModeDelphiDirective then exit;
|
||||||
if not RenameResourceDirectives then exit;
|
if not RenameResourceDirectives then exit;
|
||||||
if fCTLink.Settings.FuncReplaceMode=rsEnabled then
|
if fCTLink.Settings.FuncReplaceMode=rsEnabled then
|
||||||
@ -243,6 +245,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TConvDelphiCodeTool.RenameUnitIfNeeded: boolean;
|
||||||
|
// Change the unit name to match the disk name unless the disk name is all lowercase.
|
||||||
|
var
|
||||||
|
NamePos: TAtomPosition;
|
||||||
|
DiskNm, UnitNm: String;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
//BuildTree(lsrSourceName);
|
||||||
|
with fCTLink do begin
|
||||||
|
DiskNm := ExtractFileNameOnly(Code.Filename);
|
||||||
|
if LowerCase(DiskNm)<>DiskNm then begin // Lowercase name is found always.
|
||||||
|
if not CodeTool.GetSourceNamePos(NamePos) then exit;
|
||||||
|
UnitNm:=copy(CodeTool.Src, NamePos.StartPos, NamePos.EndPos-NamePos.StartPos);
|
||||||
|
if DiskNm<>UnitNm then begin
|
||||||
|
SrcCache.MainScanner:=CodeTool.Scanner;
|
||||||
|
SrcCache.Replace(gtNone, gtNone, NamePos.StartPos, NamePos.EndPos, DiskNm);
|
||||||
|
if not SrcCache.Apply then exit;
|
||||||
|
IDEMessagesWindow.AddMsg(Format('Fixed unit name from %s to %s.',
|
||||||
|
[UnitNm, DiskNm]), '', -1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
function TConvDelphiCodeTool.AddModeDelphiDirective: boolean;
|
function TConvDelphiCodeTool.AddModeDelphiDirective: boolean;
|
||||||
var
|
var
|
||||||
ModeDirectivePos: integer;
|
ModeDirectivePos: integer;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user