mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 14:31:29 +02:00
IDE: Fix checking new unique unit name against projectinfo name. Move nested funcs out.
This commit is contained in:
parent
1c44ec9237
commit
43da1e05f3
@ -823,6 +823,7 @@ type
|
|||||||
procedure SetStorePathDelim(const AValue: TPathDelimSwitch);
|
procedure SetStorePathDelim(const AValue: TPathDelimSwitch);
|
||||||
procedure SetTargetFilename(const NewTargetFilename: string);
|
procedure SetTargetFilename(const NewTargetFilename: string);
|
||||||
procedure SourceDirectoriesChanged(Sender: TObject);
|
procedure SourceDirectoriesChanged(Sender: TObject);
|
||||||
|
function UnitNameExists(const AnUnitName: string): boolean;
|
||||||
procedure UpdateFileBuffer;
|
procedure UpdateFileBuffer;
|
||||||
procedure UpdateProjectDirectory;
|
procedure UpdateProjectDirectory;
|
||||||
procedure UpdateSessionFilename;
|
procedure UpdateSessionFilename;
|
||||||
@ -4023,34 +4024,33 @@ begin
|
|||||||
Result:=UnitCount;
|
Result:=UnitCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProject.NewUniqueUnitName(const AnUnitName: string):string;
|
function ExpUnitName(const AnUnitName: string): string;
|
||||||
|
begin
|
||||||
function ExpandedUnitname(const AnUnitName:string):string;
|
Result:=UpperCase(ExtractFileNameOnly(AnUnitName));
|
||||||
begin
|
end;
|
||||||
Result:=uppercase(ExtractFileNameOnly(AnUnitName));
|
|
||||||
end;
|
|
||||||
|
|
||||||
function UnitNameExists(const AnUnitName:string):boolean;
|
|
||||||
var i:integer;
|
|
||||||
ExpName:string;
|
|
||||||
begin
|
|
||||||
Result:=true;
|
|
||||||
ExpName:=ExpandedUnitName(AnUnitName);
|
|
||||||
if ExtractFileNameOnly(fProjectInfoFile)=ExpName then exit;
|
|
||||||
for i:=0 to UnitCount-1 do
|
|
||||||
if (Units[i].IsPartOfProject)
|
|
||||||
and (ExpandedUnitName(Units[i].FileName)=ExpName) then
|
|
||||||
exit;
|
|
||||||
Result:=false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
function TProject.UnitNameExists(const AnUnitName: string): boolean;
|
||||||
var
|
var
|
||||||
u:integer;
|
i: integer;
|
||||||
|
ExpName: string;
|
||||||
|
begin
|
||||||
|
Result:=true;
|
||||||
|
ExpName:=ExpUnitName(AnUnitName);
|
||||||
|
if ExpUnitName(fProjectInfoFile)=ExpName then exit;
|
||||||
|
for i:=0 to UnitCount-1 do
|
||||||
|
if Units[i].IsPartOfProject and (ExpUnitName(Units[i].FileName)=ExpName) then
|
||||||
|
exit;
|
||||||
|
Result:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProject.NewUniqueUnitName(const AnUnitName: string): string;
|
||||||
|
var
|
||||||
|
u: integer;
|
||||||
Prefix: string;
|
Prefix: string;
|
||||||
begin
|
begin
|
||||||
Prefix:=AnUnitName;
|
Prefix:=AnUnitName;
|
||||||
while (Prefix<>'') and (Prefix[length(Prefix)] in ['0'..'9']) do
|
while (Prefix<>'') and (Prefix[length(Prefix)] in ['0'..'9']) do
|
||||||
Prefix:=copy(Prefix,1,length(Prefix)-1);
|
SetLength(Prefix,length(Prefix)-1);
|
||||||
if not IsValidIdent(Prefix) then
|
if not IsValidIdent(Prefix) then
|
||||||
Prefix:='Unit';
|
Prefix:='Unit';
|
||||||
u:=0;
|
u:=0;
|
||||||
@ -4062,19 +4062,17 @@ end;
|
|||||||
|
|
||||||
function TProject.NewUniqueFilename(const Filename: string): string;
|
function TProject.NewUniqueFilename(const Filename: string): string;
|
||||||
var
|
var
|
||||||
FileNameOnly: String;
|
FileNOnly, FileExt: String;
|
||||||
FileExt: String;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
FileNameOnly:=ExtractFilenameOnly(Filename);
|
FileNOnly:=ExtractFilenameOnly(Filename);
|
||||||
while (FileNameOnly<>'')
|
while (FileNOnly<>'') and (FileNOnly[length(FileNOnly)] in ['0'..'9']) do
|
||||||
and (FileNameOnly[length(FileNameOnly)] in ['0'..'9']) do
|
SetLength(FileNOnly,length(FileNOnly)-1);
|
||||||
FileNameOnly:=copy(FileNameOnly,1,length(FileNameOnly)-1);
|
|
||||||
FileExt:=ExtractFileExt(Filename);
|
FileExt:=ExtractFileExt(Filename);
|
||||||
i:=0;
|
i:=0;
|
||||||
repeat
|
repeat
|
||||||
inc(i);
|
inc(i);
|
||||||
Result:=FileNameOnly+IntToStr(i)+FileExt;
|
Result:=FileNOnly+IntToStr(i)+FileExt;
|
||||||
until ProjectUnitWithShortFilename(Result)=nil;
|
until ProjectUnitWithShortFilename(Result)=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user