View Issue Details

IDProjectCategoryView StatusLast Update
0038559LazarusIDEpublic2021-03-27 22:42
ReporterJuha Manninen Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0038559: Renaming a unit does not update its references in other units
DescriptionRenaming a unit with "File -> Save As ..." its unit name is changed correctly.
Its references in other units should be updated after asking from user but it does not happen.
It has worked sometimes. I remember seeing a question :
  'The unit %s is used by other files.'
  'Update references automatically?';
function ReplaceUnitUse() in unit SourceFileManager has code for it.
It seems that a Codetools function
  GatherUnitReferences(Files,OldCode,false,IgnoreErrors,true,PascalReferences);
raises an exception internally and does not return a unit list as it should.
Steps To ReproduceOpen the attached project and rename the HelperUnit. It is used by the MainUnit but the reference is not updated.
Additional InformationI went almost 3 years back in revision history. The feature does not work even there.
I have seen it working however. Is there another way to rename a unit so that it works?
Any information?

I tested with Linux 64-bit but this does not depend on platform.
TagsNo tags attached.
Fixed in Revision64704.
LazTarget-
Widgetset
Attached Files

Activities

Juha Manninen

2021-02-28 18:53

developer  

project1.zip (108,152 bytes)

jamie philbrook

2021-02-28 21:33

reporter   ~0129256

I still have 2.0.4 loaded on this PC and using still because it has 3.0.4 compiler, but I have lots of patches in it and have no plans to move upward, yet. it all works for me.

That file name change feature works ok here because it always ask me if I want to update the references and I say yes and it works.

Hope that gives you some clues..

Bart Broersma

2021-02-28 22:37

developer   ~0129257

Last edited: 2021-02-28 22:39

View 2 revisions

Lazarus 2.1.0 r64344:64369 FPC 3.2.0 i386-win32-win32/win64
If I have uses unit1 in main prgram file ans I rename unit1.pas to unit11.pas (file save as), the IDE then updates the uses clause of the main program to uses unit11.

It does not ask me though, it simply does.

Michl

2021-02-28 23:04

developer   ~0129259

> If I have uses unit1 in main prgram file ans I rename unit1.pas to unit11.pas (file save as),
> the IDE then updates the uses clause of the main program to uses unit11.
> It does not ask me though, it simply does.

Here also this don't work. Also "Save as" of units of packages aren't working.
Lazarus 2.1.0 r64695 FPC 3.0.4 i386-win32-win32/win64

Juha Manninen

2021-03-01 10:30

developer   ~0129266

Thanks for the fix Mattias.
Bart, yes, there is an option to turn the question dialog off. I don't know why updating references worked sometimes. Maybe unitname case had to match with filename case or something. I did not study more.

In r64707 I fixed the unit name shown in editor tab right after rename.
For some reason procedure UpdateSourceNames did not work.
  SourceName:=CodeToolBoss.GetCachedSourceName(AnUnitInfo.Source);
returned an empty string for the newly renamed unit.
Anyway we don't need to update all source names here. The renamed one is enough.

Mattias Gaertner

2021-03-01 10:46

manager   ~0129267

CodeToolBoss.GetCachedSourceName returns only a value, if the unit was already parsed.
After renaming the unit needs parsing.
If you want to parse the unit use CodeToolBoss.GetSourceName.

Issue History

Date Modified Username Field Change
2021-02-28 18:53 Juha Manninen New Issue
2021-02-28 18:53 Juha Manninen File Added: project1.zip
2021-02-28 18:55 Juha Manninen Description Updated View Revisions
2021-02-28 18:55 Juha Manninen Steps to Reproduce Updated View Revisions
2021-02-28 18:55 Juha Manninen Additional Information Updated View Revisions
2021-02-28 18:55 Juha Manninen LazTarget => -
2021-02-28 21:33 jamie philbrook Note Added: 0129256
2021-02-28 22:37 Bart Broersma Note Added: 0129257
2021-02-28 22:39 Bart Broersma Note Edited: 0129257 View Revisions
2021-02-28 23:04 Michl Note Added: 0129259
2021-03-01 00:34 Mattias Gaertner Assigned To => Mattias Gaertner
2021-03-01 00:34 Mattias Gaertner Status new => resolved
2021-03-01 00:34 Mattias Gaertner Resolution open => fixed
2021-03-01 00:34 Mattias Gaertner Fixed in Revision => 64704.
2021-03-01 10:30 Juha Manninen Note Added: 0129266
2021-03-01 10:46 Mattias Gaertner Note Added: 0129267
2021-03-27 22:42 Juha Manninen Status resolved => closed