Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
IDE
Add Component Template
Background compile
Batch file target
Block Completion
Build Tools
Caliber
Class Completion
Class Explorer
Code Browsing
Code Completion
Code Editor
Code Explorer
Code Parameters
Code Templates
Compiler Message Window
Deployment Manager
Dialogs
Direct
Docking
File Browser
File Handling
Form Designer
Help
History View
IDE Insight
Memory Issues
Menu Designer
Menus
Module Manager
Multi-Monitor Support
Object Inspector
Object TreeView
Open Tools API
Packages
Performance
Printing
Project Explorer(old Object Browser)
Project Management
Refactoring
C++Rename
C++Undo Support
Change Parameters
Create Variable
Declare Field
Declare Variable
Extract Interface
Extract Method
Extract Resourcestring
Extract Superclass
Find Class
Find References
Find Unit
Inline Variable
Introduce Field
Introduce Variable
Move Members
Pull Member Up
Push Members Down
Rename
Safe Delete
Undo Support
Repository
Save Desktop
Search
Start Page
Starteam
Startup/Shutdown
Structure Pane
System Resources
ToDoList
Tool Palette
Toolbars/Status Line
Translation Tools
Unit Testing
Version Control
VersionInfo
Views
Visual Form Inheritance
Workgroup(PVCS)
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/IDE/Refactoring
[ Add a report in this area ]
Report #:
48355
Status:
Open
Refactoring only works for units explicitly in project
Project:
Delphi
Build #:
10.0.2288.42451
Version:
10.0
Submitted By:
Joe White
Report Type:
Suggestion / Enhancement Request
Date Reported:
7/1/2007 7:03:39 AM
Severity:
Infrequently encountered problem
Last Updated:
3/20/2012 2:24:39 AM
Platform:
All platforms
Internal Tracking #:
256455
Resolution:
None
(Resolution Comments)
Resolved in Build:
:
None
Duplicate of:
None
Voting and Rating
Overall Rating:
No Ratings Yet
0.00 out of 5
Total Votes:
15
Description
The refactoring tools should work across all units used by the project. They do not. They are only applied to those units that have been explicitly added to the project (via Project > Add to Project or File > New).
This makes the refactoring tools effectively unusable, unless you have some way to make sure every source file you could ever possibly compile has been explicitly added to the project. I can't imagine how this is supposed to work in a team environment, with multiple people working on the same project, and getting conflicts on the .dpr every time they add a new unit.
In a verbal discussion with Allen Bauer at a BorCon two years ago, he said that he expected the refactoring tools to work with all units compiled into a project, not just for the units that have been explicitly added with "Add to Project". That is not the actual behavior, which is why I'm filing this as a bug rather than an enhancement.
See Steps.
Steps to Reproduce:
1. File > New > Console Application - Delphi for Win32.
2. File > New > Unit.
3. Save the new unit as Unit1.
4. Using Notepad or another text editor (i.e., NOT File > New Unit in the IDE), create a new file, paste in the "Unit2" content shown below, and save it as Unit2.pas.
5. Using Notepad or another text editor, create a new file, paste in the "Unit3" content shown below, and save it as Unit3.pas.
6. Add the following uses clause to Unit1.pas:
uses Unit2, Unit3;
7. Compile (to prove that everything is compilable).
8. Open Unit2 in the IDE, put the cursor on "TFoo", and use the Rename refactoring to rename it to TBar.
9. Try to compile.
Expected: the code should compile. (If it compiled before the refactoring, and it doesn't compile after the refactoring, then it wasn't a refactoring.)
Actual: the compiler gives error "[Pascal Error] Unit3.pas(9): E2003 Undeclared identifier: 'TFoo'". This is because the refactoring was applied only to the current unit (Unit2), and not to any of the other units compiled into the project.
----
unit Unit2;
interface
type
TFoo = class
end;
implementation
end.
----
unit Unit3;
interface
uses
Unit2;
type
TBar = class(TFoo)
end;
implementation
end.
Workarounds
None
Attachment
None
Comments
Thomas Mueller at 7/1/2007 8:50:43 AM
-
I can reproduce this in Delphi 2007.
btw:
You don't need to use an external editor, just use Add->New->Unit to create all three units and past the content given in the report into them.
Save them and then remove Unit2 and Unit3 from the project using the "Remove from Project" entry in the unit's context menu.
Joe White at 7/1/2007 3:04:18 PM
-
Sure, that'll work too. I chose the steps I did because they're closer to what we usually do in practice. (Actually, we usually open a .pas file that's not in the project, do a Save As, and then gut it and put in new content.)
Alex Fekken at 10/5/2007 6:53:50 PM
-
In my opinion the real bug is that Delphi allows you to compile a unit into a project that does not explicitly include that unit. Of course fixing that would break a lot of legacy code, so I am not asking for it to be fixed. But I would not like to see that bug extended to the refactoring engine either, even though that might be the consistent thing to do.
Chris Moseley at 7/27/2010 8:51:37 PM
-
<i>real bug is that Delphi allows you to compile a unit into a project that does not explicitly include that uni</i>
I'd be happy if the factoring tool detected the problem and ideally gave you the option of adding all the extra units to the project, but failing that just said "this will break your project. Continue?". Admittedly with the ideal solution I'd then refactor purely to get that effect (add one library unit, refactor. Easier than adding all the units one at a time).
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us