mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:59:31 +02:00
IDE: renamed TUnitInfo.Unit_Name to SrcUnitName and fixed updating it, bug #27713
git-svn-id: branches/fixes_1_4@48913 -
This commit is contained in:
parent
4964caa738
commit
44faf4bfd0
@ -614,7 +614,7 @@ begin
|
||||
end else begin
|
||||
ClassUnitInfo:=Project1.UnitWithComponentClassName(aMissingTypes[i]);
|
||||
if ClassUnitInfo<>nil then
|
||||
NeededUnitName:=ClassUnitInfo.Unit_Name;
|
||||
NeededUnitName:=ClassUnitInfo.GetUsesUnitName;
|
||||
end;
|
||||
if NeededUnitName<>'' then begin
|
||||
if fUsedUnitsTool.AddUnitImmediately(NeededUnitName) then
|
||||
|
@ -322,6 +322,7 @@
|
||||
<Unit42>
|
||||
<Filename Value="project.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="Project"/>
|
||||
</Unit42>
|
||||
<Unit43>
|
||||
<Filename Value="customformeditor.pp"/>
|
||||
@ -565,6 +566,7 @@
|
||||
<Unit82>
|
||||
<Filename Value="sourcefilemanager.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="SourceFileManager"/>
|
||||
</Unit82>
|
||||
<Unit83>
|
||||
<Filename Value="../packager/lpkcache.pas"/>
|
||||
@ -649,6 +651,7 @@
|
||||
<Unit97>
|
||||
<Filename Value="etquickfixes.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="etQuickFixes"/>
|
||||
</Unit97>
|
||||
<Unit98>
|
||||
<Filename Value="etsrceditmarks.pas"/>
|
||||
@ -783,6 +786,7 @@
|
||||
<Unit125>
|
||||
<Filename Value="mainintf.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="MainIntf"/>
|
||||
</Unit125>
|
||||
<Unit126>
|
||||
<Filename Value="mainbase.pas"/>
|
||||
@ -1223,6 +1227,7 @@
|
||||
<Filename Value="useunitdlg.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<HasResources Value="True"/>
|
||||
<UnitName Value="UseUnitDlg"/>
|
||||
</Unit220>
|
||||
<Unit221>
|
||||
<Filename Value="keymapping.pp"/>
|
||||
@ -1311,6 +1316,18 @@
|
||||
<Filename Value="initialsetupproc.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit239>
|
||||
<Unit240>
|
||||
<Filename Value="qfinitlocalvardlg.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="QFInitLocalVarDialog"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit240>
|
||||
<Unit241>
|
||||
<Filename Value="../packager/interpkgconflictfiles.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<HasResources Value="True"/>
|
||||
</Unit241>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -10712,7 +10712,7 @@ var
|
||||
ConflictingClass: TClass;
|
||||
s: string;
|
||||
begin
|
||||
if SysUtils.CompareText(ActiveUnitInfo.Unit_Name,AName)=0 then
|
||||
if SysUtils.CompareText(ActiveUnitInfo.SrcUnitName,AName)=0 then
|
||||
raise Exception.Create(Format(
|
||||
lisTheUnitItselfHasAlreadyTheNamePascalIdentifiersMus, [AName]));
|
||||
if ActiveUnitInfo.IsPartOfProject then begin
|
||||
@ -11671,7 +11671,7 @@ begin
|
||||
OkToAdd:=SourceFileMgr.CheckDirIsInSearchPath(AnUnitInfo,False,False);
|
||||
if (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags) then begin
|
||||
AnUnitInfo.ReadUnitNameFromSource(false);
|
||||
ShortUnitName:=AnUnitInfo.Unit_Name;
|
||||
ShortUnitName:=AnUnitInfo.SrcUnitName;
|
||||
if (ShortUnitName<>'') then begin
|
||||
if CodeToolBoss.AddUnitToMainUsesSectionIfNeeded(
|
||||
Project1.MainUnitInfo.Source,ShortUnitName,'') then begin
|
||||
|
@ -555,7 +555,7 @@ procedure TFileDescInheritedComponent.SetInheritedUnit(const AValue: TUnitInfo);
|
||||
begin
|
||||
if FInheritedUnit=AValue then exit;
|
||||
FInheritedUnit:=AValue;
|
||||
InheritedUnits:=FInheritedUnit.Unit_Name;
|
||||
InheritedUnits:=FInheritedUnit.SrcUnitName;
|
||||
end;
|
||||
|
||||
constructor TFileDescInheritedComponent.Create;
|
||||
|
139
ide/project.pp
139
ide/project.pp
@ -287,7 +287,7 @@ type
|
||||
FRunFileIfActive: boolean;
|
||||
FSessionModified: boolean;
|
||||
fSource: TCodeBuffer;
|
||||
fUnitName: String;
|
||||
fSrcUnitName: String;
|
||||
fUsageCount: extended;
|
||||
fUserReadOnly: Boolean;
|
||||
fSourceChangeStep: LongInt;
|
||||
@ -326,7 +326,7 @@ type
|
||||
procedure SetRunFileIfActive(const AValue: boolean);
|
||||
procedure SetSessionModified(const AValue: boolean);
|
||||
procedure SetSource(ABuffer: TCodeBuffer);
|
||||
procedure SetUnitName(const NewUnitName:string);
|
||||
procedure SetSrcUnitName(const NewUnitName:string);
|
||||
procedure SetUserReadOnly(const NewValue: boolean);
|
||||
protected
|
||||
function GetFileName: string; override;
|
||||
@ -364,10 +364,9 @@ type
|
||||
procedure IgnoreCurrentFileDateOnDisk;
|
||||
procedure IncreaseAutoRevertLock; // do not auto revert from disk
|
||||
procedure DecreaseAutoRevertLock;
|
||||
function ParseUnitNameFromSource(TryCache: boolean): string;// fetch name fom source
|
||||
procedure ReadUnitNameFromSource(TryCache: boolean);// fetch unit name from source and update property UnitName
|
||||
function ReadUnitNameFromSource(TryCache: boolean): string;// fetch unit name from source and update property UnitName
|
||||
function GetUsesUnitName: string;
|
||||
function CreateUnitName: string;
|
||||
procedure ImproveUnitNameCache(const NewUnitName: string);
|
||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
Merge, IgnoreIsPartOfProject: boolean;
|
||||
FileVersion: integer);
|
||||
@ -469,7 +468,7 @@ type
|
||||
property Source: TCodeBuffer read fSource write SetSource;
|
||||
property DefaultSyntaxHighlighter: TLazSyntaxHighlighter
|
||||
read FDefaultSyntaxHighlighter write SetDefaultSyntaxHighlighter;
|
||||
property Unit_Name: String read fUnitName write SetUnitName;
|
||||
property SrcUnitName: String read fSrcUnitName write SetSrcUnitName; // unit name in source
|
||||
property UserReadOnly: Boolean read fUserReadOnly write SetUserReadOnly;
|
||||
property SourceDirectoryReferenced: boolean read FSourceDirectoryReferenced;
|
||||
property AutoReferenceSourceDir: boolean read FAutoReferenceSourceDir
|
||||
@ -1610,34 +1609,56 @@ begin
|
||||
end;
|
||||
until Result<>mrRetry;
|
||||
if ReadUnitName then begin
|
||||
fUnitName:=CodeToolBoss.GetSourceName(fSource,false);
|
||||
ReadUnitNameFromSource(false);
|
||||
end;
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.ReadUnitNameFromSource(TryCache: boolean);
|
||||
var
|
||||
NewUnitName: String;
|
||||
function TUnitInfo.ReadUnitNameFromSource(TryCache: boolean): string;
|
||||
begin
|
||||
NewUnitName:=ParseUnitNameFromSource(TryCache);
|
||||
if NewUnitName<>'' then
|
||||
fUnitName:=NewUnitName;
|
||||
Result:='';
|
||||
if TryCache then
|
||||
Result:=CodeToolBoss.GetCachedSourceName(Source);
|
||||
if Result='' then
|
||||
Result:=CodeToolBoss.GetSourceName(fSource,false);
|
||||
if Result<>'' then begin
|
||||
// source can be parsed => update SrcUnitName
|
||||
{$IFDEF VerboseIDESrcUnitName}
|
||||
if CompareFilenames(ExtractFileNameOnly(Filename),'interpkgconflictfiles')=0 then
|
||||
debugln(['TUnitInfo.ReadUnitNameFromSource ',Result]);
|
||||
{$ENDIF}
|
||||
fSrcUnitName:=Result;
|
||||
end else begin
|
||||
// unable to parse the source
|
||||
if FilenameIsPascalSource(Filename) then begin
|
||||
// use default: the filename
|
||||
Result:=ExtractFileNameOnly(Filename);
|
||||
if CompareText(Result,fSrcUnitName)=0 then begin
|
||||
// the last stored unitname has the better case
|
||||
Result:=SrcUnitName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TUnitInfo.GetUsesUnitName: string;
|
||||
begin
|
||||
if not FilenameIsPascalUnit(Filename) then
|
||||
Result:=''
|
||||
else begin
|
||||
Result:=SrcUnitName;
|
||||
if (Result='') or (CompareText(Result,ExtractFileNameOnly(Filename))<>0) then
|
||||
Result:=ExtractFileNameOnly(Filename);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TUnitInfo.CreateUnitName: string;
|
||||
begin
|
||||
Result:=Unit_Name;
|
||||
Result:=SrcUnitName;
|
||||
if (Result='') and FilenameIsPascalSource(Filename) then
|
||||
Result:=ExtractFilenameOnly(Filename);
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.ImproveUnitNameCache(const NewUnitName: string);
|
||||
begin
|
||||
if (fUnitName='') or (CompareText(fUnitName,NewUnitName)=0) then begin
|
||||
fUnitName:=NewUnitName;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TUnitInfo Clear
|
||||
------------------------------------------------------------------------------}
|
||||
@ -1663,7 +1684,7 @@ begin
|
||||
Modified := false;
|
||||
SessionModified := false;
|
||||
FRunFileIfActive:=false;
|
||||
fUnitName := '';
|
||||
fSrcUnitName := '';
|
||||
fUsageCount:=-1;
|
||||
fUserReadOnly := false;
|
||||
if fSource<>nil then fSource.Clear;
|
||||
@ -1716,6 +1737,7 @@ procedure TUnitInfo.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
var
|
||||
AFilename: String;
|
||||
i, X, Y: Integer;
|
||||
s: String;
|
||||
begin
|
||||
// global data
|
||||
AFilename:=Filename;
|
||||
@ -1740,7 +1762,9 @@ begin
|
||||
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
||||
PFComponentBaseClassNames[FResourceBaseClass],
|
||||
PFComponentBaseClassNames[pfcbcNone]);
|
||||
XMLConfig.SetDeleteValue(Path+'UnitName/Value',fUnitName,'');
|
||||
s:=fSrcUnitName;
|
||||
if (s<>'') and (ExtractFileNameOnly(Filename)=s) then s:=''; // only save if SrcUnitName differ from filename
|
||||
XMLConfig.SetDeleteValue(Path+'UnitName/Value',s,'');
|
||||
// save custom data
|
||||
SaveStringToStringTree(XMLConfig,CustomData,Path+'CustomData/');
|
||||
end;
|
||||
@ -1815,8 +1839,16 @@ begin
|
||||
AFilename:=XMLConfig.GetValue(Path+'ResourceFilename/Value','');
|
||||
if (AFilename<>'') and Assigned(fOnLoadSaveFilename) then
|
||||
fOnLoadSaveFilename(AFilename,true);
|
||||
if FilenameIsPascalSource(AFilename) then
|
||||
fUnitName:=XMLConfig.GetValue(Path+'UnitName/Value',ExtractFileNameOnly(AFilename));
|
||||
if FilenameIsPascalSource(Filename) then begin
|
||||
fSrcUnitName:=XMLConfig.GetValue(Path+'UnitName/Value','');
|
||||
if fSrcUnitName='' then
|
||||
fSrcUnitName:=ExtractFileNameOnly(Filename);
|
||||
{$IFDEF VerboseIDESrcUnitName}
|
||||
if CompareFilenames(ExtractFileNameOnly(Filename),'interpkgconflictfiles')=0 then
|
||||
debugln(['TUnitInfo.LoadFromXMLConfig ',fSrcUnitName]);
|
||||
{$ENDIF}
|
||||
end else
|
||||
fSrcUnitName:='';
|
||||
|
||||
// save custom data
|
||||
LoadStringToStringTree(XMLConfig,CustomData,Path+'CustomData/');
|
||||
@ -1853,35 +1885,15 @@ begin
|
||||
LoadStringToStringTree(XMLConfig,CustomSessionData,Path+'CustomSessionData/');
|
||||
end;
|
||||
|
||||
function TUnitInfo.ParseUnitNameFromSource(TryCache: boolean): string;
|
||||
begin
|
||||
Result:='';
|
||||
if TryCache then
|
||||
Result:=CodeToolBoss.GetCachedSourceName(Source);
|
||||
if Result='' then
|
||||
Result:=CodeToolBoss.GetSourceName(fSource,false);
|
||||
if Result='' then begin
|
||||
// unable to parse the source
|
||||
if FilenameIsPascalSource(Filename) then begin
|
||||
// use default: the filename
|
||||
Result:=ExtractFileNameOnly(Filename);
|
||||
if CompareText(Result,fUnitName)=0 then begin
|
||||
// the last stored unitname has the better case
|
||||
Result:=fUnitName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.SetUnitName(const NewUnitName:string);
|
||||
procedure TUnitInfo.SetSrcUnitName(const NewUnitName:string);
|
||||
var
|
||||
Allowed: boolean;
|
||||
OldUnitName: String;
|
||||
begin
|
||||
if (fUnitName <> NewUnitName) and (NewUnitName <> '') then
|
||||
if (fSrcUnitName <> NewUnitName) and (NewUnitName <> '') then
|
||||
begin
|
||||
Allowed := true;
|
||||
OldUnitName := fUnitName;
|
||||
OldUnitName := fSrcUnitName;
|
||||
if OldUnitName = '' then
|
||||
OldUnitName := ExtractFileNameOnly(Filename);
|
||||
if Assigned(FOnUnitNameChange) then
|
||||
@ -1891,7 +1903,11 @@ begin
|
||||
begin
|
||||
CodeToolBoss.RenameSource(fSource,NewUnitName);
|
||||
end;
|
||||
fUnitName := NewUnitName;
|
||||
{$IFDEF VerboseIDESrcUnitName}
|
||||
if CompareFilenames(ExtractFileNameOnly(Filename),'interpkgconflictfiles')=0 then
|
||||
debugln(['TUnitInfo.SetSrcUnitName ',NewUnitName]);
|
||||
{$ENDIF}
|
||||
fSrcUnitName := NewUnitName;
|
||||
Modified := true;
|
||||
if (Project <> nil) then Project.UnitModified(Self);
|
||||
end;
|
||||
@ -3455,6 +3471,7 @@ procedure TProject.AddFile(ProjectFile: TLazProjectFile; AddToProjectUsesClause:
|
||||
var
|
||||
NewIndex: integer;
|
||||
AnUnit: TUnitInfo;
|
||||
s: String;
|
||||
begin
|
||||
AnUnit:=ProjectFile as TUnitInfo;
|
||||
//debugln('TProject.AddFile A ',AnUnit.Filename,' AddToProjectFile=',dbgs(AddToProjectFile));
|
||||
@ -3473,8 +3490,11 @@ begin
|
||||
MainUnitInfo.IncreaseAutoRevertLock;
|
||||
|
||||
if AddToProjectUsesClause and (MainUnitID>=0) and (MainUnitID<>NewIndex) then
|
||||
if AnUnit.Unit_Name<>'' then // add unit to uses section
|
||||
CodeToolBoss.AddUnitToMainUsesSectionIfNeeded(MainUnitInfo.Source,AnUnit.Unit_Name,'',true);
|
||||
begin
|
||||
s:=AnUnit.GetUsesUnitName;
|
||||
if s<>'' then // add unit to uses section
|
||||
CodeToolBoss.AddUnitToMainUsesSectionIfNeeded(MainUnitInfo.Source,s,'',true);
|
||||
end;
|
||||
EndUpdate;
|
||||
UnitModified(AnUnit);
|
||||
end;
|
||||
@ -3501,9 +3521,9 @@ begin
|
||||
// remove unit from uses section and from createforms in program file
|
||||
if (OldUnitInfo.IsPartOfProject) then begin
|
||||
if RemoveFromUsesSection then begin
|
||||
if (OldUnitInfo.Unit_Name<>'') then begin
|
||||
if (OldUnitInfo.SrcUnitName<>'') then begin
|
||||
CodeToolBoss.RemoveUnitFromAllUsesSections(MainUnitInfo.Source,
|
||||
OldUnitInfo.Unit_Name);
|
||||
OldUnitInfo.SrcUnitName);
|
||||
end;
|
||||
if (OldUnitInfo.ComponentName<>'') then begin
|
||||
CodeToolBoss.RemoveCreateFormStatement(MainUnitInfo.Source,
|
||||
@ -3864,8 +3884,7 @@ end;
|
||||
|
||||
function TProject.RemoveCreateFormFromProjectFile(const AClassName,AName:string):boolean;
|
||||
begin
|
||||
Result:=CodeToolBoss.RemoveCreateFormStatement(MainUnitInfo.Source,
|
||||
AName);
|
||||
Result:=CodeToolBoss.RemoveCreateFormStatement(MainUnitInfo.Source,AName);
|
||||
if Result then begin
|
||||
MainUnitInfo.Modified:=true;
|
||||
end;
|
||||
@ -3888,9 +3907,9 @@ begin
|
||||
if ((OnlyProjectUnits and Units[Result].IsPartOfProject)
|
||||
or (not OnlyProjectUnits))
|
||||
and (IgnoreUnit<>Units[Result])
|
||||
and (Units[Result].Unit_Name<>'')
|
||||
and (Units[Result].SrcUnitName<>'')
|
||||
then begin
|
||||
if (CompareDottedIdentifiers(PChar(Units[Result].Unit_Name),PChar(AnUnitName))=0)
|
||||
if (CompareDottedIdentifiers(PChar(Units[Result].SrcUnitName),PChar(AnUnitName))=0)
|
||||
then
|
||||
exit;
|
||||
end;
|
||||
@ -5043,8 +5062,8 @@ begin
|
||||
// check if no other project unit has this name
|
||||
for i:=0 to UnitCount-1 do begin
|
||||
if (Units[i].IsPartOfProject)
|
||||
and (Units[i]<>AnUnitInfo) and (Units[i].Unit_Name<>'')
|
||||
and (CompareText(Units[i].Unit_Name,NewUnitName)=0) then begin
|
||||
and (Units[i]<>AnUnitInfo) and (Units[i].SrcUnitName<>'')
|
||||
and (CompareText(Units[i].SrcUnitName,NewUnitName)=0) then begin
|
||||
Allowed:=false;
|
||||
exit;
|
||||
end;
|
||||
@ -5564,7 +5583,7 @@ function TProject.ProjectUnitWithUnitname(const AnUnitName: string): TUnitInfo;
|
||||
begin
|
||||
Result:=fFirst[uilPartOfProject];
|
||||
while Result<>nil do begin
|
||||
if CompareText(AnUnitName,Result.Unit_Name)=0 then exit;
|
||||
if CompareText(AnUnitName,Result.SrcUnitName)=0 then exit;
|
||||
Result:=Result.fNext[uilPartOfProject];
|
||||
end;
|
||||
end;
|
||||
|
@ -436,7 +436,7 @@ begin
|
||||
if AnUnitInfo.OpenEditorInfoCount > 0 then
|
||||
AShareEditor := TSourceEditor(AnUnitInfo.OpenEditorInfo[0].EditorComponent);
|
||||
NewSrcEdit:=SrcNotebook.NewFile(
|
||||
CreateSrcEditPageName(AnUnitInfo.Unit_Name, AFilename, AShareEditor),
|
||||
CreateSrcEditPageName(AnUnitInfo.SrcUnitName, AFilename, AShareEditor),
|
||||
AnUnitInfo.Source, False, AShareEditor);
|
||||
NewSrcEdit.EditorComponent.BeginUpdate;
|
||||
MainIDEBar.itmFileClose.Enabled:=True;
|
||||
@ -1712,7 +1712,8 @@ begin
|
||||
end else
|
||||
NewUnitInfo:=TUnitInfo.Create(NewBuffer);
|
||||
//debugln(['TLazSourceFileManager.NewFile ',NewUnitInfo.Filename,' ',NewFilename]);
|
||||
NewUnitInfo.ImproveUnitNameCache(NewUnitName);
|
||||
if (CompareText(NewUnitInfo.SrcUnitName,NewUnitName)=0) then
|
||||
NewUnitInfo.SrcUnitName:=NewUnitName;
|
||||
NewUnitInfo.BuildFileIfActive:=NewFileDescriptor.BuildFileIfActive;
|
||||
NewUnitInfo.RunFileIfActive:=NewFileDescriptor.RunFileIfActive;
|
||||
|
||||
@ -1757,7 +1758,7 @@ begin
|
||||
if NewUnitInfo.OpenEditorInfoCount > 0 then
|
||||
AShareEditor := TSourceEditor(NewUnitInfo.OpenEditorInfo[0].EditorComponent);
|
||||
NewSrcEdit := SrcNoteBook.NewFile(
|
||||
CreateSrcEditPageName(NewUnitInfo.Unit_Name, NewUnitInfo.Filename, AShareEditor),
|
||||
CreateSrcEditPageName(NewUnitInfo.SrcUnitName, NewUnitInfo.Filename, AShareEditor),
|
||||
NewUnitInfo.Source, True, AShareEditor);
|
||||
MainIDEBar.itmFileClose.Enabled:=True;
|
||||
MainIDEBar.itmFileCloseAll.Enabled:=True;
|
||||
@ -2073,7 +2074,7 @@ begin
|
||||
|
||||
OldUnitName:='';
|
||||
if WasPascalSource then
|
||||
OldUnitName:=AnUnitInfo.ParseUnitNameFromSource(true);
|
||||
OldUnitName:=AnUnitInfo.ReadUnitNameFromSource(true);
|
||||
OldFilename:=AnUnitInfo.Filename;
|
||||
|
||||
if [sfSaveAs,sfSaveToTestDir]*Flags=[sfSaveAs] then begin
|
||||
@ -2148,7 +2149,7 @@ begin
|
||||
// fix all references
|
||||
NewUnitName:='';
|
||||
if FilenameIsPascalSource(AnUnitInfo.Filename) then
|
||||
NewUnitName:=AnUnitInfo.ParseUnitNameFromSource(true);
|
||||
NewUnitName:=AnUnitInfo.ReadUnitNameFromSource(true);
|
||||
NewFilename:=AnUnitInfo.Filename;
|
||||
if (NewUnitName<>'')
|
||||
and ((OldUnitName<>NewUnitName)
|
||||
@ -2243,8 +2244,8 @@ begin
|
||||
// ask user
|
||||
if AnUnitInfo.Filename<>'' then
|
||||
AText:=Format(lisFileHasChangedSave, [AnUnitInfo.Filename])
|
||||
else if AnUnitInfo.Unit_Name<>'' then
|
||||
AText:=Format(lisUnitHasChangedSave, [AnUnitInfo.Unit_name])
|
||||
else if AnUnitInfo.SrcUnitName<>'' then
|
||||
AText:=Format(lisUnitHasChangedSave, [AnUnitInfo.SrcUnitName])
|
||||
else
|
||||
AText:=Format(lisSourceOfPageHasChangedSave, [TSourceEditor(AEditor).PageName]);
|
||||
ACaption:=lisSourceModified;
|
||||
@ -2934,7 +2935,7 @@ begin
|
||||
if FileExistsCached(LFMFilename)
|
||||
and ReadLFMHeaderFromFile(LFMFilename,LFMType,LFMComponentName,LFMClassName)
|
||||
then begin
|
||||
anUnitName:=CurUnitInfo.Unit_Name;
|
||||
anUnitName:=CurUnitInfo.SrcUnitName;
|
||||
if anUnitName='' then
|
||||
anUnitName:=ExtractFileNameOnly(LFMFilename);
|
||||
ItemList.Add(LFMComponentName, CurUnitInfo.Filename,
|
||||
@ -3089,7 +3090,7 @@ begin
|
||||
AnUnitInfo.ResourceBaseClass:=FindLFMBaseClass(AnUnitInfo.Filename);
|
||||
if not ResourceFits(AnUnitInfo.ResourceBaseClass) then continue;
|
||||
end;
|
||||
AddUnit(AnUnitInfo.Unit_Name,AnUnitInfo.Filename);
|
||||
AddUnit(AnUnitInfo.SrcUnitName,AnUnitInfo.Filename);
|
||||
end;
|
||||
end else if APackage<>nil then begin
|
||||
// add package units
|
||||
@ -3155,8 +3156,8 @@ begin
|
||||
s:='"'+ActiveUnitInfo.Filename+'"'
|
||||
else
|
||||
s:='"'+ActiveSourceEditor.PageName+'"';
|
||||
if (ActiveUnitInfo.Unit_Name<>'')
|
||||
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.Unit_Name,true,ActiveUnitInfo)>=0) then
|
||||
if (ActiveUnitInfo.SrcUnitName<>'')
|
||||
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.SrcUnitName,true,ActiveUnitInfo)>=0) then
|
||||
begin
|
||||
IDEMessageDialog(lisInformation, Format(
|
||||
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith, [s]),
|
||||
@ -4264,7 +4265,7 @@ function TLazSourceFileManager.NewUniqueComponentName(Prefix: string): string;
|
||||
if CompareText(AnUnitInfo.Component.ClassName,Identifier)=0 then exit;
|
||||
end else if (AnUnitInfo.ComponentName<>'')
|
||||
and ((AnUnitInfo.IsPartOfProject) or AnUnitInfo.Loaded) then begin
|
||||
if SysUtils.CompareText(AnUnitInfo.Unit_Name,Identifier)=0 then exit;
|
||||
if SysUtils.CompareText(AnUnitInfo.SrcUnitName,Identifier)=0 then exit;
|
||||
if SysUtils.CompareText(AnUnitInfo.ComponentName,Identifier)=0 then exit;
|
||||
end;
|
||||
end;
|
||||
@ -4360,7 +4361,7 @@ begin
|
||||
IsPascal:=FilenameIsPascalSource(AFilename);
|
||||
if IsPascal then begin
|
||||
if AnUnitInfo<>nil then
|
||||
OldUnitName:=AnUnitInfo.ParseUnitNameFromSource(false)
|
||||
OldUnitName:=AnUnitInfo.ReadUnitNameFromSource(false)
|
||||
else
|
||||
OldUnitName:=ExtractFileNameOnly(AFilename);
|
||||
end else
|
||||
@ -4981,8 +4982,8 @@ begin
|
||||
OldLFMFilename:=ChangeFileExt(OldFilename,'.dfm');
|
||||
end;
|
||||
if NewUnitName='' then
|
||||
NewUnitName:=AnUnitInfo.Unit_Name;
|
||||
debugln(['TLazSourceFileManager.RenameUnit ',AnUnitInfo.Filename,' NewUnitName=',NewUnitName,' OldUnitName=',AnUnitInfo.Unit_Name,' LFMCode=',LFMCode<>nil,' LRSCode=',LRSCode<>nil,' NewFilename="',NewFilename,'"']);
|
||||
NewUnitName:=AnUnitInfo.SrcUnitName;
|
||||
debugln(['TLazSourceFileManager.RenameUnit ',AnUnitInfo.Filename,' NewUnitName=',NewUnitName,' OldUnitName=',AnUnitInfo.SrcUnitName,' LFMCode=',LFMCode<>nil,' LRSCode=',LRSCode<>nil,' NewFilename="',NewFilename,'"']);
|
||||
|
||||
// check new resource file
|
||||
NewLFMFilename:='';
|
||||
@ -5123,7 +5124,7 @@ begin
|
||||
// the code is not changed, therefore the marks are kept
|
||||
|
||||
// change unitname in lpi and in main source file
|
||||
AnUnitInfo.Unit_Name:=NewUnitName;
|
||||
AnUnitInfo.SrcUnitName:=NewUnitName;
|
||||
if LRSCode<>nil then begin
|
||||
// change resource filename in the source include directive
|
||||
if not CodeToolBoss.RenameMainInclude(AnUnitInfo.Source,
|
||||
@ -5332,7 +5333,7 @@ begin
|
||||
mtConfirmation,[mrYes,mrIgnore,lisNo,mrAbort],'');
|
||||
if Result<>mrYes then exit;
|
||||
end;
|
||||
NewUnitName:=AnUnitInfo.Unit_Name;
|
||||
NewUnitName:=AnUnitInfo.SrcUnitName;
|
||||
if NewUnitName='' then begin
|
||||
AnUnitInfo.ReadUnitNameFromSource(false);
|
||||
NewUnitName:=AnUnitInfo.CreateUnitName;
|
||||
@ -5706,7 +5707,7 @@ begin
|
||||
FormEditor1.ClearSelection;
|
||||
|
||||
// create JIT component
|
||||
NewUnitName:=AnUnitInfo.Unit_Name;
|
||||
NewUnitName:=AnUnitInfo.SrcUnitName;
|
||||
if NewUnitName='' then
|
||||
NewUnitName:=ExtractFileNameOnly(AnUnitInfo.Filename);
|
||||
DisableAutoSize:=true;
|
||||
@ -7140,7 +7141,7 @@ begin
|
||||
AFilename:='';
|
||||
// build a nice project info filename suggestion
|
||||
if UseMainSourceFile and (Project1.MainUnitID>=0) then
|
||||
AFilename:=Project1.MainUnitInfo.Unit_Name;
|
||||
AFilename:=Project1.MainUnitInfo.SrcUnitName;
|
||||
if AFilename='' then
|
||||
AFilename:=ExtractFileName(Project1.ProjectInfoFile);
|
||||
if AFilename='' then
|
||||
@ -7321,7 +7322,7 @@ begin
|
||||
MainUnitSrcEdit.CodeBuffer:=NewBuf;
|
||||
|
||||
// change program name
|
||||
MainUnitInfo.Unit_Name:=NewProgramName;
|
||||
MainUnitInfo.SrcUnitName:=NewProgramName;
|
||||
MainUnitInfo.Modified:=true;
|
||||
|
||||
// update source notebook page names
|
||||
|
@ -311,13 +311,13 @@ begin
|
||||
FImplUsedUnits.CaseSensitive := False;
|
||||
end;
|
||||
if SrcEdit.GetProjectFile is TUnitInfo then
|
||||
CurrentUnitName := TUnitInfo(SrcEdit.GetProjectFile).Unit_Name
|
||||
CurrentUnitName := TUnitInfo(SrcEdit.GetProjectFile).SrcUnitName
|
||||
else
|
||||
CurrentUnitName := '';
|
||||
// Add available unit names to list
|
||||
ProjFile:=Project1.FirstPartOfProject;
|
||||
while ProjFile <> nil do begin
|
||||
s := ProjFile.Unit_Name;
|
||||
s := ProjFile.SrcUnitName;
|
||||
if s = CurrentUnitName then // current unit
|
||||
s := '';
|
||||
if (ProjFile <> Project1.MainUnitInfo) and (s <> '') then
|
||||
|
@ -2569,7 +2569,7 @@ var
|
||||
NewHasRegisterProc:=OldPkgFile.HasRegisterProc;
|
||||
NewAddToUses:=OldPkgFile.AddToUsesPkgSection;
|
||||
end else begin
|
||||
NewUnitName:=OldProjFile.Unit_Name;
|
||||
NewUnitName:=OldProjFile.SrcUnitName;
|
||||
NewFileType:=FileNameToPkgFileType(OldFilename);
|
||||
NewCompPrio:=ComponentPriorityNormal;
|
||||
NewResourceBaseClass:=OldProjFile.ResourceBaseClass;
|
||||
@ -4350,7 +4350,7 @@ var
|
||||
end else begin
|
||||
ClassUnitInfo:=Project1.UnitWithComponentClassName(ComponentClassnames[i]);
|
||||
if ClassUnitInfo<>nil then
|
||||
NewUnitName:=ClassUnitInfo.Unit_Name;
|
||||
NewUnitName:=ClassUnitInfo.SrcUnitName;
|
||||
end;
|
||||
if (NewUnitName<>'') and (UnitNames.IndexOf(NewUnitName)<0) then begin
|
||||
// new needed unit
|
||||
|
Loading…
Reference in New Issue
Block a user